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

Support Rouge as syntax highlighter #226

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

manuelprinz
Copy link

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.)

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: asciidoctor#221
@manuelprinz
Copy link
Author

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.

@djencks
Copy link
Contributor

djencks commented Feb 12, 2021

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.

@mojavelinux
Copy link
Member

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

@manuelprinz
Copy link
Author

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

@djencks
Copy link
Contributor

djencks commented Mar 17, 2021

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 {"

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

Successfully merging this pull request may close these issues.

Add support for rouge code highlighter
3 participants