improve code package: deactivate | symbol in tables. make | and code usable inside other macros by rescanning the token list

This commit is contained in:
Maximilian Keßler 2022-02-10 01:26:33 +01:00
parent 371ce76a81
commit 0a902cc0ec

View file

@ -4,6 +4,9 @@ __NEW_IF__(pipe,false)
\DeclareOption{pipe}{__SET_IF__(pipe,true)}
\ProcessOptions
% This is needed in general: when _ is active, we want it to expand to
% an actual _ character
\catcode`_=13
\let_\_
\catcode`_=8
@ -20,20 +23,12 @@ __NEW_IF__(pipe,false)
}
\ExplSyntaxOff
\newif\ifactive\activefalse
__IF__(pipe)
\catcode`|=\active
\def|{
\ifactive
\endgroup
\activefalse
\else
\begingroup
\catcode`_=13
\ttfamily
\fi
\def|#1|{
\code{#1}
}
% Quick fix for tables
\AddToHook{env/tabular/begin}[code]{\catcode`|=13}
\AddToHook{env/tabular/end}[code]{\catcode`|=8}
% Do not make | active inside tables
\AddToHook{env/tabular/before}[code]{\catcode`|=12}
\AddToHook{env/tabular/after}[code]{\catcode`|=13}
\fi