From 9d5230c0f699b1cc575eb211df9f016c41b6ba11 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Fri, 29 Jun 2012 18:30:22 -0700 Subject: Changed macro parser so it returns raw macro if stateApplyMacros false. Closes #554. --- src/Text/Pandoc/Parsing.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/Text/Pandoc') 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 -- cgit v1.2.3