fix: keep the code-window attributes out of the document - #63
Merged
Merged
Conversation
mcanouil
added this pull request to stack #64
September 20, 2026 17:56
A block that sets code-window-enabled="false" returned before the four readers that remove the extension's own attributes, so Pandoc wrote each one into the HTML as a data-code-window-* attribute. The readers now run first, and the per-block opt-out follows them. lines-label: false short-circuited the same way and left code-window-lines on the block. The spec is now always read and removed, and the option decides only whether the chip is drawn. A filter switched off for the whole document keeps changing nothing, so code-window-no-auto-filename stays on the block there, as it does with the extension not installed.
Each reader removed the attribute it had just read, so the rule that no code-window attribute survives the filter was spread over seven statements that all had to agree, and a new attribute would have needed its own copy of it. take_block_attributes now removes every attribute carrying the extension's prefix, once per format path, straight after the schema resolves them. The readers only read, and the "lines-label" option is answered inside read_block_lines_label rather than at both call sites.
An enabled render to a format the extension does not act on kept code-window-auto-label on the block. A writer that preserves attributes printed it, which a render to markdown showed.
The marker that says a block holds the output of an executed cell carries the same prefix as the attributes an author writes, so taking the namespace off the block removed it before the Typst pass asked. That pass then framed output it had always left alone, and let the annotation pass rewrite its text. The cell-output module now answers whether an attribute is its marker, and it keeps removing its own.
The schema check hands back the list it was given when it has no schema to read, which this extension carries on through by design. The caller then held the block's own attributes, so taking them off emptied the table every reader reads, and each per-block override was ignored with no warning. A render with the schema removed lost the windows style on a block that asked for it. The values are copied into a table of their own first, in one place both format paths call.
Three fixtures state what this branch changes: a block that turns the chrome off, a document with the chip turned off, and a render to a format the extension does not act on. Each one fails on the commit before the fix.
A single fence carrying every attribute was longer than any line limit, and the repository carries no lint configuration to allow it. Four blocks, each turning the chrome off and writing one attribute, keep each fence short and test each attribute on its own.
mcanouil
force-pushed
the
fix/code-window-attribute-strip
branch
from
September 20, 2026 18:04
c590056 to
1102a3a
Compare
mcanouil
marked this pull request as ready for review
September 20, 2026 18:07
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The filter wrote its own
code-window-*attributes into the HTML in two cases, both with the filter on.Pandoc turns an attribute the filter leaves behind into a
data-code-window-*attribute on the wrapper.code-window-enabled="false"returned before the readers that remove those attributes, so four of them reached the output.lines-label: falseshort-circuited the same readers, socode-window-linesreached the output as well.The rule this applies: the extension removes its own attributes on each path where it draws chrome.
Where it draws nothing, with the filter off for the document or for a format it does not act on, it changes nothing an author wrote and removes only the label the language module wrote itself.
take_block_attributesnow removes every attribute carrying the extension's prefix, once per format path, above every early return.The readers only read, and
read_block_lines_labelanswers thelines-labeloption rather than each call site repeating the test.Two prefixed attributes are not author-written and are handled on their own terms:
code-window-auto-labelis returned rather than dropped, and the cell-output marker is left for the pass that reads it.resolve_and_takecopies what the schema resolves into a table of its own before anything is removed.The schema check hands back the list it was given when it has no schema to read, so the caller would otherwise hold the block's live attributes, and each per-block override would be ignored with no warning.
Three fixtures are added to the render check, and each one fails on the commit before the fix.
A render of
example.qmdis byte-identical tomainin HTML, Typst and Reveal.js, so nothing changes on the default path.The documentation site renders with no warnings.