From 22863a3e124215e6fd24efe55a5a99fb2d605e5b Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 4 Nov 2025 14:02:25 +0100 Subject: Improve parsing of raw LaTeX blocks... containing macro definitions with `\makeatletter` and `\makeatother`. Closes #9953, see also #11270. --- src/Text/Pandoc/Readers/LaTeX.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 11419b15f..32195d859 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -144,12 +144,17 @@ rawLaTeXBlock = do toks <- getInputTokens snd <$> ( rawLaTeXParser toks - (macroDef (const mempty) <|> + (skipMany1 (try + (skipMany (whitespace <|> newlineTok) + *> (macroDef (const ()) + <|> void (controlSeq "makeatletter" <|> + controlSeq "mateatother"))) + <|> do choice (map controlSeq ["include", "input", "subfile", "usepackage"]) skipMany opt braced - return mempty) blocks + return mempty)) blocks <|> rawLaTeXParser toks (void (environment <|> blockCommand)) (mconcat <$> many (block <|> beginOrEndCommand))) -- cgit v1.2.3