Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda