summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Parsing.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-03-10 10:12:51 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2017-03-10 10:12:51 +0100
commit21ae5db20cd78d814d375f6e2be48e506e4a24da (patch)
tree6307e2fc7ab192b529cd7971dd7620c997f26493 /src/Text/Pandoc/Parsing.hs
parentc46febaaeef1c203f5bbb88d845ad5554622f609 (diff)
Use pMacroDefinition in macro (for more direct parsing).
This is newly exported in texmath 0.9.3. Note that this means that `macro` will now parse one macro at a time, rather than parsing a whole group together.
Diffstat (limited to 'src/Text/Pandoc/Parsing.hs')
-rw-r--r--src/Text/Pandoc/Parsing.hs21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/Text/Pandoc/Parsing.hs b/src/Text/Pandoc/Parsing.hs
index 46dc22112..b207e79e0 100644
--- a/src/Text/Pandoc/Parsing.hs
+++ b/src/Text/Pandoc/Parsing.hs
@@ -186,8 +186,7 @@ import Data.Char ( toLower, toUpper, ord, chr, isAscii, isAlphaNum,
import Data.List ( intercalate, transpose, isSuffixOf )
import Text.Pandoc.Shared
import qualified Data.Map as M
-import Text.TeXMath.Readers.TeX.Macros (applyMacros, Macro,
- parseMacroDefinitions)
+import Text.TeXMath.Readers.TeX.Macros (applyMacros, Macro, pMacroDefinition)
import Text.HTML.TagSoup.Entity ( lookupEntity )
import Text.Pandoc.Asciify (toAsciiChar)
import Data.Monoid ((<>))
@@ -1263,21 +1262,17 @@ token pp pos match = tokenPrim pp (\_ t _ -> pos t) match
-- Macros
--
--- | Parse a \newcommand or \renewcommand macro definition.
+-- | Parse a \newcommand or \newenviroment macro definition.
macro :: (Stream [Char] m Char, HasMacros st, HasReaderOptions st)
=> ParserT [Char] st m Blocks
macro = do
apply <- getOption readerApplyMacros
- inp <- getInput
- case parseMacroDefinitions inp of
- ([], _) -> mzero
- (ms, rest) -> do def' <- count (length inp - length rest) anyChar
- if apply
- then do
- updateState $ \st ->
- updateMacros (ms ++) st
- return mempty
- else return $ rawBlock "latex" def'
+ (m, def') <- withRaw pMacroDefinition
+ if apply
+ then do
+ updateState $ \st -> updateMacros (m:) st
+ return mempty
+ else return $ rawBlock "latex" def'
-- | Apply current macros to string.
applyMacros' :: (HasReaderOptions st, HasMacros st, Stream [Char] m Char)