aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2025-11-04 14:30:05 +0100
committerJohn MacFarlane <[email protected]>2025-11-04 14:30:05 +0100
commit814bdbdbef0075f056667c368901856c7fd311da (patch)
tree0709de5465d48fce4c266c100356ae61ca8f6c65 /src
parent69479fa49086dae60910fa8cc2d3d658fa95bb43 (diff)
Better handling of `\makeatletter` in parsing raw LaTeX.
Closes #11270.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 11419b15f..f12c73d7b 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -144,7 +144,8 @@ rawLaTeXBlock = do
toks <- getInputTokens
snd <$> (
rawLaTeXParser toks
- (macroDef (const mempty) <|>
+ (makeAtLetterSection <|>
+ macroDef (const mempty) <|>
do choice (map controlSeq
["include", "input", "subfile", "usepackage"])
skipMany opt
@@ -154,6 +155,17 @@ rawLaTeXBlock = do
(void (environment <|> blockCommand))
(mconcat <$> many (block <|> beginOrEndCommand)))
+makeAtLetterSection :: PandocMonad m => LP m ()
+makeAtLetterSection = try $ do
+ controlSeq "makeatletter"
+ void $ manyTill
+ ( whitespace
+ <|> newlineTok
+ <|> macroDef (const ())
+ <|> void environment
+ <|> void blockCommand
+ ) (controlSeq "makeatother")
+
-- See #4667 for motivation; sometimes people write macros
-- that just evaluate to a begin or end command, which blockCommand
-- won't accept.