Skip to content

fix: take the language from the first known class - #84

Merged
mcanouil merged 6 commits into
mainfrom
fix/language-class-order
Nov 5, 2026
Merged

mcanouil merged 6 commits into
mainfrom
fix/language-class-order

Conversation

@mcanouil

@mcanouil mcanouil commented Nov 5, 2026

Copy link
Copy Markdown
Owner

The language pass used to read only the first class of a block.
Pandoc highlights with the first class it knows as a language, so a block written {.terminal .bash} lost bash to default, was highlighted as plain text, and was labelled TERMINAL.

The pass now moves the first class Pandoc can highlight to the front, so the window name, the code annotations and Pandoc all read the same class.
The probe also stops taking numberLines, number-lines and number for languages: Pandoc writes sourceCode on any numbered block, so the probe now asks for a language name on the code tag.
A block with no language keeps its own classes and gets default in front, instead of having its first class replaced, so {.numberLines} keeps its line numbers.

Before After
Two code windows labelled TERMINAL and NUMBERLINES, the first one not highlighted The same two code windows, both labelled BASH and highlighted

The new language-not-first fixture covers the HTML and Typst output, and tests/run.sh passes with 43 tests.

Pandoc highlights a block with the first class it knows as a language, but
the language pass read only the first class. A block such as {.terminal .bash}
lost its language to default and was named after terminal. The probe also
took numberLines, number-lines and number for languages, because Pandoc
writes the sourceCode class on any numbered block.

The pass now moves the first class Pandoc can highlight to the front. A block
with none gets default in front of its own classes, so line numbers survive.
@mcanouil mcanouil added the Type: Bug 🐛 Issues related to bugs, errors, or mistakes label Nov 5, 2026
@mcanouil mcanouil self-assigned this Nov 5, 2026
@mcanouil
mcanouil marked this pull request as ready for review November 5, 2026 09:48
@mcanouil
mcanouil merged commit d120b9d into main Nov 5, 2026
4 checks passed
@mcanouil
mcanouil deleted the fix/language-class-order branch November 5, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug 🐛 Issues related to bugs, errors, or mistakes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant