@@ -84,7 +84,7 @@ import Network.URI ( parseURI, URI (..), isAllowedInURI )
8484import Control.Monad ( join, liftM, guard )
8585import Text.Pandoc.Shared
8686import qualified Data.Map as M
87−import Text.TeXMath.Macros (applyMacros, Macro, pMacroDefinition)
87+import Text.TeXMath.Macros (applyMacros, Macro, parseMacroDefinitions)
8888
8989-- | Like >>, but returns the operation on the left.
9090-- (Suggested by Tillmann Rendel on Haskell-cafe list.)
@@ -789,13 +789,15 @@ emDash = do
789789
790790-- | Parse a \newcommand or \renewcommand macro definition.
791791macro :: GenParser Char ParserState Block
792−macro = getState >>= guard . stateApplyMacros >>
793− pMacroDefinition >>= addMacro >> blanklines >> return Null
794−
795−-- | Add a macro to the list of macros in state.
796−addMacro :: Macro -> GenParser Char ParserState ()
797−addMacro m = do
798− updateState $ \st -> st{ stateMacros = m : stateMacros st }
792+macro = do
793+ getState >>= guard . stateApplyMacros
794+ inp <- getInput
795+ case parseMacroDefinitions inp of
796+ ([], _) -> pzero
797+ (ms, rest) -> do count (length inp - length rest) anyChar
798+ updateState $ \st ->
799+ st { stateMacros = ms ++ stateMacros st }
800+ return Null
799801
800802-- | Apply current macros to string.
801803applyMacros' :: String -> GenParser Char ParserState String