diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2023-11-15 10:06:22 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2023-11-15 10:06:22 -0800 |
| commit | cd48bf40597e99bec6419a9a0b49fef46330d56c (patch) | |
| tree | 06d4e8c22fcd70e3190849139d2b22669f50f758 /src | |
| parent | 0283cdc200b7ee44d3abdcc7061c47473ed9fd92 (diff) | |
Markdown reader: don't change newlines to spaces in math.
Preserve them: otherwise we can get unwanted results if there's
a `%` comment. Closes #9193.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Text/Pandoc/Parsing/Math.hs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Parsing/Math.hs b/src/Text/Pandoc/Parsing/Math.hs index 0be9ac3d6..73ae1e0c2 100644 --- a/src/Text/Pandoc/Parsing/Math.hs +++ b/src/Text/Pandoc/Parsing/Math.hs @@ -17,7 +17,7 @@ where import Control.Monad (mzero, when) import Data.Text (Text) -import Text.Parsec ((<|>), ParsecT, Stream(..), notFollowedBy, skipMany, try) +import Text.Parsec ((<|>), ParsecT, Stream(..), notFollowedBy, many1, try) import Text.Pandoc.Options ( Extension(Ext_tex_math_dollars, Ext_tex_math_single_backslash, Ext_tex_math_double_backslash) ) @@ -42,10 +42,8 @@ mathInlineWith op cl = try $ do (try (string "text" >> (("\\text" <>) <$> inBalancedBraces 0 "")) <|> (\c -> T.pack ['\\',c]) <$> anyChar)) - <|> do (blankline <* notFollowedBy' blankline) <|> - (spaceChar <* skipMany spaceChar) - notFollowedBy (char '$') - return " " + <|> ("\n" <$ blankline <* notFollowedBy' blankline) + <|> (T.pack <$> many1 spaceChar <* notFollowedBy (char '$')) ) (try $ textStr cl) notFollowedBy digit -- to prevent capture of $5 return $ trimMath $ T.concat words' |
