LaTeX reader: properly handle optional arguments for macros.
Closes #5682.
commit5e708eb8ce4bb4325b009ac37a5986517d6b9290
authorJohn MacFarlane <jgm@berkeley.edu>
dateMon 2 Sep 2019, 18:48 (7 years ago)
parent3fac27b
src/Text/Pandoc/Readers/LaTeX.hs+1−1
@@ -1591,7 +1591,7 @@ newcommand = do
15911591 (symbol '{' *> spaces *> anyControlSeq <* spaces <* symbol '}')
15921592 spaces
15931593 numargs <- option 0 $ try bracketedNum
1594− let argspecs = map (\i -> ArgNum i) [1..numargs]
1594+ let argspecs = map ArgNum [1..numargs]
15951595 spaces
15961596 optarg <- option Nothing $ Just <$> try bracketedToks
15971597 spaces
src/Text/Pandoc/Readers/LaTeX/Parsing.hs+1−1
@@ -448,7 +448,7 @@ doMacros' n inp = do
448448 Nothing -> getargs M.empty argspecs
449449 Just o -> do
450450 x <- option o bracketedToks
451− getargs (M.singleton 1 x) argspecs
451+ getargs (M.singleton 1 x) $ drop 1 argspecs
452452 rest <- getInput
453453 return (args, rest)
454454 lstate <- getState
test/command/5682.mdnew file+8
@@ -0,0 +1,8 @@
1+```
2+% pandoc -t native -f latex
3+\newcommand{\ittakestwo}[2][defaultone]{#2}
4+\ittakestwo[to]{tango}
5+^D
6+[Para [Str "tango"]]
7+```
8+