summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2023-11-15 10:06:22 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2023-11-15 10:06:22 -0800
commitcd48bf40597e99bec6419a9a0b49fef46330d56c (patch)
tree06d4e8c22fcd70e3190849139d2b22669f50f758 /src
parent0283cdc200b7ee44d3abdcc7061c47473ed9fd92 (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.hs8
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'