blefloch / latex-unravel

Watching TeX digest tokens
25 stars 1 forks source link

Macros delimited by begin-group break unravel with unbalanced text #61

Open blefloch opened 9 months ago

blefloch commented 9 months ago

The code to expand macros has an optimization which is to only pick up a balanced token list from the input and place that in front of the macro to be expanded, as anything else would mean that the macro would be seeking an argument beyond the end of \unravel. But this optimization is wrong for macros delimited by begin-group characters. The first \unravel below is ok, but the second breaks, owing only to the absence of a surrounding simple group.

\def\foo#1#{\iffalse}
\unravel{{\expandafter\foo\expandafter{\iffalse}\fi\fi}}
\unravel{\expandafter\foo\expandafter{\iffalse}\fi\fi}