summaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2011-01-05 14:42:47 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2011-01-05 14:42:47 -0800
commiteb83f0e5e40a1a0846085fccb2f72ce2b7cc60f0 (patch)
tree5458db89d6670e7a0dcc347e871098e72bf716a6 /src/Text
parente126ab9efcec79850c217b979fd295a6730bfa6c (diff)
Fixed macro parsing.
Diffstat (limited to 'src/Text')
-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