LaTeX reader: peek at next token directly in peekTok.

peekTok went through lookAhead (satisfyTok (const True)), paying
for tokenPrim position bookkeeping, the raw-token state update, and
lookAhead state save/restore on every call; peekTok is used by the
main inline and block dispatchers for every element.  Just examine
the head of the input stream after expanding macros.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
John MacFarlane
2026-09-08 16:10:11 -07:00
co-authored by Claude
parent 0a46c96458
commit 4dcf5d5db3
+4 -1
View File
@@ -579,7 +579,10 @@ satisfyTok f = do
peekTok :: PandocMonad m => LP m Tok
peekTok = do
doMacros
lookAhead (satisfyTok (const True))
TokStream _ toks <- getInput
case toks of
t : _ -> return t
[] -> mzero
doMacros :: PandocMonad m => LP m ()
doMacros = do