diff --git a/CHANGELOG.md b/CHANGELOG.md index 3303d50..f3d3860 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Bug Fixes +- fix: Stand the Skylighting hot-fix down when the filter is off, so a Typst document that sets `enabled: false` compiles. It failed on an undeclared name before. (#71) - fix: Keep a block's own language where the filter derives no name for it, which means the filter is off, or `auto-filename` is off, or the output format is neither HTML nor Typst. The block was relabelled as `default` before, and the language the author wrote was lost. (#66) - fix: Keep inline code in a Typst document as a code element, so Pandoc writes the syntax highlighting definitions for it. A document with inline code and no code block failed to compile before. (#65) - fix: Remove the code-window attributes from a block that sets code-window-enabled="false", and from a block that sets code-window-lines when lines-label is off. They reached the HTML output as data-code-window-* attributes before. (#63) diff --git a/_extensions/code-window/main.lua b/_extensions/code-window/main.lua index 3f691a4..59727d4 100644 --- a/_extensions/code-window/main.lua +++ b/_extensions/code-window/main.lua @@ -126,12 +126,19 @@ local filters = { local skylighting_mod = load_skylighting_hotfix_module() +-- The hot-fix exists only to serve the chrome, so it asks draws_chrome like +-- every other pass that does. Its Skylighting override calls the colour helpers, +-- and code_window.Pandoc is what declares them, so asking hotfix_skylighting +-- alone left the override in a document that declared none. for _, subfilter in ipairs(skylighting_mod.filters or {}) do local wrapped = {} for element_type, handler in pairs(subfilter) do wrapped[element_type] = function(...) + if not code_window.draws_chrome() then + return nil + end local cfg = code_window.CONFIG() - if not cfg or not cfg.hotfix_skylighting then + if not cfg.hotfix_skylighting then return nil end if skylighting_mod.set_wrapper then diff --git a/docs/examples.qmd b/docs/examples.qmd index ebb5c37..0abce96 100644 --- a/docs/examples.qmd +++ b/docs/examples.qmd @@ -256,12 +256,12 @@ The extension compares that string with the running Quarto. At or above the named version the hot-fix stays out, whatever `enabled` says. An upgrade thus retires the hot-fix with no further edit. -Two pairs are linked. +`code-annotations` and `skylighting` are linked. `code-annotations` and `skylighting` work together: the first resolves the annotations, and the second supplies the rule that draws the circled marker beside an annotated line. Turn `skylighting` off, and the numbered list stays under the block while every marker inside it goes, along with the block styling and the inline code backgrounds the same module supplies. -`typst-title` follows `enabled`: with the filter off, theorem titles stay as Quarto writes them. +Every hot-fix follows `enabled`: with the filter off, none of them acts, and the Typst document comes out as Quarto writes it. See [Hot-fixes](reference.qmd#hot-fixes) for what each one corrects. diff --git a/docs/reference.qmd b/docs/reference.qmd index 27720df..a726b2c 100644 --- a/docs/reference.qmd +++ b/docs/reference.qmd @@ -90,6 +90,7 @@ In Typst the chrome is a call to the `wrapper` function, emitted into the docume Typst output needs a few corrections that Quarto does not yet make itself. Each is on by default and each can be given a version at which it switches itself off, so an upgrade retires it without a code change. +All of them follow `enabled`, so a document that turns the filter off takes no hot-fix at all. | Hot-fix | What it corrects | | --- | --- | diff --git a/tests/fixtures/filter-disabled-no-language.qmd b/tests/fixtures/filter-disabled-no-language.qmd index 4f9e3e6..e72479b 100644 --- a/tests/fixtures/filter-disabled-no-language.qmd +++ b/tests/fixtures/filter-disabled-no-language.qmd @@ -5,9 +5,15 @@ filters: extensions: code-window: enabled: false +format: + typst: + keep-typ: true --- A block with no language gains none while the filter is off. The block below is indented rather than fenced, which gives the same code block with no language. +The inline code in `x = 1` keeps the shape Quarto gives it too, because the +hot-fix that boxes it stands down with the filter. + x = 1 diff --git a/tests/fixtures/filter-disabled.qmd b/tests/fixtures/filter-disabled.qmd index cc8693e..8728c9a 100644 --- a/tests/fixtures/filter-disabled.qmd +++ b/tests/fixtures/filter-disabled.qmd @@ -5,12 +5,18 @@ filters: extensions: code-window: enabled: false +format: + typst: + keep-typ: true --- A filter that is off leaves every block as Quarto writes it. The block below keeps the language its author gave it, even though Pandoc cannot highlight it and the filter would relabel it when it is on. +The inline code in `x = 1` keeps the shape Quarto gives it too, because the +hot-fix that boxes it stands down with the filter. + ```foo x = 1 ``` diff --git a/tests/run.sh b/tests/run.sh index 7b060b5..8ae852c 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -235,6 +235,44 @@ else "a default class, a cw-auto class, and data-filename=\"foo\" on the block" fi +# ============================================================================ +# The Typst hot-fix stands down with the filter +# ============================================================================ + +# The hot-fix contributes two passes, and both write Typst that only the +# filter's own preamble declares. That preamble is not written with the filter +# off, so both passes have to stand down there. The block pass is caught by the +# "_cw-" prefix the colour helpers and the annotation state share. The inline +# pass takes a different shape where the theme gives a background colour, and +# names no helper at all, so the box itself is the thing to look for. +for fixture in filter-disabled filter-disabled-no-language; do + render "${fixture}" typst + + # Both assertions below are negative, and a missing file would answer them + # the same way a clean render does. So the file is checked for first. + if [ -f "${work_dir}/${fixture}.typ" ]; then + report pass "${fixture}: the render keeps its Typst source" + else + report fail "${fixture}: the render keeps its Typst source" \ + "a ${fixture}.typ in the work directory" + continue + fi + + if grep -q '_cw-' "${work_dir}/${fixture}.typ"; then + report fail "${fixture}: the block pass stands down with the filter" \ + "no _cw- helper call in ${fixture}.typ" + else + report pass "${fixture}: the block pass stands down with the filter" + fi + + if grep -q 'box(fill: rgb(' "${work_dir}/${fixture}.typ"; then + report fail "${fixture}: the inline pass stands down with the filter" \ + "no box(fill: rgb( call in ${fixture}.typ" + else + report pass "${fixture}: the inline pass stands down with the filter" + fi +done + # ============================================================================ # The schema is where an option's default is written down # ============================================================================