Skip to content

Fix highlightjs_al for Highlight.js v11 - #8306

Open
Torben Leth (SShadowS) wants to merge 1 commit into
microsoft:masterfrom
SShadowS:fix-highlightjs-al-v11
Open

Fix highlightjs_al for Highlight.js v11#8306
Torben Leth (SShadowS) wants to merge 1 commit into
microsoft:masterfrom
SShadowS:fix-highlightjs-al-v11

Conversation

@SShadowS

@SShadowS Torben Leth (SShadowS) commented Aug 8, 2026

Copy link
Copy Markdown

Two fixes to highlightjs_al for Highlight.js v11, plus the regenerated dist.

meta-keyword is a v10 scope

The preprocessor mode uses the meta-keyword keyword group. Highlight.js replaced that with a nested .meta .keyword scope in v11 (#3167, noted in VERSION_11_UPGRADE.md). The class is still emitted, but the default theme and the mainstream ones (github, atom-one, and so on) no longer style it, so #pragma, #region and the rest render unstyled for most users. A few older themes such as agate and the base16 family do still carry the selector.

Verified against a Highlight.js 11.11.2 build with this package linked into extra/:

before: <span class="hljs-meta">#<span class="hljs-meta-keyword">pragma</span> implicitwith disable</span>
after:  <span class="hljs-meta">#<span class="hljs-keyword">pragma</span> implicitwith disable</span>

The new form matches how core grammars write it, for example src/languages/c.js.

Auto-detection

Disabled, for a measured reason. Running Highlight.js's 192 core detect fixtures with this grammar registered, AL takes exactly one fixture that is not its own: cal, the C/AL fixture, at relevance 51.

That is not surprising, since C/AL is AL's predecessor and the two are near identical to a heuristic. It does mean that anyone linking this package breaks Highlight.js's own detect suite, which is the situation extra/3RD_PARTY_QUICK_START.md names as the reason to set disableAutodetect.

Worth being precise about what this costs: highlightAuto callers lose AL detection. Explicit registration and ```al fences are unaffected, since aliases is unchanged. AL was not confused with Pascal or Delphi in that run; both of those fixtures still detect correctly.

dist

dist/al.min.js is committed here and, while the package is unpublished, is the only artifact a consumer can actually load. It still contained the old meta-keyword output, so it is regenerated with the Highlight.js CDN build.

Background

I started writing a competing AL grammar for Highlight.js, found this one was better, and contributed these fixes instead.

Separately, #8307 asks about publishing this package to npm, since Highlight.js discovers third party grammars through its SUPPORTED_LANGUAGES.md list and AL is absent from it today.

AI disclosure

This change was prepared with AI assistance (Claude). The before and after output and the detect fixture run above were produced locally against Highlight.js 11.11.2.

Two corrections to the AL grammar, and a rebuilt dist.

The preprocessor mode uses the `meta-keyword` keyword group, which
Highlight.js replaced with a nested `.meta .keyword` scope in v11
(highlightjs/highlight.js#3167, VERSION_11_UPGRADE.md). The default and
mainstream themes no longer style the old class, so the directive
keywords render unstyled:

  before: <span class="hljs-meta">#<span class="hljs-meta-keyword">pragma</span> ...
  after:  <span class="hljs-meta">#<span class="hljs-keyword">pragma</span> ...

Auto-detection is also disabled. Running Highlight.js's 192 core detect
fixtures with this grammar registered, AL takes exactly one that is not
its own: cal, the C/AL fixture. That is expected, since C/AL is AL's
predecessor and the two are near identical to a heuristic, and it is the
situation the third party guide names as the reason to set
disableAutodetect. Explicit registration and language-al are unaffected;
highlightAuto callers lose AL detection.

dist/al.min.js is regenerated, since it is committed here and is the only
artifact consumers can load while the package is unpublished.

Verified against a Highlight.js 11.11.2 build with this package linked
into extra/.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant