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

Build branch master (0a902cc) from kesslermaximilian/LatexPackages
This commit is contained in:
Maximilian Keßler 2022-02-10 00:27:09 +00:00
parent a0064f3b16
commit fc8b8daa50
2 changed files with 15 additions and 20 deletions

View file

@ -1,8 +1,8 @@
{ {
"build_time": "", "build_time": "",
"source files": { "source files": {
"version": "v2.9-4-g371ce76", "version": "v2.9-5-g0a902cc",
"commit": "371ce76a81138a9ba73676a41190c71ecd2b5748", "commit": "0a902cc0ecbccd9c4f50b99faf8e73f0b3ab5648",
"dirty": false "dirty": false
}, },
"pytex": { "pytex": {
@ -36,12 +36,12 @@
{ {
"name": "wip/code/mkessler-code.sty", "name": "wip/code/mkessler-code.sty",
"source file": "wip/code/code.pysty", "source file": "wip/code/code.pysty",
"build time": "2022/02/10 00:14", "build time": "2022/02/10 00:27",
"source version": "v2.9-4-g371ce76", "source version": "v2.9-5-g0a902cc",
"source commit hash": "371ce76a81138a9ba73676a41190c71ecd2b5748", "source commit hash": "0a902cc0ecbccd9c4f50b99faf8e73f0b3ab5648",
"pytex version": "v1.2.0-31-gc9bb0e8", "pytex version": "v1.2.0-31-gc9bb0e8",
"pytex commit hash": "c9bb0e87c91beae3e17a829603e4459cf804ec51", "pytex commit hash": "c9bb0e87c91beae3e17a829603e4459cf804ec51",
"md5sum": "68ded87bc3cbb44e2c3ff6874eda1a5e", "md5sum": "1bdb9ea56b85112b1ef80f59fcaff51d",
"dirty": false "dirty": false
}, },
{ {

View file

@ -31,7 +31,7 @@
% %
% Build details: % Build details:
% PyTeX version: v1.2.0-31-gc9bb0e8 (commit c9bb0e8) % PyTeX version: v1.2.0-31-gc9bb0e8 (commit c9bb0e8)
% Source code version: v2.9-4-g371ce76 (commit 371ce76) % Source code version: v2.9-5-g0a902cc (commit 0a902cc)
% %
% This LaTeX package is free software and is dual-licensed % This LaTeX package is free software and is dual-licensed
% under the LPPLv1.3c and the GPLv3 licenses. % under the LPPLv1.3c and the GPLv3 licenses.
@ -55,6 +55,9 @@
\DeclareOption{pipe}{\mkessler@code@pipetrue} \DeclareOption{pipe}{\mkessler@code@pipetrue}
\ProcessOptions \ProcessOptions
% This is needed in general: when _ is active, we want it to expand to
% an actual _ character
\catcode`_=13 \catcode`_=13
\let_\_ \let_\_
\catcode`_=8 \catcode`_=8
@ -71,20 +74,12 @@
} }
\ExplSyntaxOff \ExplSyntaxOff
\newif\ifactive\activefalse
\ifmkessler@code@pipe \ifmkessler@code@pipe
\catcode`|=\active \catcode`|=\active
\def|{ \def|#1|{
\ifactive \code{#1}
\endgroup
\activefalse
\else
\begingroup
\catcode`_=13
\ttfamily
\fi
} }
% Quick fix for tables % Do not make | active inside tables
\AddToHook{env/tabular/begin}[code]{\catcode`|=13} \AddToHook{env/tabular/before}[code]{\catcode`|=12}
\AddToHook{env/tabular/end}[code]{\catcode`|=8} \AddToHook{env/tabular/after}[code]{\catcode`|=13}
\fi \fi