git.iko.soy/typeable/pandoc
on master help sign in
Stop escaping `|` in LaTeX math.

This caused problems with array environments. Closes #891.

commit79a4ea03e2d0a252fd24af3444cf5b64ee724100 authorJohn MacFarlane <fiddlosopher@gmail.com> dateWed 26 Jun 2013, 20:54 (13 years ago) parentf939dbd
3 files changed+4−11
src/Text/Pandoc/Writers/LaTeX.hs+2−9 tests/Tests/Writers/LaTeX.hs+1−1 tests/lhs-test.latex+1−1
src/Text/Pandoc/Writers/LaTeX.hs+2−9
@@ -212,13 +212,6 @@ stringToLaTeX isUrl (x:xs) = do
212212 '\x2013' | ligatures -> "--" ++ rest
213213 _ -> x : rest
214214
215−-- This is needed because | in math mode interacts badly with
216−-- highlighting-kate, which redefines | as a short verb command.
217−escapeMath :: String -> String
218−escapeMath ('|':xs) = "\\vert " ++ escapeMath xs
219−escapeMath (x:xs) = x : escapeMath xs
220−escapeMath [] = ""
221−
222215-- | Puts contents into LaTeX command.
223216inCmd :: String -> Doc -> Doc
224217inCmd cmd contents = char '\\' <> text cmd <> braces contents
@@ -622,9 +615,9 @@ inlineToLaTeX (Quoted qt lst) = do
622615 else char '\x2018' <> inner <> char '\x2019'
623616inlineToLaTeX (Str str) = liftM text $ stringToLaTeX False str
624617inlineToLaTeX (Math InlineMath str) =
625− return $ char '$' <> text (escapeMath str) <> char '$'
618+ return $ char '$' <> text str <> char '$'
626619inlineToLaTeX (Math DisplayMath str) =
627− return $ "\\[" <> text (escapeMath str) <> "\\]"
620+ return $ "\\[" <> text str <> "\\]"
628621inlineToLaTeX (RawInline "latex" str) = return $ text str
629622inlineToLaTeX (RawInline "tex" str) = return $ text str
630623inlineToLaTeX (RawInline _ _) = return empty
tests/Tests/Writers/LaTeX.hs+1−1
@@ -34,6 +34,6 @@ tests = [ testGroup "code blocks"
3434 ]
3535 , testGroup "math"
3636 [ "escape |" =: para (math "\\sigma|_{\\{x\\}}") =?>
37− "$\\sigma\\vert _{\\{x\\}}$"
37+ "$\\sigma|_{\\{x\\}}$"
3838 ]
3939 ]
tests/lhs-test.latex+1−1
@@ -23,7 +23,7 @@
2323\usepackage{color}
2424\usepackage{fancyvrb}
2525\newcommand{\VerbBar}{|}
26−\DefineShortVerb[commandchars=\\\{\}]{\|}
26+\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
2727\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
2828% Add ',fontsize=\small' for more characters per line
2929\newenvironment{Shaded}{}{}