aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2024-05-27 19:37:52 -0700
committerJohn MacFarlane <[email protected]>2024-05-27 19:46:08 -0700
commit372cd1d3b19b94ce7a8a72349a5fb6d735025878 (patch)
tree5fa935f495cbbca4e70103ef571dee4545ee5a6a
parent2e1f17a09fa01fe8c265b3acf3e6a55d19a67a42 (diff)
Typst reader: handle inline bodies ending in a parbreak.
E.g. `#strong[ test ]`. Here we simply skip the final parbreak. Treat this as a soft break, which will give results similar to the typst app.
-rw-r--r--src/Text/Pandoc/Readers/Typst.hs3
-rw-r--r--test/command/9807.md13
-rw-r--r--test/typst-reader.native4
3 files changed, 18 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Typst.hs b/src/Text/Pandoc/Readers/Typst.hs
index c2e1983ac..128c919c4 100644
--- a/src/Text/Pandoc/Readers/Typst.hs
+++ b/src/Text/Pandoc/Readers/Typst.hs
@@ -539,7 +539,8 @@ pWithContents pa cs = try $ do
pInlines :: PandocMonad m => P m B.Inlines
pInlines =
- collapseAdjacentCites . mconcat <$> many pInline
+ mappend <$> (collapseAdjacentCites . mconcat <$> many pInline)
+ <*> ((B.softbreak <$ pParBreak) <|> pure mempty)
collapseAdjacentCites :: B.Inlines -> B.Inlines
collapseAdjacentCites = B.fromList . foldr go [] . B.toList
diff --git a/test/command/9807.md b/test/command/9807.md
new file mode 100644
index 000000000..e5663fac5
--- /dev/null
+++ b/test/command/9807.md
@@ -0,0 +1,13 @@
+```
+% pandoc -f typst -t native
+#let foo = [
+ bar baz
+]
+*#foo*
+^D
+[ Para
+ [ Strong
+ [ SoftBreak , Str "bar" , Space , Str "baz" , SoftBreak ]
+ ]
+]
+```
diff --git a/test/typst-reader.native b/test/typst-reader.native
index 74a0ad8de..7644ee0ff 100644
--- a/test/typst-reader.native
+++ b/test/typst-reader.native
@@ -203,7 +203,8 @@ Pandoc
[ Underline
[ Link
( "" , [] , [] )
- [ Strong
+ [ SoftBreak
+ , Strong
[ Str "Typst"
, Space
, Str "Math"
@@ -212,6 +213,7 @@ Pandoc
, Space
, Str "Undergrads"
]
+ , SoftBreak
]
( "https://github.com/johanvx/typst-undergradmath"
, ""