git.iko.soy/typeable/pandoc
on master help sign in
Stop escaping `|` in LaTeX math.
79a4ea0John MacFarlane
src/Text/Pandoc/Writers/LaTeX.hs+2−9
@@ -212,13 +212,6 @@ stringToLaTeX isUrl (x:xs) = do
212 '\x2013' | ligatures -> "--" ++ rest
212 '\x2013' | ligatures -> "--" ++ rest
213 _ -> x : rest
213 _ -> x : rest
214
214
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−
222-- | Puts contents into LaTeX command.
215-- | Puts contents into LaTeX command.
223inCmd :: String -> Doc -> Doc
216inCmd :: String -> Doc -> Doc
224inCmd cmd contents = char '\\' <> text cmd <> braces contents
217inCmd cmd contents = char '\\' <> text cmd <> braces contents
@@ -622,9 +615,9 @@ inlineToLaTeX (Quoted qt lst) = do
622 else char '\x2018' <> inner <> char '\x2019'
615 else char '\x2018' <> inner <> char '\x2019'
623inlineToLaTeX (Str str) = liftM text $ stringToLaTeX False str
616inlineToLaTeX (Str str) = liftM text $ stringToLaTeX False str
624inlineToLaTeX (Math InlineMath str) =
617inlineToLaTeX (Math InlineMath str) =
625− return $ char '$' <> text (escapeMath str) <> char '$'
618+ return $ char '$' <> text str <> char '$'
626inlineToLaTeX (Math DisplayMath str) =
619inlineToLaTeX (Math DisplayMath str) =
627− return $ "\\[" <> text (escapeMath str) <> "\\]"
620+ return $ "\\[" <> text str <> "\\]"
628inlineToLaTeX (RawInline "latex" str) = return $ text str
621inlineToLaTeX (RawInline "latex" str) = return $ text str
629inlineToLaTeX (RawInline "tex" str) = return $ text str
622inlineToLaTeX (RawInline "tex" str) = return $ text str
630inlineToLaTeX (RawInline _ _) = return empty
623inlineToLaTeX (RawInline _ _) = return empty
tests/Tests/Writers/LaTeX.hs+1−1
@@ -34,6 +34,6 @@ tests = [ testGroup "code blocks"
34 ]
34 ]
35 , testGroup "math"
35 , testGroup "math"
36 [ "escape |" =: para (math "\\sigma|_{\\{x\\}}") =?>
36 [ "escape |" =: para (math "\\sigma|_{\\{x\\}}") =?>
37− "$\\sigma\\vert _{\\{x\\}}$"
37+ "$\\sigma|_{\\{x\\}}$"
38 ]
38 ]
39 ]
39 ]
tests/lhs-test.latex+1−1
@@ -23,7 +23,7 @@
23\usepackage{color}
23\usepackage{color}
24\usepackage{fancyvrb}
24\usepackage{fancyvrb}
25\newcommand{\VerbBar}{|}
25\newcommand{\VerbBar}{|}
26−\DefineShortVerb[commandchars=\\\{\}]{\|}
26+\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
27\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
27\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
28% Add ',fontsize=\small' for more characters per line
28% Add ',fontsize=\small' for more characters per line
29\newenvironment{Shaded}{}{}
29\newenvironment{Shaded}{}{}