diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-10-15 11:59:05 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-10-15 11:59:05 -0700 |
commit | d04ded4ca999e9488128e1b85e1566fca3ef3a48 (patch) | |
tree | ce9858a09187f3e893b0365121f121f0d6c4b588 | |
parent | 6f6ad0514d7c5ec6f7177beecb4f2d5ef80100ae (diff) | |
download | pandoc-d04ded4ca999e9488128e1b85e1566fca3ef3a48.tar.gz |
LaTeX reader: more careful placement of withVerbatimMode.
for macros
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 9e419793d..b292e9b8d 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -1541,9 +1541,10 @@ newcommand = do controlSeq "renewcommand" <|> controlSeq "providecommand" <|> controlSeq "DeclareRobustCommand" - optional $ symbol '*' - Tok _ (CtrlSeq name) txt <- withVerbatimMode $ anyControlSeq <|> - (symbol '{' *> spaces *> anyControlSeq <* spaces <* symbol '}') + Tok _ (CtrlSeq name) txt <- withVerbatimMode $ do + optional (symbol '*') + anyControlSeq <|> + (symbol '{' *> spaces *> anyControlSeq <* spaces <* symbol '}') spaces numargs <- option 0 $ try bracketedNum let argspecs = map (\i -> ArgNum i) [1..numargs] @@ -1564,18 +1565,19 @@ newenvironment = do Tok _ (CtrlSeq mtype) _ <- controlSeq "newenvironment" <|> controlSeq "renewenvironment" <|> controlSeq "provideenvironment" - optional $ symbol '*' - spaces - name <- untokenize <$> braced - spaces - numargs <- option 0 $ try bracketedNum + name <- withVerbatimMode $ do + optional $ symbol '*' + spaces + untokenize <$> braced + numargs <- withVerbatimMode $ do + spaces + option 0 $ try bracketedNum let argspecs = map (\i -> ArgNum i) [1..numargs] - spaces - optarg <- option Nothing $ Just <$> try bracketedToks - spaces - startcontents <- withVerbatimMode bracedOrToken - spaces - endcontents <- withVerbatimMode bracedOrToken + optarg <- withVerbatimMode $ do + spaces + option Nothing $ Just <$> try bracketedToks + startcontents <- withVerbatimMode $ spaces >> bracedOrToken + endcontents <- withVerbatimMode $ spaces >> bracedOrToken when (mtype == "newenvironment") $ do macros <- sMacros <$> getState case M.lookup name macros of |