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

98
Views
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 answers
Answer question

0

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

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