Add: optional syntax highlighting with pygments#26
Conversation
TrueBrain
left a comment
There was a problem hiding this comment.
I like what you did here. Some coding-style stuff mostly. The summary of it is: name things as they are ;)
|
Two minor flake8 warnings left; otherwise good to go as far as I am concerned! |
I removed the unused import, but I don't know if the second is fixable. Is is possible to break up the regex without ruining it? |
(sorry for the slow replies; it is a bit busy on my side). Hmm, I do not know :D But honestly, I am not that fuzzed the line is too long; it makes total sense to have it as a single line in this case. So I am also totally fine if you add a |
|
Kind reminder; just a small thing left to get this merged :D |
Yeah, sorry about the wait. I did figure out that long regexps can be split using normal string literal concatenation: https://stackoverflow.com/a/8006576 |
|
Tnx again for this work! I will make a release out of this soon so we can update TrueWiki :) |
|
Right, released a new wikitexthtml, and bumped it in TrueWiki. @Qrbaker : you had a commit ready to enable it in TrueWiki? :D |
This PR adds the option to render the MediaWiki
<syntaxhighlight>tag. Currently it supports the "lang" and "line " options of the feature. Note that iflangis not supplied, the processor will make a best guess and highlight based on heuristics.By default, anything downstream will not see any changed behavior. If downstream projects wish to use the new feature, they may do so by calling the
prepare()method with theshould_color_syntaxargument set toTrue.I have a companion PR ready for TrueWiki that will add this functionality and expose a setting in the
.truewiki.ymlfile to toggle it. If toggled off, wikitexthtml converts any instances of<syntaxhighlight></syntaxhighlight>pairs to<pre>tags.Here are some examples of what this looks like in practice:
Syntax highlighting with default options

Syntax highlighting with

lineoptionSyntax highlighting with

line 6800optionI should also note that without CSS, these blocks will look identical to
<pre>blocks.Pygmentshas the ability to both output css styling to be piped to a file, or it can render it inline with the html.The examples above were rendered with the following CSS (applied in a second file in addition to the default wiki css in TrueWiki):
https://gist.github.com/Qrbaker/424bdd7d48b88557be1340eb208a7c6f