Configuring wagtail-markdown to use Prism instead of Pygments
Is there a way to inject a class into the <code>
tag produced by wagtail-markdown so that I can style my Markdown code blocks with Prism instead of Pygments, which is the default syntax highlighter? Ideally, I'd like to choose the language in the first line of my Markdown as in e.g.
:::python
for i in range(5):
print(i**2)
and have it add the class="language-python"
attribute required by Prism to style the block nicely.
It turns out I just needed to pass a parameter to the extension_configs
for codehilite
in my Django settings file, as part of the WAGTAILMARKDOWN
setting:
WAGTAILMARKDOWN = {
"allowed_tags": ["sub", "sup"],
"tab_length": 4,
"extension_configs": {
"codehilite": [
("use_pygments", False),
]
},
}
This is more documented as part of Pygments than in the README for wagtail-markdown.