aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-11-02 12:44:48 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-11-02 12:44:48 -0700
commit65593043c33b97f55170a53eb330d7ce069774cd (patch)
tree7b2a6f1db45292e622b514e9d196a19339af7a62 /src
parentf39c44f0badc832acfd3fcb317940b4aafa26e20 (diff)
downloadpandoc-65593043c33b97f55170a53eb330d7ce069774cd.tar.gz
LaTeX reader: Fixed dollar-math parsing...
...to ensure that space is left between a control seq and a following word that would otherwise change its meaning. Closes #5836.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 94fd9427b..be19964a4 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -629,28 +629,28 @@ dollarsMath :: PandocMonad m => LP m Inlines
dollarsMath = do
symbol '$'
display <- option False (True <$ symbol '$')
- (do contents <- try $ T.unpack <$> pDollarsMath 0
+ (do contents <- try $ T.unpack . untokenize <$> pDollarsMath 0
if display
then (mathDisplay contents <$ symbol '$')
else return $ mathInline contents)
<|> (guard display >> return (mathInline ""))
-- Int is number of embedded groupings
-pDollarsMath :: PandocMonad m => Int -> LP m Text
+pDollarsMath :: PandocMonad m => Int -> LP m [Tok]
pDollarsMath n = do
- Tok _ toktype t <- anyTok
+ tk@(Tok _ toktype t) <- anyTok
case toktype of
Symbol | t == "$"
- , n == 0 -> return mempty
+ , n == 0 -> return []
| t == "\\" -> do
- Tok _ _ t' <- anyTok
- return (t <> t')
- | t == "{" -> (t <>) <$> pDollarsMath (n+1)
+ tk' <- anyTok
+ ((tk :) . (tk' :)) <$> pDollarsMath n
+ | t == "{" -> (tk :) <$> pDollarsMath (n+1)
| t == "}" ->
if n > 0
- then (t <>) <$> pDollarsMath (n-1)
+ then (tk :) <$> pDollarsMath (n-1)
else mzero
- _ -> (t <>) <$> pDollarsMath n
+ _ -> (tk :) <$> pDollarsMath n
-- citations