summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/Typst.hs9
-rw-r--r--test/tables.typst41
2 files changed, 29 insertions, 21 deletions
diff --git a/src/Text/Pandoc/Writers/Typst.hs b/src/Text/Pandoc/Writers/Typst.hs
index 159174baf..10948e2ab 100644
--- a/src/Text/Pandoc/Writers/Typst.hs
+++ b/src/Text/Pandoc/Writers/Typst.hs
@@ -165,14 +165,15 @@ blockToTypst block =
then return mempty
else do
captcontents <- inlinesToTypst caption
- return $ "#align(center, " <> brackets captcontents <> ")"
+ return $ ", caption: " <> brackets captcontents
let lab = toLabel ident
let formatalign AlignLeft = "left,"
formatalign AlignRight = "right,"
formatalign AlignCenter = "center,"
formatalign AlignDefault = "auto,"
let alignarray = parens $ mconcat $ map formatalign aligns
- return $ "#align(center)[#table("
+ return $ "#figure(" $$
+ "align(center)[#table("
$$ nest 2
( "columns: " <> text (show numcols) <> "," -- auto
$$ "align: (col, row) => " <> alignarray <> ".at(col),"
@@ -180,10 +181,10 @@ blockToTypst block =
$$ hsep (map ((<>",") . brackets) headers')
$$ vcat (map (\x -> brackets x <> ",") (concat rows'))
)
- $$ ")"
+ $$ ")]"
$$ capt'
+ $$ ")"
$$ lab
- $$ "]"
$$ blankline
Figure (ident,_,_) (Caption _mbshort capt) blocks -> do
caption <- blocksToTypst capt
diff --git a/test/tables.typst b/test/tables.typst
index 99a483616..46b3e7133 100644
--- a/test/tables.typst
+++ b/test/tables.typst
@@ -1,6 +1,7 @@
Simple table with caption:
-#align(center)[#table(
+#figure(
+align(center)[#table(
columns: 4,
align: (col, row) => (right,left,center,auto,).at(col),
inset: 6pt,
@@ -17,13 +18,14 @@ Simple table with caption:
[1],
[1],
[1],
+)]
+, caption: [Demonstration of simple table syntax.]
)
-#align(center, [Demonstration of simple table syntax.])
-]
Simple table without caption:
-#align(center)[#table(
+#figure(
+align(center)[#table(
columns: 4,
align: (col, row) => (right,left,center,auto,).at(col),
inset: 6pt,
@@ -40,12 +42,13 @@ Simple table without caption:
[1],
[1],
[1],
+)]
)
-]
Simple table indented two spaces:
-#align(center)[#table(
+#figure(
+align(center)[#table(
columns: 4,
align: (col, row) => (right,left,center,auto,).at(col),
inset: 6pt,
@@ -62,13 +65,14 @@ Simple table indented two spaces:
[1],
[1],
[1],
+)]
+, caption: [Demonstration of simple table syntax.]
)
-#align(center, [Demonstration of simple table syntax.])
-]
Multiline table with caption:
-#align(center)[#table(
+#figure(
+align(center)[#table(
columns: 4,
align: (col, row) => (center,left,right,left,).at(col),
inset: 6pt,
@@ -81,13 +85,14 @@ Multiline table with caption:
[row],
[5.0],
[Here’s another one. Note the blank line between rows.],
+)]
+, caption: [Here’s the caption. It may span multiple lines.]
)
-#align(center, [Here’s the caption. It may span multiple lines.])
-]
Multiline table without caption:
-#align(center)[#table(
+#figure(
+align(center)[#table(
columns: 4,
align: (col, row) => (center,left,right,left,).at(col),
inset: 6pt,
@@ -100,12 +105,13 @@ Multiline table without caption:
[row],
[5.0],
[Here’s another one. Note the blank line between rows.],
+)]
)
-]
Table without column headers:
-#align(center)[#table(
+#figure(
+align(center)[#table(
columns: 4,
align: (col, row) => (right,left,center,right,).at(col),
inset: 6pt,
@@ -121,12 +127,13 @@ Table without column headers:
[1],
[1],
[1],
+)]
)
-]
Multiline table without column headers:
-#align(center)[#table(
+#figure(
+align(center)[#table(
columns: 4,
align: (col, row) => (center,left,right,auto,).at(col),
inset: 6pt,
@@ -138,5 +145,5 @@ Multiline table without column headers:
[row],
[5.0],
[Here’s another one. Note the blank line between rows.],
+)]
)
-]