summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/Typst.hs15
-rw-r--r--test/command/9478.md9
2 files changed, 19 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Writers/Typst.hs b/src/Text/Pandoc/Writers/Typst.hs
index 9fc58b368..c9df66f77 100644
--- a/src/Text/Pandoc/Writers/Typst.hs
+++ b/src/Text/Pandoc/Writers/Typst.hs
@@ -218,6 +218,9 @@ listItemToTypst ind marker blocks = do
return $ hang ind (marker <> space) contents
inlinesToTypst :: PandocMonad m => [Inline] -> TW m (Doc Text)
+inlinesToTypst ils@(Str t : _) -- need to escape - in '[-]' #9478
+ | Just (c, _) <- T.uncons t
+ , needsEscapeAtLineStart c = ("\\" <>) . hcat <$> mapM inlineToTypst ils
inlinesToTypst ils = hcat <$> mapM inlineToTypst ils
inlineToTypst :: PandocMonad m => Inline -> TW m (Doc Text)
@@ -360,11 +363,13 @@ escapeTypst context t =
needsEscape '~' = True
needsEscape ':' = context == TermContext
needsEscape _ = False
- needsEscapeAtLineStart '/' = True
- needsEscapeAtLineStart '+' = True
- needsEscapeAtLineStart '-' = True
- needsEscapeAtLineStart '=' = True
- needsEscapeAtLineStart _ = False
+
+needsEscapeAtLineStart :: Char -> Bool
+needsEscapeAtLineStart '/' = True
+needsEscapeAtLineStart '+' = True
+needsEscapeAtLineStart '-' = True
+needsEscapeAtLineStart '=' = True
+needsEscapeAtLineStart _ = False
data LabelType =
FreestandingLabel
diff --git a/test/command/9478.md b/test/command/9478.md
new file mode 100644
index 000000000..273971775
--- /dev/null
+++ b/test/command/9478.md
@@ -0,0 +1,9 @@
+```
+% pandoc -t typst --wrap=preserve
+**- a -
+- b**
+^D
+#strong[\- a -
+\- b]
+```
+