summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Parsing.hs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index bcdb053c4..05d644a4b 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -84,7 +84,7 @@ import Network.URI ( parseURI, URI (..), isAllowedInURI )
import Control.Monad ( join, liftM, guard )
import Text.Pandoc.Shared
import qualified Data.Map as M
-import Text.TeXMath.Macros (applyMacros, Macro, pMacroDefinition)
+import Text.TeXMath.Macros (applyMacros, Macro, parseMacroDefinitions)
-- | Like >>, but returns the operation on the left.
-- (Suggested by Tillmann Rendel on Haskell-cafe list.)
@@ -789,13 +789,15 @@ emDash = do
-- | Parse a \newcommand or \renewcommand macro definition.
macro :: GenParser Char ParserState Block
-macro = getState >>= guard . stateApplyMacros >>
- pMacroDefinition >>= addMacro >> blanklines >> return Null
-
--- | Add a macro to the list of macros in state.
-addMacro :: Macro -> GenParser Char ParserState ()
-addMacro m = do
- updateState $ \st -> st{ stateMacros = m : stateMacros st }
+macro = do
+ getState >>= guard . stateApplyMacros
+ 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
-- | Apply current macros to string.
applyMacros' :: String -> GenParser Char ParserState String