mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-29 01:41:20 +08:00
Markdown reader: fix parsing of inline math ($...$) (#11348)
Do not allow blank lines before closing `$` delimiter. This brings the parser in line with the documentation. Closes #11311.
This commit is contained in:
committed by
John MacFarlane
parent
e8ed40ef01
commit
db9be758bc
@@ -42,7 +42,7 @@ mathInlineWith op cl = try $ do
|
||||
(try (string "text" >>
|
||||
(("\\text" <>) <$> inBalancedBraces 0 ""))
|
||||
<|> (\c -> T.pack ['\\',c]) <$> anyChar))
|
||||
<|> ("\n" <$ blankline <* notFollowedBy' blankline)
|
||||
<|> ("\n" <$ blankline <* notFollowedBy' blankline <* notFollowedBy (char '$'))
|
||||
<|> (T.pack <$> many1 spaceChar <* notFollowedBy (char '$'))
|
||||
) (try $ textStr cl)
|
||||
notFollowedBy digit -- to prevent capture of $5
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
```
|
||||
% pandoc -f markdown -t native
|
||||
$ invalid opening inline math$
|
||||
|
||||
$
|
||||
invalid opening inline math$
|
||||
|
||||
$invalid closing inline math $
|
||||
|
||||
$invalid closing inline math
|
||||
$
|
||||
|
||||
$valid inline math$
|
||||
^D
|
||||
[ Para
|
||||
[ Str "$"
|
||||
, Space
|
||||
, Str "invalid"
|
||||
, Space
|
||||
, Str "opening"
|
||||
, Space
|
||||
, Str "inline"
|
||||
, Space
|
||||
, Str "math$"
|
||||
]
|
||||
, Para
|
||||
[ Str "$"
|
||||
, SoftBreak
|
||||
, Str "invalid"
|
||||
, Space
|
||||
, Str "opening"
|
||||
, Space
|
||||
, Str "inline"
|
||||
, Space
|
||||
, Str "math$"
|
||||
]
|
||||
, Para
|
||||
[ Str "$invalid"
|
||||
, Space
|
||||
, Str "closing"
|
||||
, Space
|
||||
, Str "inline"
|
||||
, Space
|
||||
, Str "math"
|
||||
, Space
|
||||
, Str "$"
|
||||
]
|
||||
, Para
|
||||
[ Str "$invalid"
|
||||
, Space
|
||||
, Str "closing"
|
||||
, Space
|
||||
, Str "inline"
|
||||
, Space
|
||||
, Str "math"
|
||||
, SoftBreak
|
||||
, Str "$"
|
||||
]
|
||||
, Para [ Math InlineMath "valid inline math" ]
|
||||
]
|
||||
```
|
||||
Reference in New Issue
Block a user