aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2024-03-22 08:50:20 -0700
committerJohn MacFarlane <[email protected]>2024-03-22 08:50:20 -0700
commitb28dc15817e6e4b56cd1f12c6883bbb5b964afad (patch)
tree4288cc01b9a64c839492d81c03c3e9b14a2b590b
parenta70399d7a07ec4854551e1cd0bc75d28ee99b002 (diff)
LaTeX writer: fix math inside strikeout (closes #9597).
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs5
-rw-r--r--test/command/9597.md6
2 files changed, 10 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 2c3404310..33fa15f1b 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -868,7 +868,10 @@ inlineToLaTeX (Strikeout lst) = do
-- incorrect results if there is a space, see #5529
contents <- inlineListToLaTeX $ walk (concatMap protectCode) lst
modify $ \s -> s{ stStrikeout = True }
- return $ inCmd "st" contents
+ -- soul doesn't like \(..\) delimiters, so we change these to $ (#9597):
+ let fixMath = T.replace "\\(" "$" . T.replace "\\)" "$" .
+ T.replace "\\[" "$$" . T.replace "\\]" "$$"
+ return $ inCmd "st" $ fixMath <$> contents
inlineToLaTeX (Superscript lst) =
inCmd "textsuperscript" <$> inlineListToLaTeX lst
inlineToLaTeX (Subscript lst) =
diff --git a/test/command/9597.md b/test/command/9597.md
new file mode 100644
index 000000000..272d79d02
--- /dev/null
+++ b/test/command/9597.md
@@ -0,0 +1,6 @@
+```
+% pandoc -t latex
+~~$T$~~
+^D
+\st{$T$}
+```