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