From a0064f3b1694f3a30c0c2048f77cdadc9dce27b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler=20=28via=20gitlab=20runner=29?= Date: Thu, 10 Feb 2022 00:14:06 +0000 Subject: [PATCH] add code macro usable inside other environments Build branch master (371ce76) from kesslermaximilian/LatexPackages --- build_info.json | 12 ++++++------ wip/code/mkessler-code.sty | 25 ++++++++++++++----------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/build_info.json b/build_info.json index c991817..d1c53d1 100644 --- a/build_info.json +++ b/build_info.json @@ -1,8 +1,8 @@ { "build_time": "", "source files": { - "version": "v2.9-3-g394ecc3", - "commit": "394ecc310cf67afd6630fae6d9321e9ea2e2da8c", + "version": "v2.9-4-g371ce76", + "commit": "371ce76a81138a9ba73676a41190c71ecd2b5748", "dirty": false }, "pytex": { @@ -36,12 +36,12 @@ { "name": "wip/code/mkessler-code.sty", "source file": "wip/code/code.pysty", - "build time": "2022/02/09 23:40", - "source version": "v2.9-3-g394ecc3", - "source commit hash": "394ecc310cf67afd6630fae6d9321e9ea2e2da8c", + "build time": "2022/02/10 00:14", + "source version": "v2.9-4-g371ce76", + "source commit hash": "371ce76a81138a9ba73676a41190c71ecd2b5748", "pytex version": "v1.2.0-31-gc9bb0e8", "pytex commit hash": "c9bb0e87c91beae3e17a829603e4459cf804ec51", - "md5sum": "c7e63292c9f515f645da21352bb6785e", + "md5sum": "68ded87bc3cbb44e2c3ff6874eda1a5e", "dirty": false }, { diff --git a/wip/code/mkessler-code.sty b/wip/code/mkessler-code.sty index e8698c7..e9d5f56 100644 --- a/wip/code/mkessler-code.sty +++ b/wip/code/mkessler-code.sty @@ -31,7 +31,7 @@ % % Build details: % PyTeX version: v1.2.0-31-gc9bb0e8 (commit c9bb0e8) -% Source code version: v2.9-3-g394ecc3 (commit 394ecc3) +% Source code version: v2.9-4-g371ce76 (commit 371ce76) % % This LaTeX package is free software and is dual-licensed % under the LPPLv1.3c and the GPLv3 licenses. @@ -47,7 +47,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{mkessler-code}[2022/02/09 - Hacky code setup for verbatim code] +\ProvidesPackage{mkessler-code}[2022/02/10 - Hacky code setup for verbatim code] @@ -58,15 +58,18 @@ \catcode`_=13 \let_\_ \catcode`_=8 -\newcommand\code{ - \begingroup - \catcode`_=\active - \code@impl -} -\newcommand\code@impl[1]{ - \texttt{#1} - \endgroup -} + +\ExplSyntaxOn +\NewDocumentCommand{\code}{m} + { + \tl_set_rescan:Nnn \l_tmpa_tl + { + \char_set_catcode_active:N _ + } + { #1 } + \texttt{ \tl_use:N \l_tmpa_tl } + } +\ExplSyntaxOff \newif\ifactive\activefalse \ifmkessler@code@pipe