git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: use applyMacros in rawLaTeXBlock, rawLaTeXInline.
commit3679d8d0bd0969d08142a2f6eb40b3a4bd0522d4 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 22 Dec 2017, 16:57 (9 years ago) parent9daf22f
1 file changed+5−2
src/Text/Pandoc/Readers/LaTeX.hs+5−2
src/Text/Pandoc/Readers/LaTeX.hs+5−2
@@ -270,13 +270,16 @@ rawLaTeXBlock :: (PandocMonad m, HasMacros s, HasReaderOptions s)
270270 => ParserT String s m String
271271rawLaTeXBlock = do
272272 lookAhead (try (char '\\' >> letter))
273− snd <$> rawLaTeXParser (environment <|> macroDef <|> blockCommand)
273+ -- we don't want to apply newly defined latex macros to their own
274+ -- definitions:
275+ (snd <$> rawLaTeXParser macroDef) <|>
276+ ((snd <$> rawLaTeXParser (environment <|> blockCommand)) >>= applyMacros)
274277
275278rawLaTeXInline :: (PandocMonad m, HasMacros s, HasReaderOptions s)
276279 => ParserT String s m String
277280rawLaTeXInline = do
278281 lookAhead (try (char '\\' >> letter) <|> char '$')
279− snd <$> rawLaTeXParser (inlineEnvironment <|> inlineCommand')
282+ rawLaTeXParser (inlineEnvironment <|> inlineCommand') >>= applyMacros . snd
280283
281284inlineCommand :: PandocMonad m => ParserT String ParserState m Inlines
282285inlineCommand = do