Skip to content

Added linenums for highlighting

Philip WINDECKER (AVENYR GmbH) requested to merge dev into main

This MR adds linenum to highlighted source code. It is built as a script that is added after the highlightjs script in the footer-scripts handlebar.

How it works

The script checks the page for elements of class highlightjs, then filters those with class language-none out. The reason for filtering is that Antora/Asciidoctor also converts nested source code blocks, e.g. when showcasing the AsciiDoc syntax for source code blocks. If these were not filtered, nested source code blocks would incorrectly get added linenums as well.

Known limitations

  • Asciidoctor/Antora or highlightjs (unclear which one) do not copy the linenums attribute to the html file. It is thus not possible to have control over whether a source code block gets linenumbers or not. Therefore, this feature is now active all the time.
Edited by Philip WINDECKER (AVENYR GmbH)

Merge request reports