aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-10-15 17:28:37 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-10-15 17:28:37 -0700
commit85394d403464f25db2ffd586dcc9893fc984877c (patch)
treeb7415e242edd22a8b9c685044daac0d4b1bc9b9e /src/Text
parent252398a4f3c33cff4a0407e749cf3abebca7654f (diff)
downloadpandoc-85394d403464f25db2ffd586dcc9893fc984877c.tar.gz
LaTeX reader: small verbatim mode cleanups.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 543ebec5a..26ac781db 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -1525,11 +1525,11 @@ defmacro = try $
argspecArg :: PandocMonad m => LP m ArgSpec
argspecArg = do
- Tok _ (Arg i) _ <- withVerbatimMode $ satisfyTok isArgTok
+ Tok _ (Arg i) _ <- satisfyTok isArgTok
return $ ArgNum i
argspecPattern :: PandocMonad m => LP m ArgSpec
-argspecPattern = withVerbatimMode $
+argspecPattern =
Pattern <$> many1 (satisfyTok (\(Tok _ toktype' txt) ->
(toktype' == Symbol || toktype' == Word) &&
(txt /= "{" && txt /= "\\" && txt /= "}")))
@@ -1566,25 +1566,23 @@ newenvironment = do
Tok _ (CtrlSeq mtype) _ <- controlSeq "newenvironment" <|>
controlSeq "renewenvironment" <|>
controlSeq "provideenvironment"
- name <- withVerbatimMode $ do
+ withVerbatimMode $ do
optional $ symbol '*'
spaces
- untokenize <$> braced
- numargs <- withVerbatimMode $ do
+ name <- untokenize <$> braced
spaces
- option 0 $ try bracketedNum
- let argspecs = map (\i -> ArgNum i) [1..numargs]
- optarg <- withVerbatimMode $ do
+ numargs <- option 0 $ try bracketedNum
spaces
- option Nothing $ Just <$> try bracketedToks
- startcontents <- withVerbatimMode $ spaces >> bracedOrToken
- endcontents <- withVerbatimMode $ spaces >> bracedOrToken
- when (mtype == "newenvironment") $ do
- macros <- sMacros <$> getState
- case M.lookup name macros of
- Just _ -> report $ MacroAlreadyDefined (T.unpack name) pos
- Nothing -> return ()
- return (name, Macro ExpandWhenUsed argspecs optarg startcontents,
+ optarg <- option Nothing $ Just <$> try bracketedToks
+ let argspecs = map (\i -> ArgNum i) [1..numargs]
+ startcontents <- spaces >> bracedOrToken
+ endcontents <- spaces >> bracedOrToken
+ when (mtype == "newenvironment") $ do
+ macros <- sMacros <$> getState
+ case M.lookup name macros of
+ Just _ -> report $ MacroAlreadyDefined (T.unpack name) pos
+ Nothing -> return ()
+ return (name, Macro ExpandWhenUsed argspecs optarg startcontents,
Macro ExpandWhenUsed [] Nothing endcontents)
bracketedNum :: PandocMonad m => LP m Int