Skip to content

Commit 61387d2

Browse files
move typst table block wrapper to specific place where it is needed
to avoid churning tests with a temporary change
1 parent ed4b831 commit 61387d2

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

src/resources/filters/quarto-post/typst-css-property-processing.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,17 @@ function render_typst_css_property_processing()
284284
Table = function(tab)
285285
_warnings = new_table()
286286
local tabstyle = tab.attributes['style']
287+
local has_typst_text = false
287288
if tabstyle ~= nil then
288289
for clause in tabstyle:gmatch('([^;]+)') do
289290
local k, v = to_kv(clause)
290291
if k == 'font-family' then
291292
tab.attributes['typst:text:font'] = translate_string_list(v)
293+
has_typst_text = true
292294
end
293295
if k == 'font-size' then
294296
tab.attributes['typst:text:size'] = _quarto.format.typst.css.translate_length(v, _warnings)
297+
has_typst_text = true
295298
end
296299
end
297300
end
@@ -311,7 +314,13 @@ function render_typst_css_property_processing()
311314
end
312315
aggregate_warnings()
313316
_warnings = nil
314-
return tab
317+
if not has_typst_text then return tab end
318+
-- Create Div wrapper and return false to prevent processing its contents
319+
return pandoc.Div({
320+
pandoc.RawBlock("typst", "#["),
321+
tab,
322+
pandoc.RawBlock("typst", "]")
323+
}), false
315324
end,
316325
Div = function(div)
317326
_warnings = new_table()

src/resources/filters/quarto-post/typst.lua

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,7 @@ function render_typst_fixups()
122122
Table = function(tbl)
123123
-- https://github.com/quarto-dev/quarto-cli/issues/10438
124124
tbl.classes:insert("typst:no-figure")
125-
126-
-- Create Div wrapper and return false to prevent processing its contents
127-
return pandoc.Div({
128-
pandoc.RawBlock("typst", "#["),
129-
tbl,
130-
pandoc.RawBlock("typst", "]")
131-
}), false
125+
return tbl
132126
end,
133127
Para = function(para)
134128
if #para.content ~= 1 then
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
format: typst
3+
_quarto:
4+
tests:
5+
typst:
6+
ensurePdfRegexMatches:
7+
-
8+
- 'Paragraph text before is 11pt'
9+
- 'Paragraph text after is 11pt'
10+
-
11+
- 'Paragraph text after is 6pt'
12+
13+
---
14+
15+
Paragraph text before is `#context text.size`{=typst}.
16+
17+
```{=html}
18+
<table style="font-size: 8px;">
19+
<tr><td>A</td><td>B</td></tr>
20+
</table>
21+
```
22+
23+
Paragraph text after is `#context text.size`{=typst}.

0 commit comments

Comments
 (0)