Skip to content

fix: keep a block's own language where no chrome is drawn - #66

Merged
mcanouil merged 7 commits into
mainfrom
fix/language-pass-enabled-gate
Sep 21, 2026
Merged

mcanouil merged 7 commits into
mainfrom
fix/language-pass-enabled-gate

Conversation

@mcanouil

@mcanouil mcanouil commented Sep 20, 2026 •

Copy link
Copy Markdown
Owner

The pass that labels a block whose language Pandoc cannot highlight ran on every render.
The derived filename is the only reader of that label, so wherever no name is derived the pass rewrote the class for nobody, and the author got default back in place of the language they wrote.

Three render-level cases reached that state, and the gate now covers all three:

  • The filter is off.
  • auto-filename is off, which the documentation site itself sets.
  • The output format is neither HTML nor Typst, where a render to markdown printed ``` default for a ```foo fence.

draws_chrome answers the question once, built on acts_on_format, which holds the format union the file used to spell out in three places.
The cell-output pass asks the same question, so a render that draws no chrome no longer walks the whole document to set a mark nothing reads.

A block can still draw no chrome inside a render that does, through code-window-no-auto-filename or code-window-enabled on the block.
The class is rewritten with no reader there too.
That one is tracked separately, because the fix moves the relabelling into the two window paths, and those are being restructured in their own change.

Tests

Four fixtures cover the gate closing, one covers it staying open, and one covers the branch of the pass that inserts a class where a block had none.
The positive fixture has teeth: forcing draws_chrome to answer false turns it red, along with the cell-output test.

Sixteen tests pass. example.qmd renders byte-identical to main in HTML, Typst and Reveal.js, so nothing changes on the default path.
The documentation site loses two spurious default classes on its examples page, which is the auto-filename case working.
The two that remain are the cw-style-default style name and a block written as {.default filename="console"} by hand.

The pass that labels a block whose language Pandoc cannot highlight ran
whether the extension was on or off, so a disabled filter handed the
author back the "default" class in place of their own language. Nothing
read the label in that state, because only the derived filename does and
that never runs with the filter off.

The cell-output pass loses the case it only had to serve that one, and
the examples page no longer says a disabled filter relabels a block.
With the filter on and the output format neither HTML nor Typst, the
pass still rewrote the class, and again nothing read the result: the
derived filename is the only reader, and it runs for those two formats
alone. A render to markdown printed "``` default" where the source said
"```foo".

code-window.lua exposes the current format, as it already exposes the
configuration, so the guard can read it.
Three places asked some part of "is this render drawing chrome": the
options check compared the two formats inline, and the two passes that
serve the chrome each carried their own copy of the configuration test.

draws_chrome answers it once, built on acts_on_format, which holds the
format union the file used to spell out. The cell-output pass gains the
format half it was missing, so a render that draws no chrome no longer
walks the whole document to set a mark nothing reads.
The two new tests both asserted that the pass does not run, so a gate
that closed on a render it should let through would have left the suite
green. A fixture with the filter on now asserts the class becomes
"default", the block is framed, and the title bar keeps the language the
author wrote. Forcing the gate shut turns it red, along with the
cell-output test.

The fixture prose and the comment beside the older markdown test
described the label as written and then stripped, which is no longer
what happens.
@mcanouil mcanouil self-assigned this Sep 20, 2026
"auto-filename" is the reader itself: with no derived name to build, both
window paths return before they read the label, so the pass rewrote a
class for nobody there too. The documentation site sets that option off,
and its own blocks were relabelled.

Two fixtures cover the branch of the pass that inserts a class where a
block had none, and the option itself. Two comments are corrected: the
cell-output mark has a reader that only removes it, and the label the
disabled branches clear is now only ever one a document wrote by hand.
@mcanouil
mcanouil marked this pull request as ready for review September 21, 2026 08:10
@mcanouil mcanouil added the Type: Bug 🐛 Issues related to bugs, errors, or mistakes label Sep 21, 2026
@mcanouil
mcanouil merged commit 570d11d into main Sep 21, 2026
4 checks passed
@mcanouil
mcanouil deleted the fix/language-pass-enabled-gate branch September 21, 2026 09:05
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