Skip to main content
10 of 10
edited tags
Frog StaffMod
  • 2.2k
  • 1
  • 10
  • 21

Syntax highlighting when using a `lang-*` alias (and some "main" language codes) is broken

As cocomac points out in the comments, this specific instance of the issue may be explained by this; so the example below, that showcases the bug for lang-vim, is an unfortunate one.

However:

  1. The same also happens for lang-console, which is listed among the supported languages, and at the same time lang-shell works, so it seems like the bug is there anyways, and it's affecting some aliases handled by Highlight.js and, as shown by the tests conducted by zcoop98, also some "main" language codes (see the lang-javascript example in their answer; in that case, lang-javascript, a "main" language code, is broken; bizarrely, lang-js, an SE alias for lang-javascript, works);
  2. I'd argue that there's also a side-bug in the discrepancy between what's shown in the preview and what's shown in the edited post for unsupported languages; preview and edited post should be consistent with each other. A minor thing, I agree, but still kinda annoying. Personally, I like to see exactly how my post is gonna look like.

Initial (partially wrong) report, now amended by the paragraphs above:

This is new, it used to work fine up until a few days ago.

On multiple sites (I've experienced this on Ask Ubuntu and Unix & Linux), syntax highlighting when using lang-* with a language that doesn't have a tag that hints at it is broken; the post is displayed correctly in the preview while editing it, but syntax highlighting isn't applied at all after the edit has been sent through.

I'm saying "with a language that doesn't have a tag that hints at it" because, on the same post, lang-bash (which I'm pretty sure it's hinted at by ) works.

The screenshots were taken on Chromium 129.0.6668.89 stable / openSUSE Leap 15.6, however I think the issue may be browser-agnostic (server-sided even, due to the nature of the issue); however, for reference, I get the exact same on Firefox and Chrome on Ubuntu 24.04.

This is the link to the post in the example however this also shouldn't really matter as I'm getting this everywhere, on questions, answers and across sites.

While editing:

s1

After the edit has been sent through:

s2

But lang-bash works:

s3

kos
  • 2.2k
  • 13
  • 21