git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: more careful placement of withVerbatimMode.

for macros

commitd04ded4ca999e9488128e1b85e1566fca3ef3a48 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 15 Oct 2018, 11:59 (8 years ago) parent6f6ad05
1 file changed+16−14
src/Text/Pandoc/Readers/LaTeX.hs+16−14
src/Text/Pandoc/Readers/LaTeX.hs+16−14
@@ -1541,9 +1541,10 @@ newcommand = do
15411541 controlSeq "renewcommand" <|>
15421542 controlSeq "providecommand" <|>
15431543 controlSeq "DeclareRobustCommand"
1544− optional $ symbol '*'
1545− Tok _ (CtrlSeq name) txt <- withVerbatimMode $ anyControlSeq <|>
1546− (symbol '{' *> spaces *> anyControlSeq <* spaces <* symbol '}')
1544+ Tok _ (CtrlSeq name) txt <- withVerbatimMode $ do
1545+ optional (symbol '*')
1546+ anyControlSeq <|>
1547+ (symbol '{' *> spaces *> anyControlSeq <* spaces <* symbol '}')
15471548 spaces
15481549 numargs <- option 0 $ try bracketedNum
15491550 let argspecs = map (\i -> ArgNum i) [1..numargs]
@@ -1564,18 +1565,19 @@ newenvironment = do
15641565 Tok _ (CtrlSeq mtype) _ <- controlSeq "newenvironment" <|>
15651566 controlSeq "renewenvironment" <|>
15661567 controlSeq "provideenvironment"
1567− optional $ symbol '*'
1568− spaces
1569− name <- untokenize <$> braced
1570− spaces
1571− numargs <- option 0 $ try bracketedNum
1568+ name <- withVerbatimMode $ do
1569+ optional $ symbol '*'
1570+ spaces
1571+ untokenize <$> braced
1572+ numargs <- withVerbatimMode $ do
1573+ spaces
1574+ option 0 $ try bracketedNum
15721575 let argspecs = map (\i -> ArgNum i) [1..numargs]
1573− spaces
1574− optarg <- option Nothing $ Just <$> try bracketedToks
1575− spaces
1576− startcontents <- withVerbatimMode bracedOrToken
1577− spaces
1578− endcontents <- withVerbatimMode bracedOrToken
1576+ optarg <- withVerbatimMode $ do
1577+ spaces
1578+ option Nothing $ Just <$> try bracketedToks
1579+ startcontents <- withVerbatimMode $ spaces >> bracedOrToken
1580+ endcontents <- withVerbatimMode $ spaces >> bracedOrToken
15791581 when (mtype == "newenvironment") $ do
15801582 macros <- sMacros <$> getState
15811583 case M.lookup name macros of