aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjorn Buckwalter <bjorn@buckwalter.se>2014-10-15 21:06:41 +0200
committerBjorn Buckwalter <bjorn@buckwalter.se>2014-10-15 21:06:41 +0200
commit7960013cd4586542c2d7feab908a8befccc677f0 (patch)
tree12673a957262d3c1ed3a15777986cdc68926131c
parent8b60d430f2095c42daf26f2921359d5c49f0757d (diff)
downloadpandoc-7960013cd4586542c2d7feab908a8befccc677f0.tar.gz
Escape spaces. Fixes jgm/pandoc#1694.
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs4
-rw-r--r--tests/writer.latex2
2 files changed, 4 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index ae2f4e907..417317b54 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -746,8 +746,10 @@ inlineToLaTeX (Code (_,classes,_) str) = do
Nothing -> rawCode
Just h -> modify (\st -> st{ stHighlighting = True }) >>
return (text h)
- rawCode = liftM (text . (\s -> "\\texttt{" ++ s ++ "}"))
+ rawCode = liftM (text . (\s -> "\\texttt{" ++ escapeSpaces s ++ "}"))
$ stringToLaTeX CodeString str
+ where
+ escapeSpaces = concatMap (\c -> if c == ' ' then "\\ " else [c])
inlineToLaTeX (Quoted qt lst) = do
contents <- inlineListToLaTeX lst
csquotes <- liftM stCsquotes get
diff --git a/tests/writer.latex b/tests/writer.latex
index a966e374b..82fa3c23f 100644
--- a/tests/writer.latex
+++ b/tests/writer.latex
@@ -734,7 +734,7 @@ These shouldn't be math:
\begin{itemize}
\itemsep1pt\parskip0pt\parsep0pt
\item
- To get the famous equation, write \texttt{\$e = mc\^{}2\$}.
+ To get the famous equation, write \texttt{\$e\ =\ mc\^{}2\$}.
\item
\$22,000 is a \emph{lot} of money. So is \$34,000. (It worked if ``lot'' is
emphasized.)