git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: inline math must have nonspace before final `$`.

Closes #1313.

commit2e80613451651ec8f1945daa7540168a427f0507 authorJohn MacFarlane <jgm@berkeley.edu> dateTue 27 May 2014, 11:59 (12 years ago) parentfd11a5a
3 files changed+12−4
src/Text/Pandoc/Parsing.hs+6−4 tests/markdown-reader-more.native+2 tests/markdown-reader-more.txt+4
src/Text/Pandoc/Parsing.hs+6−4
@@ -464,11 +464,13 @@ mathInlineWith :: String -> String -> Parser [Char] st String
464464mathInlineWith op cl = try $ do
465465 string op
466466 notFollowedBy space
467− words' <- many1Till (count 1 (noneOf "\n\\")
467+ words' <- many1Till (count 1 (noneOf " \t\n\\")
468468 <|> (char '\\' >> anyChar >>= \c -> return ['\\',c])
469− <|> count 1 newline <* notFollowedBy' blankline
470− *> return " ")
471− (try $ string cl)
469+ <|> do (blankline <* notFollowedBy' blankline) <|>
470+ (oneOf " \t" <* skipMany (oneOf " \t"))
471+ notFollowedBy (char '$')
472+ return " "
473+ ) (try $ string cl)
472474 notFollowedBy digit -- to prevent capture of $5
473475 return $ concat words'
474476
tests/markdown-reader-more.native+2
@@ -16,6 +16,8 @@
1616,Header 3 ("my-header",[],[]) [Str "my",Space,Str "header"]
1717,Header 2 ("in-math",[],[]) [Str "$",Space,Str "in",Space,Str "math"]
1818,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"]
1921,Header 2 ("commented-out-list-item",[],[]) [Str "Commented-out",Space,Str "list",Space,Str "item"]
2022,BulletList
2123 [[Plain [Str "one",Space,RawInline (Format "html") "<!--\n- two\n-->"]]
tests/markdown-reader-more.txt+4
@@ -58,6 +58,10 @@
5858
5959$\$2 + \$3$
6060
61+This should not be math:
62+
63+$PATH 90 $PATH
64+
6165## Commented-out list item
6266
6367- one