Skip to content

Enable AsciiDoc syntax highlighting (using Rouge)

What does this MR do?

Enable syntax highlighting for AsciiDoc. Basically we generate the following HTML for source blocks:

<pre><code lang="LANG">some code\n</code></pre>

This syntax is compatible with GitLab Flavored Markdown (GFM). We can then use the Banzai::Filter::SyntaxHighlightFilter in the AsciiDoc pipeline.

Please note that callouts are not rendered correctly because the SyntaxHighlightFilter is designed for Markdown (which does not have this feature).

Since Asciidoctor provides a built-in syntax highlighter based on Rouge we could potentially configure source-highlighter' => 'rouge' to let Asciidoctor do the syntax highlighting. But this approach only works if the sanitization does not remove CSS classes in the pre > code > span elements.

Wiki

Before After
no-syntax-highlighting-wiki syntax-highlighting-wiki

Repository

Before After
no-syntax-highlighting-adoc syntax-highlighting-adoc

resolves #32635 (closed)

Does this MR meet the acceptance criteria?

Conformity

Edited by Guillaume Grossetie

Merge request reports