Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda