aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2012-02-07 19:40:26 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2012-02-07 19:41:37 -0800
commit328c91e3071f34f798f472661469b561468713ed (patch)
treeafef77cf064ead00077d29856e42c7db4688f597
parent9538328c6b483041de8a8e610ba9bf94a6600c2f (diff)
downloadpandoc-328c91e3071f34f798f472661469b561468713ed.tar.gz
Handle escaped $ in latex math. Closes #186.
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index fb0bc34e8..2240a008d 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -136,6 +136,12 @@ mathDisplay p = displayMath <$> (try p >>= applyMacros' . trim)
mathInline :: LP String -> LP Inlines
mathInline p = math <$> (try p >>= applyMacros')
+mathChars :: LP String
+mathChars = concat <$>
+ many ( many1 (satisfy (\c -> c /= '$' && c /='\\'))
+ <|> (\c -> ['\\',c]) <$> (try $ char '\\' *> anyChar)
+ )
+
double_quote :: LP Inlines
double_quote = (doubleQuoted . mconcat) <$>
(try $ string "``" *> manyTill inline (try $ string "''"))
@@ -158,8 +164,8 @@ inline = (mempty <$ comment)
<|> single_quote
<|> (str "’" <$ char '\'')
<|> (str "\160" <$ char '~')
- <|> (mathDisplay $ string "$$" *> manyTill anyChar (try $ string "$$"))
- <|> (mathInline $ char '$' *> manyTill anyChar (char '$'))
+ <|> (mathDisplay $ string "$$" *> mathChars <* string "$$")
+ <|> (mathInline $ char '$' *> mathChars <* char '$')
<|> (superscript <$> (char '^' *> tok))
<|> (subscript <$> (char '_' *> tok))
<|> (failUnlessLHS *> char '|' *> doLHSverb)