From dd4448fd7eae3ac58163e02b2272095b1cedf7c0 Mon Sep 17 00:00:00 2001 From: Carlos Scheidegger Date: Fri, 23 May 2025 08:49:36 -0400 Subject: [PATCH] lua,typst - do not crash if float.content is nil --- news/changelog-1.8.md | 1 + src/resources/filters/quarto-post/typst.lua | 3 +++ tests/docs/smoke-all/2025/05/23/issue-12815.qmd | 10 ++++++++++ 3 files changed, 14 insertions(+) create mode 100644 tests/docs/smoke-all/2025/05/23/issue-12815.qmd diff --git a/news/changelog-1.8.md b/news/changelog-1.8.md index 569dff95000..57e072503b7 100644 --- a/news/changelog-1.8.md +++ b/news/changelog-1.8.md @@ -33,6 +33,7 @@ All changes included in 1.8: - ([#12554](https://github.com/quarto-dev/quarto-cli/pull/12554)): CSS properties `font-weight` and `font-style` are translated to Typst `text` properties. - ([#12695](https://github.com/quarto-dev/quarto-cli/issues/12695)): Resolve Typst `font-paths` that start with `/` relative to project root. - ([#12739](https://github.com/quarto-dev/quarto-cli/pull/12739)): Remove unused variable `heading-background-color` and `heading-decoration` from Typst's templates. They are leftover from previous change, and not part of Brand.yml schema for typography of headings. +- ([#12815](https://github.com/quarto-dev/quarto-cli/issues/12815)): Do not crash when floats have no content. ### `beamer` diff --git a/src/resources/filters/quarto-post/typst.lua b/src/resources/filters/quarto-post/typst.lua index 8ebd9c87596..8550ff5bf96 100644 --- a/src/resources/filters/quarto-post/typst.lua +++ b/src/resources/filters/quarto-post/typst.lua @@ -32,6 +32,9 @@ function render_typst() }, { FloatRefTarget = function(float) + if float.content == nil then + return float + end if float.content.t == "Table" then -- this needs the fix from https://github.com/jgm/pandoc/pulls/9778 float.content.classes:insert("typst-no-figure") diff --git a/tests/docs/smoke-all/2025/05/23/issue-12815.qmd b/tests/docs/smoke-all/2025/05/23/issue-12815.qmd new file mode 100644 index 00000000000..ee0efcd1f17 --- /dev/null +++ b/tests/docs/smoke-all/2025/05/23/issue-12815.qmd @@ -0,0 +1,10 @@ +--- +title: "Untitled" +format: typst +--- + + +::: {#tbl-mtcars .cell tbl-cap='Head of mtcars'} + +::: +