Loss of syntax highlighting on the forum

@magjac do you know why we seem to have lost syntax highlighting of inline snippets?

Here is a previous post of mine, How to interpret Graphviz Edge coordinates from xDOT or JSON - #9 by smattr, screenshotted below if you’re not seeing what I’m seeing:

Now here is a more recent post, How to make child nodes not interweaved - #7 by smattr, again screenshotted:

I know these posts have identical source because I went to edit and copied the text out of the first post to create the second. Any idea why syntax highlighting isn’t working?

No I don’t. And I see the same as you. It’s strange since I thought these were rendered on the fly, i.e., it shouldn’t matter if the post is old or new. Here’s my attempt that also doesn’t work:

digraph {
  like -> so[with="a label"];
}

Mysterious. I guess the syntax highlighting isn’t a big deal as it doesn’t actually seem very accurate (the emphasised with is not a keyword, but the unemphasised digraph is).

Looking in the web inspector, I see a data-unknown-hljs-lang="dot" which may be a clue that dot is no longer known by the syntax highlighting library.

<code class="lang-dot" data-unknown-hljs-lang="dot">digraph {
  like -&gt; so[with="a label"];
}
</code>

Searching for hljs shows up https://highlightjs.org/.

Contrast with the code snippet I just typed, which starts like:

<code class="lang-html hljs language-xml" data-highlighted="yes">

I suspect either the way Discourse is configuring this hljs library has changed, or hljs has dropped support for dot.

https://highlightjs.readthedocs.io/en/latest/supported-languages.html

does not list ‘dot’ or graphviz.

Here’s the old feature request for highlight js to add graphviz/dot support: Support PlantUML and Graphviz Dot · Issue #1726 · highlightjs/highlight.js · GitHub

Here’s the docs on how Discourse admins can configure which languages get syntax highlighting (this seems configurable by us): Configure which programming languages are available for syntax highlighting - Site Management - Discourse Meta

I wonder if we ever had syntax highlighting for dot, or if it just fell back to JavaScript syntax highlighting? That would explain the with highlighting.

If I right-click, “Inspect Element” on that HTML in the highlighted forum post, I see it’s using C# highlighting:

<code class="hljs language-csharp" data-highlighted="yes">digraph {
  like -&gt; so[<span class="hljs-keyword">with</span>=<span class="hljs-string">"a label"</span>];
}
</code>

That’s surprising. I wonder how it got to C#. Maybe it was content-sniffing, or maybe it was configured to use C# for dot.

Maybe it’s matching dot as a prefix of dotnet.