Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight Lines in Source disables syntax colouring #525

Open
abul4fia opened this issue Jan 27, 2024 · 2 comments
Open

Highlight Lines in Source disables syntax colouring #525

abul4fia opened this issue Jan 27, 2024 · 2 comments

Comments

@abul4fia
Copy link

I don't know if I'm doing something wrong. My setup is:

:source-highlighter: highlightjs
:revealjsdir: https://cdn.jsdelivr.net/npm/[email protected]
:revealjs_theme: white

If I wrote code such as:

=== Example

[source,c]
----
#include <stdio.h>

int main() {
    printf("Hello\n");
    return 0;
}
----

then all works as expected, and I get coloured syntax in the slide:

image

But if I try to highlight one line:

=== Example

[source,c, highlight=4]
----
#include <stdio.h>

int main() {
    printf("Hello\n");
    return 0;
}
----

Then two unexpected things happen:

  1. Lines are suddenly numbered
  2. Syntax colouring disappears. Everything is gray
image

I'm using

Asciidoctor reveal.js 5.1.0 using Asciidoctor 2.0.18 [https://asciidoctor.org]
Runtime Environment (ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]) (lc:UTF-8 fs:UTF-8 in:UTF-8 ex:UTF-8)

I'm I doing something wrong? Is this a known issue? I was unable to find anything...

@abul4fia abul4fia changed the title Highlight Lines in Source disable syntax colouring Highlight Lines in Source disables syntax colouring Jan 27, 2024
@ggrossetie
Copy link
Member

ggrossetie commented Feb 3, 2024

Lines are suddenly numbered

Did you try to enable line numbering? https://docs.asciidoctor.org/asciidoc/latest/verbatim/source-highlighter/#enable-line-numbering

Line numbering is not enabled by default.

[%linenums,ruby]
----
puts 1
puts 2
puts 3
----

Syntax colouring disappears. Everything is gray

Are you using a custom CSS.

@Godin
Copy link

Godin commented Feb 5, 2024

FWIW

if I try to highlight one line

  1. Lines are suddenly numbered

this is not specific to Asciidoctor and a kinda feature of reveal.js itself - line numbers and lines highlighting are controlled by the same data-line-numbers, see https://revealjs.com/code/#line-numbers-%26-highlights

You can enable line numbers by adding data-line-numbers to your <code> tags. If you want to highlight specific lines you can provide a comma separated list of line numbers using the same attribute.

however one can hide line numbers using custom CSS

.hljs-ln-numbers {
  display: none;
}
  1. Syntax colouring disappears.

seems to be specific to Asciidoc when # presented in code block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants