asciidoctor / asciidoctor-reveal.js

:crystal_ball: A reveal.js converter for Asciidoctor and Asciidoctor.js. Write your slides in AsciiDoc!
http://asciidoctor.org
Other
289 stars 188 forks source link

Syntax highlighting doesn't work when following the most recent instructions #530

Closed kito99 closed 5 months ago

kito99 commented 5 months ago

I've been using asciidoctor-reveal.js on and off for several years, but for some reason, syntax highlighting doesn't work in a new presentation I created last year. This is using 5.0 and following the instructions here: https://docs.asciidoctor.org/reveal.js-converter/latest/setup/ruby-setup/. Initially I tried the Ruby install, but I also tried a new sample project with Ruby and plain Node, and either way. I also tried reverting to 4.1 and that didn't make a difference either. I get the same result: the HTML output has the right CSS classes, but highlight.js isn't loaded in the output. For reference, here is the sample presentation I'm using:

= Foo bar baz

:source-highlighter: highlight.js
:highlightjs-languages: java

== Blah

* one
* two 
* three

== Bar

[source, java]
----
package hello;

import org.springframework.data.redis.core.ReactiveRedisOperations;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class CoffeeController {
private final ReactiveRedisOperations<String, Coffee> coffeeOps;

  CoffeeController(ReactiveRedisOperations<String, Coffee> coffeeOps) {
    this.coffeeOps = coffeeOps;
  }

  @GetMapping("/coffees")
  public Flux<Coffee> all() {
    return coffeeOps.keys("*")
        .flatMap(coffeeOps.opsForValue()::get);
  }
}
----
ggrossetie commented 5 months ago

You need to remove the blank line after the document title:

= Foo bar baz
:source-highlighter: highlight.js
:highlightjs-languages: java

Otherwise, :source-highlighter: is not defined as a document attribute but as an attribute defined in the "body".

kito99 commented 5 months ago

Thank you so much @ggrossetie! I totally missed that. I even compared it to prior presentations that worked and didn't see that detail!

It's a little counter-intuitive because many of the other revealjs-related attribute (I'd say, all of the others I've tried), work fine either way.

I'll make a PR for the docs.

kito99 commented 5 months ago

PR: https://github.com/asciidoctor/asciidoctor-reveal.js/pull/531

ggrossetie commented 5 months ago

Documentation updated in #531