@@ -214,6 +214,13 @@ stringToLaTeX isUrl (x:xs) = do
214214 '\x2013' | ligatures -> "--" ++ rest
215215 _ -> x : rest
216216
217+-- This is needed because | in math mode interacts badly with
218+-- highlighting-kate, which redefines | as a short verb command.
219+escapeMath :: String -> String
220+escapeMath ('|':xs) = "\\vert " ++ escapeMath xs
221+escapeMath (x:xs) = x : escapeMath xs
222+escapeMath [] = ""
223+
217224-- | Puts contents into LaTeX command.
218225inCmd :: String -> Doc -> Doc
219226inCmd cmd contents = char '\\' <> text cmd <> braces contents
@@ -603,8 +610,10 @@ inlineToLaTeX (Quoted qt lst) = do
603610 then char '`' <> inner <> char '\''
604611 else char '\x2018' <> inner <> char '\x2019'
605612inlineToLaTeX (Str str) = liftM text $ stringToLaTeX False str
606−inlineToLaTeX (Math InlineMath str) = return $ char '$' <> text str <> char '$'
607−inlineToLaTeX (Math DisplayMath str) = return $ "\\[" <> text str <> "\\]"
613+inlineToLaTeX (Math InlineMath str) =
614+ return $ char '$' <> text (escapeMath str) <> char '$'
615+inlineToLaTeX (Math DisplayMath str) =
616+ return $ "\\[" <> text (escapeMath str) <> "\\]"
608617inlineToLaTeX (RawInline "latex" str) = return $ text str
609618inlineToLaTeX (RawInline "tex" str) = return $ text str
610619inlineToLaTeX (RawInline _ _) = return empty