summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2012-06-29 18:30:22 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2012-06-29 18:30:53 -0700
commit9d5230c0f699b1cc575eb211df9f016c41b6ba11 (patch)
treec4749016d2f1fe7e68d72e25567a46e6779c5ee4
parent11aea4bd3f4bbf4f6e434a64f6a7e49713f0ba6a (diff)
Changed macro parser so it returns raw macro if stateApplyMacros false.
Closes #554.
-rw-r--r--src/Text/Pandoc/Parsing.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index 140b96cfa..cac2b71ca 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -868,14 +868,17 @@ emDashOld = do
-- | Parse a \newcommand or \renewcommand macro definition.
macro :: GenParser Char ParserState Block
macro = do
- getState >>= guard . stateApplyMacros
+ apply <- stateApplyMacros `fmap` getState
inp <- getInput
case parseMacroDefinitions inp of
([], _) -> pzero
- (ms, rest) -> do count (length inp - length rest) anyChar
- updateState $ \st ->
- st { stateMacros = ms ++ stateMacros st }
- return Null
+ (ms, rest) -> do def <- count (length inp - length rest) anyChar
+ if apply
+ then do
+ updateState $ \st ->
+ st { stateMacros = ms ++ stateMacros st }
+ return Null
+ else return $ RawBlock "latex" def
-- | Apply current macros to string.
applyMacros' :: String -> GenParser Char ParserState String