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

99
Vistas
HighlightJS not highlighting certain code fragments

I'm using HighlightJS to format code that's being stored in a model's TextField of my Django application.

Here is the template HTML:

<pre>
  <code class="{{ compiler.highlight_js_alias }}">{{ compiler.unit_test_boilerplate_code }}</code>
</pre>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/styles/default.min.css"
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/highlight.min.js"></script>
<script>hljs.highlightAll();</script>

Example output:

<pre>        
  <code class="ruby hljs language-ruby">
    <span class="hljs-keyword">class</span> 
    <span class="hljs-title class_">Person</span>
    :
    <span class="hljs-keyword">def</span> 
    <span class="hljs-title function_">__init__</span>
    (
    <span class="hljs-params">
    <span class="hljs-variable language_">self</span>, name, age</span>
    ):
    <span class="hljs-variable language_">self</span>
    .name = name
    <span class="hljs-variable language_">self</span>
    .age = age
    me = Person(
    <span class="hljs-string">"Nathan"</span>
    <span class="hljs-number">32</span>
    )
    print(me.name)
  </code>
</pre>

Why are certain fragments not highlighted? Thank you for any advice.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

After inspecting the outputted HTML of HighlightJS' own demos, it seems this is expected behavior.

about 4 years ago · Juan Pablo Isaza Denunciar
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