git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1695 from bjornbm/master

Escape inline verbatim spaces in LaTeX output

commit4ffa70970dc7219aa71c137c728280b7460ed604 authorJohn MacFarlane <jgm@berkeley.edu> dateWed 10 Dec 2014, 09:07 (12 years ago) parent2b1ddc27960013
2 files changed+4−2
src/Text/Pandoc/Writers/LaTeX.hs+3−1 tests/writer.latex+1−1
src/Text/Pandoc/Writers/LaTeX.hs+3−1
@@ -746,8 +746,10 @@ inlineToLaTeX (Code (_,classes,_) str) = do
746746 Nothing -> rawCode
747747 Just h -> modify (\st -> st{ stHighlighting = True }) >>
748748 return (text h)
749− rawCode = liftM (text . (\s -> "\\texttt{" ++ s ++ "}"))
749+ rawCode = liftM (text . (\s -> "\\texttt{" ++ escapeSpaces s ++ "}"))
750750 $ stringToLaTeX CodeString str
751+ where
752+ escapeSpaces = concatMap (\c -> if c == ' ' then "\\ " else [c])
751753inlineToLaTeX (Quoted qt lst) = do
752754 contents <- inlineListToLaTeX lst
753755 csquotes <- liftM stCsquotes get
tests/writer.latex+1−1
@@ -734,7 +734,7 @@ These shouldn't be math:
734734\begin{itemize}
735735\itemsep1pt\parskip0pt\parsep0pt
736736\item
737− To get the famous equation, write \texttt{\$e = mc\^{}2\$}.
737+ To get the famous equation, write \texttt{\$e\ =\ mc\^{}2\$}.
738738\item
739739 \$22,000 is a \emph{lot} of money. So is \$34,000. (It worked if ``lot'' is
740740 emphasized.)