diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-10-30 11:35:40 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-10-30 11:35:40 -0700 |
commit | 272b833ad55c6705e44703d1d38b07548f017ecf (patch) | |
tree | fb8af3d71e1116d70201f16b942652379159519b /src/Text/Pandoc | |
parent | 244b42dbaf81b45a1e6d95ca4f2203ea4c2a98cd (diff) | |
download | pandoc-272b833ad55c6705e44703d1d38b07548f017ecf.tar.gz |
Allow unbraced arguments for macros.
See #4007.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 0664a94aa..407952a54 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -430,7 +430,7 @@ doMacros n = do Nothing -> return () Just (Macro expansionPoint numargs optarg newtoks) -> do setInput ts - let getarg = spaces >> braced + let getarg = try $ spaces >> bracedOrToken args <- case optarg of Nothing -> count numargs getarg Just o -> @@ -1824,7 +1824,7 @@ letmacro = do Tok _ (CtrlSeq name) _ <- anyControlSeq optional $ symbol '=' spaces - contents <- macroContents + contents <- bracedOrToken return (name, Macro ExpandWhenDefined 0 Nothing contents) defmacro :: PandocMonad m => LP m (Text, Macro) @@ -1834,7 +1834,7 @@ defmacro = try $ do numargs <- option 0 $ argSeq 1 -- we use withVerbatimMode, because macros are to be expanded -- at point of use, not point of definition - contents <- withVerbatimMode macroContents + contents <- withVerbatimMode bracedOrToken return (name, Macro ExpandWhenUsed numargs Nothing contents) -- Note: we don't yet support fancy things like #1.#2 @@ -1848,8 +1848,8 @@ isArgTok :: Tok -> Bool isArgTok (Tok _ (Arg _) _) = True isArgTok _ = False -macroContents :: PandocMonad m => LP m [Tok] -macroContents = braced <|> ((:[]) <$> (anyControlSeq <|> singleChar)) +bracedOrToken :: PandocMonad m => LP m [Tok] +bracedOrToken = braced <|> ((:[]) <$> (anyControlSeq <|> singleChar)) newcommand :: PandocMonad m => LP m (Text, Macro) newcommand = do @@ -1866,7 +1866,7 @@ newcommand = do spaces optarg <- option Nothing $ Just <$> try bracketedToks spaces - contents <- withVerbatimMode macroContents + contents <- withVerbatimMode bracedOrToken when (mtype == "newcommand") $ do macros <- sMacros <$> getState case M.lookup name macros of @@ -1888,9 +1888,9 @@ newenvironment = do spaces optarg <- option Nothing $ Just <$> try bracketedToks spaces - startcontents <- withVerbatimMode macroContents + startcontents <- withVerbatimMode bracedOrToken spaces - endcontents <- withVerbatimMode macroContents + endcontents <- withVerbatimMode bracedOrToken when (mtype == "newenvironment") $ do macros <- sMacros <$> getState case M.lookup name macros of |