git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: inline math must have nonspace before final `$`.
2e80613John MacFarlane
src/Text/Pandoc/Parsing.hs+6−4
@@ -464,11 +464,13 @@ mathInlineWith :: String -> String -> Parser [Char] st String
464mathInlineWith op cl = try $ do
464mathInlineWith op cl = try $ do
465 string op
465 string op
466 notFollowedBy space
466 notFollowedBy space
467− words' <- many1Till (count 1 (noneOf "\n\\")
467+ words' <- many1Till (count 1 (noneOf " \t\n\\")
468 <|> (char '\\' >> anyChar >>= \c -> return ['\\',c])
468 <|> (char '\\' >> anyChar >>= \c -> return ['\\',c])
469− <|> count 1 newline <* notFollowedBy' blankline
469+ <|> do (blankline <* notFollowedBy' blankline) <|>
470+ (oneOf " \t" <* skipMany (oneOf " \t"))
471+ notFollowedBy (char '$')
470− *> return " ")
472+ return " "
471− (try $ string cl)
473+ ) (try $ string cl)
472 notFollowedBy digit -- to prevent capture of $5
474 notFollowedBy digit -- to prevent capture of $5
473 return $ concat words'
475 return $ concat words'
474
476
tests/markdown-reader-more.native+2
@@ -16,6 +16,8 @@
16,Header 3 ("my-header",[],[]) [Str "my",Space,Str "header"]
16,Header 3 ("my-header",[],[]) [Str "my",Space,Str "header"]
17,Header 2 ("in-math",[],[]) [Str "$",Space,Str "in",Space,Str "math"]
17,Header 2 ("in-math",[],[]) [Str "$",Space,Str "in",Space,Str "math"]
18,Para [Math InlineMath "\\$2 + \\$3"]
18,Para [Math InlineMath "\\$2 + \\$3"]
19+,Para [Str "This",Space,Str "should",Space,Str "not",Space,Str "be",Space,Str "math:"]
20+,Para [Str "$PATH",Space,Str "90",Space,Str "$PATH"]
19,Header 2 ("commented-out-list-item",[],[]) [Str "Commented-out",Space,Str "list",Space,Str "item"]
21,Header 2 ("commented-out-list-item",[],[]) [Str "Commented-out",Space,Str "list",Space,Str "item"]
20,BulletList
22,BulletList
21 [[Plain [Str "one",Space,RawInline (Format "html") "<!--\n- two\n-->"]]
23 [[Plain [Str "one",Space,RawInline (Format "html") "<!--\n- two\n-->"]]
tests/markdown-reader-more.txt+4
@@ -58,6 +58,10 @@
58
58
59$\$2 + \$3$
59$\$2 + \$3$
60
60
61+This should not be math:
62+
63+$PATH 90 $PATH
64+
61## Commented-out list item
65## Commented-out list item
62
66
63- one
67- one