From 26c3c6224082e2b968d2e4a964aaa5ba71625ce2 Mon Sep 17 00:00:00 2001 From: Younes <3153107+younes-io@users.noreply.github.com> Date: Fri, 18 Oct 2024 22:07:54 +0200 Subject: [PATCH 1/2] Fix Typst table wrapping to prevent font family and size spill remove typst-processed --- src/resources/filters/quarto-post/typst.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/resources/filters/quarto-post/typst.lua b/src/resources/filters/quarto-post/typst.lua index 347fbf85477..f595ac2e26f 100644 --- a/src/resources/filters/quarto-post/typst.lua +++ b/src/resources/filters/quarto-post/typst.lua @@ -122,7 +122,13 @@ function render_typst_fixups() Table = function(tbl) -- https://github.com/quarto-dev/quarto-cli/issues/10438 tbl.classes:insert("typst:no-figure") - return tbl + + -- Create Div wrapper and return false to prevent processing its contents + return pandoc.Div({ + pandoc.RawBlock("typst", "#["), + tbl, + pandoc.RawBlock("typst", "]") + }), false end, Para = function(para) if #para.content ~= 1 then @@ -145,4 +151,4 @@ function render_typst_fixups() }) end, } -end \ No newline at end of file +end From 6999e08e6e50c8f83255abd5a64e84b45ee0ce62 Mon Sep 17 00:00:00 2001 From: Gordon Woodhull Date: Wed, 23 Oct 2024 11:19:42 -0400 Subject: [PATCH 2/2] move typst table block wrapper to specific place where it is needed to avoid churning tests with a temporary change --- .../typst-css-property-processing.lua | 11 ++++++++- src/resources/filters/quarto-post/typst.lua | 8 +------ .../2024/10/23/spilled-font-size.qmd | 23 +++++++++++++++++++ 3 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 tests/docs/smoke-all/2024/10/23/spilled-font-size.qmd diff --git a/src/resources/filters/quarto-post/typst-css-property-processing.lua b/src/resources/filters/quarto-post/typst-css-property-processing.lua index 324e30ef299..17a8b413421 100644 --- a/src/resources/filters/quarto-post/typst-css-property-processing.lua +++ b/src/resources/filters/quarto-post/typst-css-property-processing.lua @@ -284,14 +284,17 @@ function render_typst_css_property_processing() Table = function(tab) _warnings = new_table() local tabstyle = tab.attributes['style'] + local has_typst_text = false if tabstyle ~= nil then for clause in tabstyle:gmatch('([^;]+)') do local k, v = to_kv(clause) if k == 'font-family' then tab.attributes['typst:text:font'] = translate_string_list(v) + has_typst_text = true end if k == 'font-size' then tab.attributes['typst:text:size'] = _quarto.format.typst.css.translate_length(v, _warnings) + has_typst_text = true end end end @@ -311,7 +314,13 @@ function render_typst_css_property_processing() end aggregate_warnings() _warnings = nil - return tab + if not has_typst_text then return tab end + -- Create Div wrapper and return false to prevent processing its contents + return pandoc.Div({ + pandoc.RawBlock("typst", "#["), + tab, + pandoc.RawBlock("typst", "]") + }), false end, Div = function(div) _warnings = new_table() diff --git a/src/resources/filters/quarto-post/typst.lua b/src/resources/filters/quarto-post/typst.lua index f595ac2e26f..4a2e7f8d6f5 100644 --- a/src/resources/filters/quarto-post/typst.lua +++ b/src/resources/filters/quarto-post/typst.lua @@ -122,13 +122,7 @@ function render_typst_fixups() Table = function(tbl) -- https://github.com/quarto-dev/quarto-cli/issues/10438 tbl.classes:insert("typst:no-figure") - - -- Create Div wrapper and return false to prevent processing its contents - return pandoc.Div({ - pandoc.RawBlock("typst", "#["), - tbl, - pandoc.RawBlock("typst", "]") - }), false + return tbl end, Para = function(para) if #para.content ~= 1 then diff --git a/tests/docs/smoke-all/2024/10/23/spilled-font-size.qmd b/tests/docs/smoke-all/2024/10/23/spilled-font-size.qmd new file mode 100644 index 00000000000..1b2908142e3 --- /dev/null +++ b/tests/docs/smoke-all/2024/10/23/spilled-font-size.qmd @@ -0,0 +1,23 @@ +--- +format: typst +_quarto: + tests: + typst: + ensurePdfRegexMatches: + - + - 'Paragraph text before is 11pt' + - 'Paragraph text after is 11pt' + - + - 'Paragraph text after is 6pt' + +--- + +Paragraph text before is `#context text.size`{=typst}. + +```{=html} + + +
AB
+``` + +Paragraph text after is `#context text.size`{=typst}. \ No newline at end of file