@@ -1541,9 +1541,10 @@ newcommand = do
1541 controlSeq "renewcommand" <|>
1541 controlSeq "renewcommand" <|>
1542 controlSeq "providecommand" <|>
1542 controlSeq "providecommand" <|>
1543 controlSeq "DeclareRobustCommand"
1543 controlSeq "DeclareRobustCommand"
1544− optional $ symbol '*'
1545− Tok _ (CtrlSeq name) txt <- withVerbatimMode $ anyControlSeq <|>
1544+ Tok _ (CtrlSeq name) txt <- withVerbatimMode $ do
1545+ optional (symbol '*')
1546− (symbol '{' *> spaces *> anyControlSeq <* spaces <* symbol '}')
1547+ (symbol '{' *> spaces *> anyControlSeq <* spaces <* symbol '}')
1548 numargs <- option 0 $ try bracketedNum
1549 numargs <- option 0 $ try bracketedNum
1549 let argspecs = map (\i -> ArgNum i) [1..numargs]
1550 let argspecs = map (\i -> ArgNum i) [1..numargs]
@@ -1564,18 +1565,19 @@ newenvironment = do
1564 Tok _ (CtrlSeq mtype) _ <- controlSeq "newenvironment" <|>
1565 Tok _ (CtrlSeq mtype) _ <- controlSeq "newenvironment" <|>
1565 controlSeq "renewenvironment" <|>
1566 controlSeq "renewenvironment" <|>
1566 controlSeq "provideenvironment"
1567 controlSeq "provideenvironment"
1568+ name <- withVerbatimMode $ do
1567− optional $ symbol '*'
1569+ optional $ symbol '*'
1569− name <- untokenize <$> braced
1571+ untokenize <$> braced
1570− spaces
1572+ numargs <- withVerbatimMode $ do
1571− numargs <- option 0 $ try bracketedNum
1574+ option 0 $ try bracketedNum
1572 let argspecs = map (\i -> ArgNum i) [1..numargs]
1575 let argspecs = map (\i -> ArgNum i) [1..numargs]
1573− spaces
1576+ optarg <- withVerbatimMode $ do
1574− optarg <- option Nothing $ Just <$> try bracketedToks
1578+ option Nothing $ Just <$> try bracketedToks
1576− startcontents <- withVerbatimMode bracedOrToken
1579+ startcontents <- withVerbatimMode $ spaces >> bracedOrToken
1578− endcontents <- withVerbatimMode bracedOrToken
1580+ endcontents <- withVerbatimMode $ spaces >> bracedOrToken
1579 when (mtype == "newenvironment") $ do
1581 when (mtype == "newenvironment") $ do
1580 macros <- sMacros <$> getState
1582 macros <- sMacros <$> getState
1581 case M.lookup name macros of
1583 case M.lookup name macros of