[NTG-context] About xstring and ConTeXt

Phelype Oleinik phe.h.o1 at gmail.com
Tue Jul 7 23:30:49 CEST 2020


On Tue, Jul 7, 2020 at 6:21 PM Jairo A. del Rio <jairoadelrio6 at gmail.com> wrote:
>
> Thank, Wolfgang! Both methods work, but both fail with the following example:
>
> \pushmacro\unexpanded
> \let\unexpanded\normalunexpanded
> \input xstring
> \popmacro\unexpanded
> \starttext
> \StrGobbleLeft{bcdef}{4}
> \stoptext
>
> The log says:
>
> tex error > tex error on line 6 in file ./tests.tex: ! This can't happen (prefixed command)
>
>
> <argument> \unexpanded {
>
> f}
>
> \xs_execfirst #1#2->#1
>
> However, some others work.

As I said, the internals of `xstring` still use \unexpanded which, after
you do \popmacro\unexpanded, will mean e-TeX's \protected, rather than
\unexpanded, which are quite different.  To be on the safe side, you'd
need to wrap every `xstring` command in
    \pushmacro\unexpanded
    \let\unexpanded\normalunexpanded
    <xstring stuff>
    \popmacro\unexpanded
to make sure that \unexpanded means what `xstring` expects.

The *proper* way to make `xstring` work in ConTeXt would be something
like Circuitikz does:
    \ifcsname normalunexpanded\endcsname
      \let\pgfcircutil at unexpanded\normalunexpanded
    \else
      \let\pgfcircutil at unexpanded\unexpanded
    \fi
then use \pgfcircutil at unexpanded in the code, which will always have the
same meaning.  That, of course, requires an update to `xstring`.

Phelype


More information about the ntg-context mailing list