From f791fcaff351547e7f7e252a6632fb47eab9b897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Sun, 22 Nov 2026 22:35:12 +0100 Subject: [PATCH 1/6] feat: add fill and stroke keys to the Typst theme A template could not set the code background, which came from the Skylighting fill, nor draw the window border on some sides only. The fill key sets the code background, and the stroke key replaces the window border with any Typst stroke. --- CHANGELOG.md | 2 + .../_modules/hotfix/skylighting-typst-fix.lua | 3 +- _extensions/code-window/code-window.lua | 6 ++- docs/reference.qmd | 2 + tests/fixtures/typst-theme-fill-stroke.qmd | 29 ++++++++++++++ tests/run.sh | 40 +++++++++++++++++++ 6 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 tests/fixtures/typst-theme-fill-stroke.qmd diff --git a/CHANGELOG.md b/CHANGELOG.md index 25fe6af..f244933 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- feat: Add the `fill` and `stroke` keys to the Typst theme, so a template can set the code background and draw the window border on some sides only. + ## 1.9.1 (2026-11-20) - fix: A code block without a filename now gets its title bar when the page renders, so the content below it no longer moves down as the page loads. (#95) diff --git a/_extensions/code-window/_modules/hotfix/skylighting-typst-fix.lua b/_extensions/code-window/_modules/hotfix/skylighting-typst-fix.lua index c1050e8..fbeb748 100644 --- a/_extensions/code-window/_modules/hotfix/skylighting-typst-fix.lua +++ b/_extensions/code-window/_modules/hotfix/skylighting-typst-fix.lua @@ -39,10 +39,11 @@ local function build_skylighting_override() start: 1, sourcelines, ) = { - let bgcolor = if fill != none { fill } else { rgb("%s") } let has-gutter = start + sourcelines.len() > 999 context { + let theme-fill = _cw-theme.get().at("fill", default: none) + let bgcolor = if theme-fill != none { theme-fill } else if fill != none { fill } else { rgb("%s") } let _page-bg = _cw-page-bg() let _fg = _cw-fg(_page-bg) let _border-colour = color.mix((_fg, 15%%), (_page-bg, 85%%)) diff --git a/_extensions/code-window/code-window.lua b/_extensions/code-window/code-window.lua index c90e721..1e017a7 100644 --- a/_extensions/code-window/code-window.lua +++ b/_extensions/code-window/code-window.lua @@ -343,8 +343,10 @@ local TYPST_COLOUR_HELPERS = [==[ // the colour keys (border, surface, label, muted) derive from the page fill #let _cw-theme-defaults = ( radius: 8pt, + stroke: auto, stroke-thickness: 1pt, stroke-dash: none, + fill: none, title-inset: (x: 1em, y: 0.6em), body-inset: 8pt, traffic-light-size: 0.85em, @@ -571,7 +573,7 @@ local function build_typst_function_def(has_hotfixes, has_own_wrapper) block( width: 100%%, - stroke: window-stroke, + stroke: if theme.stroke == auto { window-stroke } else { theme.stroke }, radius: theme.radius, clip: true, { @@ -598,7 +600,7 @@ local function build_typst_function_def(has_hotfixes, has_own_wrapper) below: 0pt, ) show raw.where(block: true): set block( - fill: none, + fill: theme.fill, width: 100%%, radius: 0pt, stroke: none, diff --git a/docs/reference.qmd b/docs/reference.qmd index 59d50ca..4d0ca91 100644 --- a/docs/reference.qmd +++ b/docs/reference.qmd @@ -159,9 +159,11 @@ The default colours come from the page fill, so the window matches light and dar |---|---|---| | `border` | 15% of the text colour mixed into the page fill | The colour of the window border and of the line below the title bar. | | `surface` | 5% of the text colour mixed into the page fill | The title bar background. | +| `fill` | `none` | The background of each highlighted code block, in a window and out of it. With `none`, the block keeps the background of the highlight style. With Skylighting highlighting, this needs the `skylighting` hot-fix. With native Typst highlighting, it applies only in a window. | | `label` | 65% of the text colour mixed into the page fill | The colour of the filename. | | `muted` | 50% of the text colour mixed into the page fill | The colour of the `windows` style buttons. | | `radius` | `8pt` | The radius of the window corners. | +| `stroke` | `auto` | The window border. With `auto`, the border is made from `border`, `stroke-thickness`, and `stroke-dash`. Any other value is a Typst stroke that replaces the border, for example `(top: 2pt + olive, rest: none)` for a top rule only. The line below the title bar does not change. | | `stroke-thickness` | `1pt` | The thickness of the border. | | `stroke-dash` | `none` | The dash pattern of the border, for example `"dashed"`. | | `title-inset` | `(x: 1em, y: 0.6em)` | The inset of the title bar. | diff --git a/tests/fixtures/typst-theme-fill-stroke.qmd b/tests/fixtures/typst-theme-fill-stroke.qmd new file mode 100644 index 0000000..bb12bf6 --- /dev/null +++ b/tests/fixtures/typst-theme-fill-stroke.qmd @@ -0,0 +1,29 @@ +--- +title: "A Typst theme with a code fill and a top rule" +filters: + - code-window +format: + typst: + keep-typ: true +--- + +```{=typst} +#state("code-window-theme").update(( + border: rgb("#ff0000"), + fill: rgb("#00ff00"), + stroke: (top: 3pt + rgb("#0000ff"), rest: none), +)) +``` + +The window below draws a blue top rule and no other side, and its code takes +the green fill. The line below the title bar keeps the red border colour. + +```{.python filename="a.py"} +x = 1 +``` + +The block below has no window, and also takes the green fill. + +```{.python code-window-enabled="false"} +y = 2 +``` diff --git a/tests/run.sh b/tests/run.sh index 5c0a747..ee54e9f 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -62,6 +62,12 @@ count_typst_windows() { grep -c '^#code-window(filename' "$1" || true } +# Count the matches of a fixed string in a file, and answer 0 when none match. +# $1 file. $2 fixed string. +count_in() { + grep -o -F "$2" "$1" | wc -l | tr -d ' ' || true +} + # Succeed when one page of page-break-title.txt holds both strings. pdftotext # ends each page with a form feed, so awk reads one page per record. # $1 first string. $2 second string. @@ -398,6 +404,40 @@ else "the key boarder named in typst-theme-unknown-key.log" fi +# The theme's fill replaces the background of every highlighted block, in the +# window and out of it, and its stroke replaces the frame of the window. The +# stroke draws only a blue top rule, so the red border colour stays only on +# the line below the title bar. +render typst-theme-fill-stroke typst +if ! quarto typst compile "${work_dir}/typst-theme-fill-stroke.typ" \ + "${work_dir}/typst-theme-fill-stroke.svg" \ + >"${work_dir}/typst-theme-fill-stroke-svg.log" 2>&1; then + printf 'FAIL typst-theme-fill-stroke: the SVG compile failed\n' + tail -n 20 "${work_dir}/typst-theme-fill-stroke-svg.log" + exit 1 +fi +fill_stroke_svg="${work_dir}/typst-theme-fill-stroke.svg" +green_fills="$(count_in "${fill_stroke_svg}" 'fill="#00ff00"')" +if [ "${green_fills}" -eq 2 ]; then + report pass "typst-theme-fill-stroke: both code blocks take the theme's fill" +else + report fail "typst-theme-fill-stroke: both code blocks take the theme's fill" \ + "two fill=\"#00ff00\" in typst-theme-fill-stroke.svg, got ${green_fills}" +fi + +# Typst draws a stroke that covers only some sides as filled shapes, so the top +# rule and the line below the title bar are fills. A full red frame would be a +# red stroke. +blue_sides="$(count_in "${fill_stroke_svg}" 'fill="#0000ff"')" +red_sides="$(count_in "${fill_stroke_svg}" 'fill="#ff0000"')" +red_frames="$(count_in "${fill_stroke_svg}" 'stroke="#ff0000"')" +if [ "${blue_sides}" -eq 1 ] && [ "${red_sides}" -eq 1 ] && [ "${red_frames}" -eq 0 ]; then + report pass "typst-theme-fill-stroke: the window draws only the sides the theme sets" +else + report fail "typst-theme-fill-stroke: the window draws only the sides the theme sets" \ + "one blue side, one red side, and no red frame, got ${blue_sides}, ${red_sides}, and ${red_frames}" +fi + # ============================================================================ # A wrapper that the document defines replaces the stock one # ============================================================================ From fb2829dda62c114a470fff3780d3f89710f0004d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Sun, 22 Nov 2026 22:38:41 +0100 Subject: [PATCH 2/6] refactor: reuse the themed Typst source in the fill test The test edits the rendered typst-theme source rather than rendering a second fixture, and a compile_svg helper replaces the copied compile block. The Skylighting override and the window resolve the new keys once. --- .../_modules/hotfix/skylighting-typst-fix.lua | 2 +- _extensions/code-window/code-window.lua | 3 +- tests/fixtures/typst-theme-fill-stroke.qmd | 29 --------------- tests/run.sh | 35 ++++++++++--------- 4 files changed, 22 insertions(+), 47 deletions(-) delete mode 100644 tests/fixtures/typst-theme-fill-stroke.qmd diff --git a/_extensions/code-window/_modules/hotfix/skylighting-typst-fix.lua b/_extensions/code-window/_modules/hotfix/skylighting-typst-fix.lua index fbeb748..4876fc2 100644 --- a/_extensions/code-window/_modules/hotfix/skylighting-typst-fix.lua +++ b/_extensions/code-window/_modules/hotfix/skylighting-typst-fix.lua @@ -42,7 +42,7 @@ local function build_skylighting_override() let has-gutter = start + sourcelines.len() > 999 context { - let theme-fill = _cw-theme.get().at("fill", default: none) + let theme-fill = (_cw-theme-defaults + _cw-theme.get()).fill let bgcolor = if theme-fill != none { theme-fill } else if fill != none { fill } else { rgb("%s") } let _page-bg = _cw-page-bg() let _fg = _cw-fg(_page-bg) diff --git a/_extensions/code-window/code-window.lua b/_extensions/code-window/code-window.lua index 1e017a7..11e3da3 100644 --- a/_extensions/code-window/code-window.lua +++ b/_extensions/code-window/code-window.lua @@ -492,6 +492,7 @@ local function build_typst_function_def(has_hotfixes, has_own_wrapper) thickness: theme.stroke-thickness, dash: theme.stroke-dash, ) + let frame-stroke = if theme.stroke == auto { window-stroke } else { theme.stroke } let filename-label = if filename != none { text( @@ -573,7 +574,7 @@ local function build_typst_function_def(has_hotfixes, has_own_wrapper) block( width: 100%%, - stroke: if theme.stroke == auto { window-stroke } else { theme.stroke }, + stroke: frame-stroke, radius: theme.radius, clip: true, { diff --git a/tests/fixtures/typst-theme-fill-stroke.qmd b/tests/fixtures/typst-theme-fill-stroke.qmd deleted file mode 100644 index bb12bf6..0000000 --- a/tests/fixtures/typst-theme-fill-stroke.qmd +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: "A Typst theme with a code fill and a top rule" -filters: - - code-window -format: - typst: - keep-typ: true ---- - -```{=typst} -#state("code-window-theme").update(( - border: rgb("#ff0000"), - fill: rgb("#00ff00"), - stroke: (top: 3pt + rgb("#0000ff"), rest: none), -)) -``` - -The window below draws a blue top rule and no other side, and its code takes -the green fill. The line below the title bar keeps the red border colour. - -```{.python filename="a.py"} -x = 1 -``` - -The block below has no window, and also takes the green fill. - -```{.python code-window-enabled="false"} -y = 2 -``` diff --git a/tests/run.sh b/tests/run.sh index ee54e9f..129a9db 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -62,6 +62,18 @@ count_typst_windows() { grep -c '^#code-window(filename' "$1" || true } +# Compile a rendered Typst file to SVG, and stop the run when the compile +# fails. +# $1 base name of the .typ file in the work directory. +compile_svg() { + if ! quarto typst compile "${work_dir}/$1.typ" "${work_dir}/$1.svg" \ + >"${work_dir}/$1-svg.log" 2>&1; then + printf 'FAIL %s: the SVG compile failed\n' "$1" + tail -n 20 "${work_dir}/$1-svg.log" + exit 1 + fi +} + # Count the matches of a fixed string in a file, and answer 0 when none match. # $1 file. $2 fixed string. count_in() { @@ -356,12 +368,7 @@ fi # draws a solid border mixed from the page colour, so a red dashed border can # only come from the theme. render typst-theme typst -if ! quarto typst compile "${work_dir}/typst-theme.typ" "${work_dir}/typst-theme.svg" \ - >"${work_dir}/typst-theme-svg.log" 2>&1; then - printf 'FAIL typst-theme: the SVG compile failed\n' - tail -n 20 "${work_dir}/typst-theme-svg.log" - exit 1 -fi +compile_svg typst-theme if grep -q 'stroke="#ff0000"' "${work_dir}/typst-theme.svg" && grep -q 'stroke-dasharray' "${work_dir}/typst-theme.svg"; then report pass "typst-theme: the window draws the border the theme sets" @@ -406,16 +413,12 @@ fi # The theme's fill replaces the background of every highlighted block, in the # window and out of it, and its stroke replaces the frame of the window. The -# stroke draws only a blue top rule, so the red border colour stays only on -# the line below the title bar. -render typst-theme-fill-stroke typst -if ! quarto typst compile "${work_dir}/typst-theme-fill-stroke.typ" \ - "${work_dir}/typst-theme-fill-stroke.svg" \ - >"${work_dir}/typst-theme-fill-stroke-svg.log" 2>&1; then - printf 'FAIL typst-theme-fill-stroke: the SVG compile failed\n' - tail -n 20 "${work_dir}/typst-theme-fill-stroke-svg.log" - exit 1 -fi +# themed source above is reused with the dashed border swapped for a fill and +# a stroke that draws only a blue top rule, so the red border colour stays only +# on the line below the title bar. +sed 's/stroke-dash: "dashed",/fill: rgb("#00ff00"), stroke: (top: 3pt + rgb("#0000ff"), rest: none),/' \ + "${work_dir}/typst-theme.typ" >"${work_dir}/typst-theme-fill-stroke.typ" +compile_svg typst-theme-fill-stroke fill_stroke_svg="${work_dir}/typst-theme-fill-stroke.svg" green_fills="$(count_in "${fill_stroke_svg}" 'fill="#00ff00"')" if [ "${green_fills}" -eq 2 ]; then From f489161ca955d52640993c282eebbebecf880497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Sun, 22 Nov 2026 22:41:42 +0100 Subject: [PATCH 3/6] feat: default the Typst fill key to auto With none as the default, a template could not ask for a code block with no background. auto now keeps the highlight style's background, and none removes it. --- .../_modules/hotfix/skylighting-typst-fix.lua | 2 +- _extensions/code-window/code-window.lua | 4 ++-- docs/reference.qmd | 2 +- tests/run.sh | 14 ++++++++++++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/_extensions/code-window/_modules/hotfix/skylighting-typst-fix.lua b/_extensions/code-window/_modules/hotfix/skylighting-typst-fix.lua index 4876fc2..1ea4fd3 100644 --- a/_extensions/code-window/_modules/hotfix/skylighting-typst-fix.lua +++ b/_extensions/code-window/_modules/hotfix/skylighting-typst-fix.lua @@ -43,7 +43,7 @@ local function build_skylighting_override() context { let theme-fill = (_cw-theme-defaults + _cw-theme.get()).fill - let bgcolor = if theme-fill != none { theme-fill } else if fill != none { fill } else { rgb("%s") } + let bgcolor = if theme-fill != auto { theme-fill } else if fill != none { fill } else { rgb("%s") } let _page-bg = _cw-page-bg() let _fg = _cw-fg(_page-bg) let _border-colour = color.mix((_fg, 15%%), (_page-bg, 85%%)) diff --git a/_extensions/code-window/code-window.lua b/_extensions/code-window/code-window.lua index 11e3da3..466d249 100644 --- a/_extensions/code-window/code-window.lua +++ b/_extensions/code-window/code-window.lua @@ -346,7 +346,7 @@ local TYPST_COLOUR_HELPERS = [==[ stroke: auto, stroke-thickness: 1pt, stroke-dash: none, - fill: none, + fill: auto, title-inset: (x: 1em, y: 0.6em), body-inset: 8pt, traffic-light-size: 0.85em, @@ -601,7 +601,7 @@ local function build_typst_function_def(has_hotfixes, has_own_wrapper) below: 0pt, ) show raw.where(block: true): set block( - fill: theme.fill, + fill: if theme.fill == auto { none } else { theme.fill }, width: 100%%, radius: 0pt, stroke: none, diff --git a/docs/reference.qmd b/docs/reference.qmd index 4d0ca91..f7646e7 100644 --- a/docs/reference.qmd +++ b/docs/reference.qmd @@ -159,7 +159,7 @@ The default colours come from the page fill, so the window matches light and dar |---|---|---| | `border` | 15% of the text colour mixed into the page fill | The colour of the window border and of the line below the title bar. | | `surface` | 5% of the text colour mixed into the page fill | The title bar background. | -| `fill` | `none` | The background of each highlighted code block, in a window and out of it. With `none`, the block keeps the background of the highlight style. With Skylighting highlighting, this needs the `skylighting` hot-fix. With native Typst highlighting, it applies only in a window. | +| `fill` | `auto` | The background of each highlighted code block, in a window and out of it. With `auto`, the block keeps the background of the highlight style. With `none`, the block has no background. With Skylighting highlighting, this needs the `skylighting` hot-fix. With native Typst highlighting, it applies only in a window. | | `label` | 65% of the text colour mixed into the page fill | The colour of the filename. | | `muted` | 50% of the text colour mixed into the page fill | The colour of the `windows` style buttons. | | `radius` | `8pt` | The radius of the window corners. | diff --git a/tests/run.sh b/tests/run.sh index 129a9db..837d8e0 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -441,6 +441,20 @@ else "one blue side, one red side, and no red frame, got ${blue_sides}, ${red_sides}, and ${red_frames}" fi +# With fill left at auto, both code blocks keep the highlight style's +# background. With fill set to none, neither block has one. +sed 's/stroke-dash: "dashed",/fill: none,/' \ + "${work_dir}/typst-theme.typ" >"${work_dir}/typst-theme-fill-none.typ" +compile_svg typst-theme-fill-none +style_fills_auto="$(count_in "${work_dir}/typst-theme.svg" 'fill="#f1f3f5"')" +style_fills_none="$(count_in "${work_dir}/typst-theme-fill-none.svg" 'fill="#f1f3f5"')" +if [ "${style_fills_auto}" -eq 2 ] && [ "${style_fills_none}" -eq 0 ]; then + report pass "typst-theme-fill-none: fill none removes the background that auto keeps" +else + report fail "typst-theme-fill-none: fill none removes the background that auto keeps" \ + "two fill=\"#f1f3f5\" with auto and none with fill none, got ${style_fills_auto} and ${style_fills_none}" +fi + # ============================================================================ # A wrapper that the document defines replaces the stock one # ============================================================================ From d2ca39003dd98a2567b525144a2d5eaacc26fcba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Sun, 22 Nov 2026 22:44:50 +0100 Subject: [PATCH 4/6] test: cover the Typst fill with native highlighting --- tests/run.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/run.sh b/tests/run.sh index 837d8e0..d066528 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -455,6 +455,21 @@ else "two fill=\"#f1f3f5\" with auto and none with fill none, got ${style_fills_auto} and ${style_fills_none}" fi +# With native Typst highlighting there is no Skylighting override, so the +# theme's fill reaches only the code in the window, through its raw rule. +sed -e 's/stroke-dash: "dashed",/fill: rgb("#00ff00"),/' \ + -e 's/^ keep-typ: true$/ keep-typ: true\n syntax-highlighting: idiomatic/' \ + "${work_dir}/typst-theme.qmd" >"${work_dir}/typst-theme-fill-native.qmd" +render typst-theme-fill-native typst +compile_svg typst-theme-fill-native +native_fills="$(count_in "${work_dir}/typst-theme-fill-native.svg" 'fill="#00ff00"')" +if [ "${native_fills}" -eq 1 ]; then + report pass "typst-theme-fill-native: only the code in the window takes the theme's fill" +else + report fail "typst-theme-fill-native: only the code in the window takes the theme's fill" \ + "one fill=\"#00ff00\" in typst-theme-fill-native.svg, got ${native_fills}" +fi + # ============================================================================ # A wrapper that the document defines replaces the stock one # ============================================================================ From 04ab2972f091f7800b10c168e4c118def8cb27fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Sun, 22 Nov 2026 22:49:36 +0100 Subject: [PATCH 5/6] docs: say what the Typst fill auto gives per highlighting --- docs/reference.qmd | 2 +- tests/run.sh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/reference.qmd b/docs/reference.qmd index f7646e7..98715fd 100644 --- a/docs/reference.qmd +++ b/docs/reference.qmd @@ -159,7 +159,7 @@ The default colours come from the page fill, so the window matches light and dar |---|---|---| | `border` | 15% of the text colour mixed into the page fill | The colour of the window border and of the line below the title bar. | | `surface` | 5% of the text colour mixed into the page fill | The title bar background. | -| `fill` | `auto` | The background of each highlighted code block, in a window and out of it. With `auto`, the block keeps the background of the highlight style. With `none`, the block has no background. With Skylighting highlighting, this needs the `skylighting` hot-fix. With native Typst highlighting, it applies only in a window. | +| `fill` | `auto` | The background of each highlighted code block, in a window and out of it. With `none`, the block has no background. With Skylighting highlighting, this needs the `skylighting` hot-fix, and `auto` keeps the background of the highlight style. With native Typst highlighting, the key applies only in a window, and `auto` gives no background there. | | `label` | 65% of the text colour mixed into the page fill | The colour of the filename. | | `muted` | 50% of the text colour mixed into the page fill | The colour of the `windows` style buttons. | | `radius` | `8pt` | The radius of the window corners. | diff --git a/tests/run.sh b/tests/run.sh index d066528..296a72c 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -458,7 +458,8 @@ fi # With native Typst highlighting there is no Skylighting override, so the # theme's fill reaches only the code in the window, through its raw rule. sed -e 's/stroke-dash: "dashed",/fill: rgb("#00ff00"),/' \ - -e 's/^ keep-typ: true$/ keep-typ: true\n syntax-highlighting: idiomatic/' \ + -e 's/^ keep-typ: true$/ keep-typ: true\ + syntax-highlighting: idiomatic/' \ "${work_dir}/typst-theme.qmd" >"${work_dir}/typst-theme-fill-native.qmd" render typst-theme-fill-native typst compile_svg typst-theme-fill-native From 13671bd96e7c21a586d142f9ccc78b22af49bfac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Sun, 22 Nov 2026 22:55:46 +0100 Subject: [PATCH 6/6] test: read the highlight background in the fill test The changelog entry now names the pull request. --- CHANGELOG.md | 2 +- tests/run.sh | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f244933..7d28ea9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- feat: Add the `fill` and `stroke` keys to the Typst theme, so a template can set the code background and draw the window border on some sides only. +- feat: Add the `fill` and `stroke` keys to the Typst theme, so a template can set the code background and draw the window border on some sides only. (#97) ## 1.9.1 (2026-11-20) diff --git a/tests/run.sh b/tests/run.sh index 296a72c..9025dc7 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -442,17 +442,19 @@ else fi # With fill left at auto, both code blocks keep the highlight style's -# background. With fill set to none, neither block has one. +# background. With fill set to none, neither block has one. The background is +# read from the override's fallback, so the test follows the highlight style. sed 's/stroke-dash: "dashed",/fill: none,/' \ "${work_dir}/typst-theme.typ" >"${work_dir}/typst-theme-fill-none.typ" compile_svg typst-theme-fill-none -style_fills_auto="$(count_in "${work_dir}/typst-theme.svg" 'fill="#f1f3f5"')" -style_fills_none="$(count_in "${work_dir}/typst-theme-fill-none.svg" 'fill="#f1f3f5"')" +style_bg="$(sed -n 's/.*else { rgb("\(#[0-9a-f]*\)") }.*/\1/p' "${work_dir}/typst-theme.typ")" +style_fills_auto="$(count_in "${work_dir}/typst-theme.svg" "fill=\"${style_bg}\"")" +style_fills_none="$(count_in "${work_dir}/typst-theme-fill-none.svg" "fill=\"${style_bg}\"")" if [ "${style_fills_auto}" -eq 2 ] && [ "${style_fills_none}" -eq 0 ]; then report pass "typst-theme-fill-none: fill none removes the background that auto keeps" else report fail "typst-theme-fill-none: fill none removes the background that auto keeps" \ - "two fill=\"#f1f3f5\" with auto and none with fill none, got ${style_fills_auto} and ${style_fills_none}" + "two fill=\"${style_bg}\" with auto and none with fill none, got ${style_fills_auto} and ${style_fills_none}" fi # With native Typst highlighting there is no Skylighting override, so the