git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: properly handle optional arguments for macros.
5e708ebJohn MacFarlane
src/Text/Pandoc/Readers/LaTeX.hs+1−1
@@ -1591,7 +1591,7 @@ newcommand = do
1591 (symbol '{' *> spaces *> anyControlSeq <* spaces <* symbol '}')
1591 (symbol '{' *> spaces *> anyControlSeq <* spaces <* symbol '}')
1592 spaces
1592 spaces
1593 numargs <- option 0 $ try bracketedNum
1593 numargs <- option 0 $ try bracketedNum
1594− let argspecs = map (\i -> ArgNum i) [1..numargs]
1594+ let argspecs = map ArgNum [1..numargs]
1595 spaces
1595 spaces
1596 optarg <- option Nothing $ Just <$> try bracketedToks
1596 optarg <- option Nothing $ Just <$> try bracketedToks
1597 spaces
1597 spaces
src/Text/Pandoc/Readers/LaTeX/Parsing.hs+1−1
@@ -448,7 +448,7 @@ doMacros' n inp = do
448 Nothing -> getargs M.empty argspecs
448 Nothing -> getargs M.empty argspecs
449 Just o -> do
449 Just o -> do
450 x <- option o bracketedToks
450 x <- option o bracketedToks
451− getargs (M.singleton 1 x) argspecs
451+ getargs (M.singleton 1 x) $ drop 1 argspecs
452 rest <- getInput
452 rest <- getInput
453 return (args, rest)
453 return (args, rest)
454 lstate <- getState
454 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+