LaTeX writer: Use mbox to get proper behavior inside \sout
.
Closes #5529.
This commit is contained in:
parent
59529e408b
commit
3febd81cbc
3 changed files with 17 additions and 7 deletions
|
@ -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 }
|
||||
|
|
|
@ -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" =:
|
||||
|
|
10
test/command/5529.md
Normal file
10
test/command/5529.md
Normal file
|
@ -0,0 +1,10 @@
|
|||
```
|
||||
% pandoc -t latex
|
||||
~~`hello world`~~
|
||||
|
||||
~~_`hello world`_~~
|
||||
^D
|
||||
\sout{\mbox{\texttt{hello\ world}}}
|
||||
|
||||
\sout{\emph{\mbox{\texttt{hello\ world}}}}
|
||||
```
|
Loading…
Reference in a new issue