Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
highlight.js not working on django+dash website

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?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!