This PR introduces syntax highlighting of fenced code blocks via a Statocles plugin.
There are 3 steps which build on top of each other:
Remove highlight.js and related references
Except the CSS theme for the highlighted fragments, so the exact same design can be reused, or even replaceed easily later.
Add a site-specific Statocles plugin for highlighting
It is now living in ./lib under project root, so has to be included on recent Perl versions with PERL5LIB="./lib:${PERL5LIB}" or similar.
It basically hooks into the page collection step of the Statocles build process, and preprocesses each document by replacing fenced code blocks with HTML fragments including <span class="...">...</span> tags around parts that needs to be highlighted.
It also adds leading invisible and non-copyable (? fixme!) WORD JOINER characters to the code blocks, so the subsequent markdown rendering will leave these fragments intact, while also not interfering with copy-pasting from the browser.
It expects code fences with hints about the language of the code blocks, and supports any language that is supported by Syntax::Highlight::Engine::Kate.
Add fences around code blocks which need highlighting
This is the last step needed to actually enable the preprocessing and highlighting of the code blocks.
As a side effect, it makes it relatively easy to identify perl code blocks and process them in various ways, e.g. run perltidy on them (stay tuned for a followup PR, work in progress :).
This PR introduces syntax highlighting of fenced code blocks via a Statocles plugin.
There are 3 steps which build on top of each other:
Remove highlight.js and related references
Except the CSS theme for the highlighted fragments, so the exact same design can be reused, or even replaceed easily later.
Add a site-specific Statocles plugin for highlighting
It is now living in
./lib
under project root, so has to be included on recent Perl versions withPERL5LIB="./lib:${PERL5LIB}"
or similar.It basically hooks into the page collection step of the Statocles build process, and preprocesses each document by replacing fenced code blocks with HTML fragments including
<span class="...">...</span>
tags around parts that needs to be highlighted.It also adds leading invisible and non-copyable (? fixme!)
WORD JOINER
characters to the code blocks, so the subsequent markdown rendering will leave these fragments intact, while also not interfering with copy-pasting from the browser.It expects code fences with hints about the language of the code blocks, and supports any language that is supported by
Syntax::Highlight::Engine::Kate
.Add fences around code blocks which need highlighting
This is the last step needed to actually enable the preprocessing and highlighting of the code blocks.
As a side effect, it makes it relatively easy to identify perl code blocks and process them in various ways, e.g. run perltidy on them (stay tuned for a followup PR, work in progress :).