mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-26 17:35:49 +00:00
Fixed macro parsing.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user