Skip to content

fix: keep the code-window attributes out of the document - #63

Merged
mcanouil merged 8 commits into
test/render-fixturesfrom
fix/code-window-attribute-strip
Sep 20, 2026
Merged

mcanouil merged 8 commits into
test/render-fixturesfrom
fix/code-window-attribute-strip

Conversation

@mcanouil

@mcanouil mcanouil commented Sep 20, 2026 •

Copy link
Copy Markdown
Owner

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.

  • A block that sets code-window-enabled="false" returned before the readers that remove those attributes, so four of them reached the output.
  • lines-label: false short-circuited the same readers, so code-window-lines reached 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_attributes now removes every attribute carrying the extension's prefix, once per format path, above every early return.
The readers only read, and read_block_lines_label answers the lines-label option 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-label is returned rather than dropped, and the cell-output marker is left for the pass that reads it.

resolve_and_take copies 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.qmd is byte-identical to main in HTML, Typst and Reveal.js, so nothing changes on the default path.
The documentation site renders with no warnings.

@mcanouil
mcanouil added this pull request to stack #64 September 20, 2026 17:56
@mcanouil mcanouil added the Type: Bug 🐛 Issues related to bugs, errors, or mistakes label Sep 20, 2026
@mcanouil mcanouil self-assigned this Sep 20, 2026
@mcanouil mcanouil changed the title fix/code window attribute strip fix: keep the code-window attributes out of the document Sep 20, 2026
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
mcanouil force-pushed the fix/code-window-attribute-strip branch from c590056 to 1102a3a Compare September 20, 2026 18:04
@mcanouil
mcanouil marked this pull request as ready for review September 20, 2026 18:07
@mcanouil
mcanouil merged commit 87c7d2e into main Sep 20, 2026
6 checks passed
@mcanouil
mcanouil deleted the fix/code-window-attribute-strip branch September 20, 2026 18:09
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