LaTeX3 defines the \peek_catcode_ignore_spaces:NTF
which allows me to look ahead at the next token in the stream (ignoring spaces) and test its catcode against those of a slew of standard tokens. So I can do:
\peek_catcode_ignore_spaces:NTF \c_math_toggle_token
{
Uh-oh,~ upcoming~ math!
}
{
Phew!~ Just~ text.
}
to see if what's next is a math shift.
How do I do the same but for an active character? There's no \c_active_token
that I can test against. I've tried making one by emulating the code that makes the other tokens, but my attempts have failed dismally. There's a \c_catcode_active_tl
that contains an active token, but it contains it with an \exp_not:N
so even doing
\exp_last_unbraced:NV \peek_catcode_ignore_spaces:NTF \c_catcode_token_tl
doesn't work.
Yet there is a \token_if_active:NTF
so I presume I could cobble together some variant of the peek code that tested for an active character by effectively copying the code that defines \peek_catcode_stuff
and swapping the tests. But before I attempt that, I thought I'd ask if there's something I'm missing.
So, is there a straightforward way to see if the next character is active?