aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs12
-rw-r--r--test/Tests/Writers/LaTeX.hs2
-rw-r--r--test/command/5529.md10
3 files changed, 17 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 467ef304a..9933c6d36 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -1131,7 +1131,9 @@ inlineToLaTeX (Strong lst) =
inlineToLaTeX (Strikeout lst) = do
-- we need to protect VERB in an mbox or we get an error
-- see #1294
- contents <- inlineListToLaTeX $ protectCode lst
+ -- with regular texttt we don't get an error, but we get
+ -- incorrect results if there is a space, see #5529
+ contents <- inlineListToLaTeX $ walk (concatMap protectCode) lst
modify $ \s -> s{ stStrikeout = True }
return $ inCmd "sout" contents
inlineToLaTeX (Superscript lst) =
@@ -1336,12 +1338,10 @@ handleMathComment s =
'%':_ -> s ++ "\n"
_ -> s
-protectCode :: [Inline] -> [Inline]
-protectCode [] = []
-protectCode (x@(Code ("",[],[]) _) : xs) = x : protectCode xs
-protectCode (x@(Code _ _) : xs) = ltx "\\mbox{" : x : ltx "}" : xs
+protectCode :: Inline -> [Inline]
+protectCode x@(Code _ _) = [ltx "\\mbox{" , x , ltx "}"]
where ltx = RawInline (Format "latex")
-protectCode (x : xs) = x : protectCode xs
+protectCode x = [x]
setEmptyLine :: PandocMonad m => Bool -> LW m ()
setEmptyLine b = modify $ \st -> st{ stEmptyLine = b }
diff --git a/test/Tests/Writers/LaTeX.hs b/test/Tests/Writers/LaTeX.hs
index 00150022f..4bf25fb1c 100644
--- a/test/Tests/Writers/LaTeX.hs
+++ b/test/Tests/Writers/LaTeX.hs
@@ -81,7 +81,7 @@ tests = [ testGroup "code blocks"
, "struck out and not highlighted" =:
strikeout (code "foo" <> space
<> str "bar") =?>
- "\\sout{\\texttt{foo} bar}"
+ "\\sout{\\mbox{\\texttt{foo}} bar}"
, "single quotes" =:
code "dog's" =?> "\\texttt{dog\\textquotesingle{}s}"
, "backtick" =:
diff --git a/test/command/5529.md b/test/command/5529.md
new file mode 100644
index 000000000..fcecd9b1f
--- /dev/null
+++ b/test/command/5529.md
@@ -0,0 +1,10 @@
+```
+% pandoc -t latex
+~~`hello world`~~
+
+~~_`hello world`_~~
+^D
+\sout{\mbox{\texttt{hello\ world}}}
+
+\sout{\emph{\mbox{\texttt{hello\ world}}}}
+```