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

Sourcecode highlighting with coderay or pygments not working #163

Closed
dschulten opened this issue Dec 25, 2017 · 14 comments
Closed

Sourcecode highlighting with coderay or pygments not working #163

dschulten opened this issue Dec 25, 2017 · 14 comments
Milestone

Comments

@dschulten
Copy link
Contributor

Even when I install coderay

gem install coderay

or pygments

gem install pygments.rb

I cannot use either of

:source-highlighter: coderay
:source-highlighter: pygments

I get

uninitialized constant CodeRay

or

uninitialized constant Pygments
@obilodeau
Copy link
Member

Using asciidoctor (ruby) or asciidoctor.js (javascript)?

@keenJoe
Copy link

keenJoe commented Dec 26, 2017

what's mean using asciidoctor or asciidoctor.js? like : asciidoctor -D output speaker-note.adoc? This way creates html file with source hignlight,but not in the slides.

@keenJoe
Copy link

keenJoe commented Dec 26, 2017

asciidoctor: WARNING: optional gem 'coderay' is not installed. Functionality disabled.

@dschulten
Copy link
Contributor Author

dschulten commented Dec 26, 2017

The above observation is from a javascript execution with 1.0.4.

@dschulten
Copy link
Contributor Author

dschulten commented Dec 26, 2017

In 1.1.0 I get:

$ node asciidoctor-revealjs.js
D:\Dokumente\ws\microfrontends-revealjs\node_modules\opal-runtime\src\nodejs.js:93
        throw Opal.IOError.$new(error.message)
        ^
IOError: ENOENT: no such file or directory, open 'D:\Dokumente\ws\mypresentation-revealjs\data\stylesheets\coderay-asciidoctor.css'

Apparently the converter is looking in a data\stylesheets folder in my presentation project. (Same for pygments)

@dschulten
Copy link
Contributor Author

@keenJoe The warning about the missing gem tells you that you need to install coderay, see my original issue description.

@obilodeau
Copy link
Member

I think, for simplicity, we should just explicitly document that we only support highlight.js.

From Javascript it's going to be a pain to implement. From Ruby, out of the box, coderay doesn't work and pygments you need to manually change your Gemfile and the default style is incompatible with reveal.js' themes.

Is highlightjs adequate for your needs?

@dschulten
Copy link
Contributor Author

Very much so, especially since the reason to switch to other highlighters was mainly caused by the callouts issue. Should I write a readme PR?

@mojavelinux
Copy link
Member

mojavelinux commented Dec 28, 2017

Coderay should work. You just need to install it (add it to Gemfile and run bundle), then also configure Coderay (via Asciidoctor) to add the styles inline:

= Presentation Title
:coderay-css: inline

I agree that highlight.js is probably going to be the best experience, minus the fact that it stumbles over callout bubbles.

@dschulten
Copy link
Contributor Author

@mojavelinux highlightjs stumbles no more, see the current additions to master :)

At least we should state clearly that coderay only really works with a ruby setup, not with Javascript.

However, there seems to be an issue right now:

= Presentation Title
:source-highlighter: coderay
:coderay-css: inline

with gem 'coderay', '~> 1.1.2' in my Gemfile gives me:

$ bundle exec asciidoctor-revealjs index.adoc
mypresentation/.bundle/gems/ruby/2.4.0/gems/coderay-1.1.2/lib/coderay/encoders/html.rb:274: \
    in `check_options!': Unknown value :inline for :css. (ArgumentError)

backtrace
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/coderay-1.1.2/lib/coderay/encoders/html.rb:175:in `setup'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/coderay-1.1.2/lib/coderay/encoders/encoder.rb:73:in `encode'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/coderay-1.1.2/lib/coderay/duo.rb:66:in `encode'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/substitutors.rb:1406:in `highlight_source'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/substitutors.rb:128:in `block in apply_subs'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/substitutors.rb:115:in `each'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/substitutors.rb:115:in `apply_subs'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/block.rb:118:in `content'
        from D:/Dokumente/ws/asciidoctor-reveal.js/lib/asciidoctor-revealjs/converter.rb:2335:in `block in listing'
        from D:/Dokumente/ws/asciidoctor-reveal.js/lib/asciidoctor-revealjs/converter.rb:2212:in `instance_eval'
        from D:/Dokumente/ws/asciidoctor-reveal.js/lib/asciidoctor-revealjs/converter.rb:2212:in `listing'
        from D:/Dokumente/ws/asciidoctor-reveal.js/lib/asciidoctor-revealjs/converter.rb:141:in `convert'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/abstract_block.rb:70:in `convert'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/abstract_block.rb:79:in `block in content'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/abstract_block.rb:79:in `map'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/abstract_block.rb:79:in `content'
        from D:/Dokumente/ws/asciidoctor-reveal.js/lib/asciidoctor-revealjs/converter.rb:3196:in `block in section'
        from D:/Dokumente/ws/asciidoctor-reveal.js/lib/asciidoctor-revealjs/converter.rb:2839:in `instance_eval'
        from D:/Dokumente/ws/asciidoctor-reveal.js/lib/asciidoctor-revealjs/converter.rb:2839:in `section'
        from D:/Dokumente/ws/asciidoctor-reveal.js/lib/asciidoctor-revealjs/converter.rb:141:in `convert'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/abstract_block.rb:70:in `convert'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/abstract_block.rb:79:in `block in content'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/abstract_block.rb:79:in `map'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/abstract_block.rb:79:in `content'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/document.rb:1120:in `content'
        from D:/Dokumente/ws/asciidoctor-reveal.js/lib/asciidoctor-revealjs/converter.rb:1100:in `block in document'
        from D:/Dokumente/ws/asciidoctor-reveal.js/lib/asciidoctor-revealjs/converter.rb:716:in `instance_eval'
        from D:/Dokumente/ws/asciidoctor-reveal.js/lib/asciidoctor-revealjs/converter.rb:716:in `document'
        from D:/Dokumente/ws/asciidoctor-reveal.js/lib/asciidoctor-revealjs/converter.rb:141:in `convert'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/document.rb:1060:in `convert'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor.rb:1502:in `convert'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor.rb:1575:in `block in convert_file'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor.rb:1575:in `open'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor.rb:1575:in `convert_file'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/cli/invoker.rb:108:in `block in invoke!'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/cli/invoker.rb:102:in `each'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/cli/invoker.rb:102:in `invoke!'
        from D:/Dokumente/ws/asciidoctor-reveal.js/bin/asciidoctor-revealjs:18:in `'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/bin/asciidoctor-revealjs:23:in `load'
        from D:/Dokumente/ws/microfrontends-revealjs/.bundle/gems/ruby/2.4.0/bin/asciidoctor-revealjs:23:in `'

@mojavelinux
Copy link
Member

highlightjs stumbles no more, see the current additions to master :)

Just saw that. Very nice!

At least we should state clearly that coderay only really works with a ruby setup, not with Javascript.

That's absolutely correct. Though we have to be aware that our users are split (probably pretty evenly) between JavaScript and Ruby (which is also our Java users via AsciidoctorJ). So we're really catering to different groups and just need to funnel them accordingly.

:coderay-css: inline

My mistake, this should be:

:coderay-css: style

(the value refers to which HTML attribute it uses, class or style. class is the default).

@obilodeau
Copy link
Member

I did some tests with coderay, pygments, prettify and highlightjs today. I don't have time to push them up yet but I can confirm that coderay and pygments work from a Ruby setup (w/ Gemfile changes), that highlightjs works out of the box and that we don't support prettify.

I'll push the tests linking to this issue and open a new compliance issue about prettify's support.

@dschulten if you want to do a README PR stating that we only officially support highlightjs for now please do so.

@mojavelinux
Copy link
Member

Thanks for testing @obilodeau!

@obilodeau
Copy link
Member

I filed #171 for prettify, merged examples (and notes) with all highlighters in #170 and sent PR #175 for the documentation updates.

Once #175 is reviewed and merged I think we can close this ticket. Objections?

@obilodeau obilodeau added this to the 1.1.1 milestone Jan 2, 2018
obilodeau added a commit that referenced this issue Jan 3, 2018
doc: Clarified syntax highlighting support (fixes #163)
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

4 participants