Skip to content

Commit

Permalink
Stop escaping | in LaTeX math.
Browse files Browse the repository at this point in the history
This caused problems with array environments.  Closes #891.
  • Loading branch information
John MacFarlane committed Jun 27, 2013
1 parent f939dbd commit 79a4ea0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
11 changes: 2 additions & 9 deletions src/Text/Pandoc/Writers/LaTeX.hs
Expand Up @@ -212,13 +212,6 @@ stringToLaTeX isUrl (x:xs) = do
'\x2013' | ligatures -> "--" ++ rest
_ -> x : rest

-- This is needed because | in math mode interacts badly with
-- highlighting-kate, which redefines | as a short verb command.
escapeMath :: String -> String
escapeMath ('|':xs) = "\\vert " ++ escapeMath xs
escapeMath (x:xs) = x : escapeMath xs
escapeMath [] = ""

-- | Puts contents into LaTeX command.
inCmd :: String -> Doc -> Doc
inCmd cmd contents = char '\\' <> text cmd <> braces contents
Expand Down Expand Up @@ -622,9 +615,9 @@ inlineToLaTeX (Quoted qt lst) = do
else char '\x2018' <> inner <> char '\x2019'
inlineToLaTeX (Str str) = liftM text $ stringToLaTeX False str
inlineToLaTeX (Math InlineMath str) =
return $ char '$' <> text (escapeMath str) <> char '$'
return $ char '$' <> text str <> char '$'
inlineToLaTeX (Math DisplayMath str) =
return $ "\\[" <> text (escapeMath str) <> "\\]"
return $ "\\[" <> text str <> "\\]"
inlineToLaTeX (RawInline "latex" str) = return $ text str
inlineToLaTeX (RawInline "tex" str) = return $ text str
inlineToLaTeX (RawInline _ _) = return empty
Expand Down
2 changes: 1 addition & 1 deletion tests/Tests/Writers/LaTeX.hs
Expand Up @@ -34,6 +34,6 @@ tests = [ testGroup "code blocks"
]
, testGroup "math"
[ "escape |" =: para (math "\\sigma|_{\\{x\\}}") =?>
"$\\sigma\\vert _{\\{x\\}}$"
"$\\sigma|_{\\{x\\}}$"
]
]
2 changes: 1 addition & 1 deletion tests/lhs-test.latex
Expand Up @@ -23,7 +23,7 @@
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\DefineShortVerb[commandchars=\\\{\}]{\|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\newenvironment{Shaded}{}{}
Expand Down

0 comments on commit 79a4ea0

Please sign in to comment.