jekyll-asciidoc icon indicating copy to clipboard operation
jekyll-asciidoc copied to clipboard

Support Rouge as syntax highlighter

Open manuelprinz opened this issue 5 years ago • 5 comments

Commit message:

Refactors code to be more generic, following the same model/prefixes as with pygments. It also calls the Asciidoctor syntax highlighter factory directly, as there are no helper methods for rouge in the Stylesheets class in Asciidoctor.

Closes: #221

I tested the package locally and it seems to work fine. The tests are a modified copy of the Pygments tests. I am unsure if it is reasonable to have the default value of {pygments,rouge}-stylesheet to be highlighter-dependent, as it will make it harder to integrate the Asciidoc plugin into templates, without forcing users to re-define it in every Jekyll configuration; so maybe setting both to asciidoc-highlighter.css might be a better choice. What are you thoughts?

Feedback is always welcome! (My Ruby is not that great, yet.)

manuelprinz avatar Feb 12 '20 07:02 manuelprinz

The Travis CI fails because I was not aware that the API I used is Asciidoctor 2.x only. I do not know what the best way forward is now, I see two options:

  1. Update Asciidoctor 1.5 with helper methods for Rouge similar to those for Pygments. (I am unsure if Rouge as supported at all in this version. It seems like it wasn't.)
  2. Revert back to the API using the helper method for Pygments and error out if Rouge is configured when Asciidoctor 1.5 is used. This would mean the tests have to be skipped for this scenario.

As for the failures of AppVeyor, I fail to understand how this is related to this change. Any suggestions are welcome.

manuelprinz avatar Feb 12 '20 18:02 manuelprinz

I'm starting to look at this.... one year later to the day :-) One good thing is that now 3.1.x is firmly on asciidoctor 2.

djencks avatar Feb 12 '21 07:02 djencks

I definitely think this integration should only be done using the Asciidoctor 2 API, so forge ahead!

mojavelinux avatar Feb 12 '21 07:02 mojavelinux

Thanks for having a look at it! I can have another look at it and update, if needed. Just let me know.

manuelprinz avatar Mar 16 '21 07:03 manuelprinz

Thanks for bringing me back to this, I got distracted.

I'd like to leverage all of the Asciidoctor 2.0 syntax highlighter support, so both all the built in highlighters and any custom highlighter can be used equivalently. Now that there's docinfo support in jekyll-asciidoc, I think we can use that to install the appropriate head styles and header/footer scripts. This will be something the user has to set up in their template, but at least it will be the same for every highlighter.

I'm going to start by setting up a test that uses all the built-in highlighters so we can compare what happens.

I don't understand yet what the purpose of this line is, since it doesn't seem to be needed for regular Asciidoctor:

css = css.sub RootSelector[highlighter.to_sym], "\1.#{highlighter}, \1.#{highlighter} code {"

djencks avatar Mar 17 '21 19:03 djencks