Skip to content

Commit 59aa47f

Browse files
committed
fix(typst): preserve bare table labels
Emit the existing label after tables with typst:no-figure, including those with scoped text properties. Cover identifiers, explicit label precedence, and scoped text properties with three command tests.
1 parent 8813d0f commit 59aa47f

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

src/Text/Pandoc/Writers/Typst.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ blockToTypst block =
364364
)
365365
$$ ")"
366366
return $ if "typst:no-figure" `elem` tabclasses
367-
then toTypstBracesSetText typstTextAttrs table
367+
then toTypstBracesSetText typstTextAttrs table $$ lab
368368
else "#figure("
369369
$$
370370
nest 2

test/command/typst-table-labels.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Identifiers are preserved on tables without a figure wrapper.
2+
3+
```
4+
% pandoc -f html -t typst
5+
<table id="table-id" class="typst:no-figure">
6+
<tr><td>A</td><td>B</td></tr>
7+
</table>
8+
^D
9+
#table(
10+
columns: 2,
11+
align: (auto,auto,),
12+
[A], [B],
13+
)
14+
<table-id>
15+
```
16+
17+
An explicit Typst label takes precedence over the identifier.
18+
19+
```
20+
% pandoc -f html -t typst
21+
<table id="table-id" class="typst:no-figure" typst-label="table-label">
22+
<tr><td>A</td><td>B</td></tr>
23+
</table>
24+
^D
25+
#table(
26+
columns: 2,
27+
align: (auto,auto,),
28+
[A], [B],
29+
)
30+
<table-label>
31+
```
32+
33+
Labels follow scoped text properties.
34+
35+
```
36+
% pandoc -f html -t typst
37+
<table class="typst:no-figure" typst-label="table label"
38+
typst:text:size="3em">
39+
<tr><td>A</td><td>B</td></tr>
40+
</table>
41+
<p>Paragraph after.</p>
42+
^D
43+
#{set text(size: 3em);table(
44+
columns: 2,
45+
align: (auto,auto,),
46+
[A], [B],
47+
)}
48+
#label("table label")
49+
Paragraph after.
50+
```

0 commit comments

Comments
 (0)