summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2023-08-09 11:37:39 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2023-08-09 11:38:38 -0700
commitcc371a9485241db3e0101180432e2122d023a9bd (patch)
tree2882f2d10e8b17a78fef6282dca5e7a976619183
parente611edb7d86af665830a34bb3ee2ff049eda0976 (diff)
Typst writer: put the label in right place for Div, use `#block`.
Closes #8991. Previously we were putting the label at the beginning of the Div's contents, but according to the documentation such a label gets attached to the *preceding* element. We now use an explicit `#block` and add the label at the end.
-rw-r--r--src/Text/Pandoc/Writers/Typst.hs4
-rw-r--r--test/writer.typst18
2 files changed, 21 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Typst.hs b/src/Text/Pandoc/Writers/Typst.hs
index 53edbcb0c..8cd64d2ac 100644
--- a/src/Text/Pandoc/Writers/Typst.hs
+++ b/src/Text/Pandoc/Writers/Typst.hs
@@ -189,10 +189,12 @@ blockToTypst block =
return $ "#figure(" <> nest 2 (brackets contents <> "," <> cr <>
("caption: [" $$ nest 2 caption $$ "]"))
$$ ")" $$ lab $$ blankline
+ Div (ident,_,_) (Header lev ("",cls,kvs) ils:rest) ->
+ blocksToTypst (Header lev (ident,cls,kvs) ils:rest)
Div (ident,_,_) blocks -> do
let lab = toLabel ident
contents <- blocksToTypst blocks
- return $ lab $$ contents
+ return $ "#block[" $$ contents $$ ("]" <+> lab)
defListItemToTypst :: PandocMonad m => ([Inline], [[Block]]) -> TW m (Doc Text)
defListItemToTypst (term, defns) = do
diff --git a/test/writer.typst b/test/writer.typst
index 14658c489..d645d11b2 100644
--- a/test/writer.typst
+++ b/test/writer.typst
@@ -497,20 +497,32 @@ orange fruit
<html-blocks>
Simple block on one line:
+#block[
foo
+]
And nested without indentation:
+#block[
+#block[
+#block[
foo
+]
+]
+#block[
bar
+]
+]
Interpreted markdown in a table:
This is #emph[emphasized]
And this is #strong[strong]
Here’s a simple block:
+#block[
foo
+]
This should be a code block, though:
```
@@ -527,7 +539,13 @@ As should this:
Now, nested:
+#block[
+#block[
+#block[
foo
+]
+]
+]
This should just be an HTML comment:
Multiline: