SomeBruh
SomeBruh

Reputation: 460

highlight.js doesn't auto detect language

I downloaded highlight.pack.js from https://highlightjs.org/download/ and expecting it to highlight <pre><code> block automatically, without specifying any languages.

However an exeption is thrown when I load the page:

Uncaught SyntaxError: Invalid regular expression: /([À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*(<[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*(\s*,\s*[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*)*>)?\s+)+[a-zA-Z_]\w*\s*\(/: Range out of order in character class

But if I specify the language <pre><code class="fsharp"> then everything works fine. Also, the cdn hosted highlight.min.js can auto-detect languages but it doesn't have the languages I need.

Any idea how I can get it work?

Upvotes: 1

Views: 3462

Answers (2)

Nima Habibollahi
Nima Habibollahi

Reputation: 480

Add UTF-8 characterset in the head section of your HTML file :

<head>
  <meta charset="UTF-8">
</head>

Upvotes: 2

David R
David R

Reputation: 15667

You need to be including charset="utf-8" to the tag where you're including the highlight.js library.

Hope this will resolve your issue.

Upvotes: 4

Related Questions