fix: keep a block's own language where no chrome is drawn - #66
Merged
Merged
Conversation
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.
"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.
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 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
defaultback in place of the language they wrote.Three render-level cases reached that state, and the gate now covers all three:
auto-filenameis off, which the documentation site itself sets.``` defaultfor a```foofence.draws_chromeanswers the question once, built onacts_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-filenameorcode-window-enabledon 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_chrometo answer false turns it red, along with the cell-output test.Sixteen tests pass.
example.qmdrenders byte-identical tomainin HTML, Typst and Reveal.js, so nothing changes on the default path.The documentation site loses two spurious
defaultclasses on its examples page, which is theauto-filenamecase working.The two that remain are the
cw-style-defaultstyle name and a block written as{.default filename="console"}by hand.