Code highlighting seems to ignore escaped quotes (both single and double). Meaning, if a string within a code section contains escaped quotes, parts of the string are highlighted like normal code. In this forum code highlighting seems to be disabled, hence I include the link to the specific forum post where I’ve noticed it for the first time.
Code highlighting is enabled for bash, cs, cpp, xml, ini, json, makefile, markdown, python, c, c-like. Default is set to cpp. Resetting these language highlighting settings to default doesn’t solve the issue.
Issue is also present when escaping single-quotes in a single-quoted string (escaping single-quote in a double-quoted string and vice-versa works properly).
Indeed, cpp highlighting works if set explicitly. However, while looking into this a bit further I found another… unexpected behavior.
I removed all languages from the highlighted languages list except for cpp and reverted the default language back to auto. The result was still a wrong highlighting. Opening the Inspector in Firefox revealed that the code is apparently recognized as vbnet - a language that was never in the list of highlighted languages (neither the default one nor any custom ones I tried for this issue)? Is this supposed to happen?
I reloaded the page. While the forum post itself never changed - even when restarting firefox or reloading the page with CTRL+F5 - I noticed that the preview for editing the post does use the modified settings when reloading the page.
So, with cpp as only language in the list (to keep things simple), if I set the default language to cpp, code highlighting in the post edit preview is correct. If I set the default language to auto and again reload the page, it’s not correct anymore as described in the previous post.
Restarting the browser won’t do it. In Discourse posts are baked (converted from markdown to HTML) in the server just once, and the resulting HTML is cached in the database. In order to updated said cooked post, you need to “rebake” it. This can be done by a staff user using the wrench menu on a post or by the post author by editing said post contents.
Thx. Rebaking results in the same behavior as with the edit preview though. auto selects a language (vbnet) that’s not in the list of languages to highlight. Setting the default lang explicitly to cpp (either in the forum settings or as you showed here) does work as reported earlier.
So the question remains: is auto supposed to use other languages than those in the list?