summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Parsing.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-05-27 11:59:28 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2014-05-27 11:59:28 -0700
commit2e80613451651ec8f1945daa7540168a427f0507 (patch)
treef7f7c5cbc33fb415402ab74e92138d260b534341 /src/Text/Pandoc/Parsing.hs
parentfd11a5a5eb51d54f0d3ee91e859a63854f465971 (diff)
Markdown reader: inline math must have nonspace before final `$`.
Closes #1313.
Diffstat (limited to 'src/Text/Pandoc/Parsing.hs')
-rw-r--r--src/Text/Pandoc/Parsing.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index 4cd6591c0..8bc042e28 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -464,11 +464,13 @@ mathInlineWith :: String -> String -> Parser [Char] st String
mathInlineWith op cl = try $ do
string op
notFollowedBy space
- words' <- many1Till (count 1 (noneOf "\n\\")
+ words' <- many1Till (count 1 (noneOf " \t\n\\")
<|> (char '\\' >> anyChar >>= \c -> return ['\\',c])
- <|> count 1 newline <* notFollowedBy' blankline
- *> return " ")
- (try $ string cl)
+ <|> do (blankline <* notFollowedBy' blankline) <|>
+ (oneOf " \t" <* skipMany (oneOf " \t"))
+ notFollowedBy (char '$')
+ return " "
+ ) (try $ string cl)
notFollowedBy digit -- to prevent capture of $5
return $ concat words'