Fixed macro parsing.

This commit is contained in:
John MacFarlane
2011-01-05 14:42:47 -08:00
parent e126ab9efc
commit eb83f0e5e4
+10 -8
View File
@@ -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