-
-
Notifications
You must be signed in to change notification settings - Fork 789
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
Code in Tables Not Highlighted #2990
Comments
Tree processors do not get called separately for AsciiDoc table cells. It's up to the extension to descend into the table, find the AsciiDoc table cells, and descend into those. You can use the mathematical extension as a reference. See https://github.com/asciidoctor/asciidoctor-mathematical/blob/master/lib/asciidoctor-mathematical/extension.rb#L45-L59 This is something we need to make easier in Asciidoctor, but that's a separate issue. |
Thanks for the clarification. Would this also affect code blocks inside admonitions?
Indeed, it would make sense that source code is treated the same in respect to syntax highlighting, regardless of whether it appears in the main body of text or inside tables, admonitions, etc. |
Asciidoctor 2.0 introduces a new API for registering a syntax highlighter adapter. I recommend that you use this for your highlight extension. Here's an example: https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/syntax_highlighter/coderay.rb Instead of having to find nodes in a tree processor extension, the adapter gets called by the processor to highlight the relevant nodes, contribution markup to the output, and write a custom stylesheet. You can find the API docs here: https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/syntax_highlighter.rb I look forward to your feedback. |
To answer your question, no. Although admonition blocks are laid out using tables, they are not themselves table nodes. |
Please open a new issue if you have follow-up questions or feedback. |
I'm working on an AsciiDoc document which uses Highlight as an external syntax highlighter (via the Highlight Treeprocessor Extension). Code block in the main document are being highlighted fine, but blocks inside tables not.
I have some tables with a column set as ADoc (
[cols="<1m,<6a"]
) and some cells in that column contain code blocks. Although in the final HTML document the block is correctly shown as a code block, with the proper language, nevertheless the code is not highlighted.For some reason, it seems that code blocks inside tables are being ignored by the Treeprocessor extension.
Is it an Asciidoctor bug? or is it just a problem with the Highlight Treeprocessor Extension?
The text was updated successfully, but these errors were encountered: