I have a django website where I'd like to display blocks of code w/ syntax highlighting.
I've installed highlight.js and per their instructions am injecting style and js into html, in this case in base.html:
...
<link rel="stylesheet" href="{% static 'highlight/styles/default.min.css' %}">
<script src="{% static 'highlight/highlight.min.js' %}"></script>
<script>hljs.highlightAll();</script>
I then add code to some view using dash html components:
...
html.Div([html.H3(title),
html.Pre(html.Code(code, className=f'language-{lang}'))])
The code isnt't syntax highlighted. Not sure how to troubleshoot this.
Edit: If hardcode a <pre><code>...</pre><code> element into an html template that will get highlight.js applied to it, where inspecting the element shows the various transformations to each word in the code block. However if the HTML is generated by dash, such as in the above, it is just a plain <pre><code>...</pre><code> block. How do I allow highlight.js to apply to dash generated HTML?