From 0a902cc0ecbccd9c4f50b99faf8e73f0b3ab5648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Thu, 10 Feb 2022 01:26:33 +0100 Subject: [PATCH] improve code package: deactivate | symbol in tables. make | and code usable inside other macros by rescanning the token list --- src/wip/code/code.pysty | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/wip/code/code.pysty b/src/wip/code/code.pysty index 9ede12e..2ac1802 100644 --- a/src/wip/code/code.pysty +++ b/src/wip/code/code.pysty @@ -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