From f9e3b88ca0a578b474fab0440a030136f034ab2e Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 11 Feb 2023 21:16:41 +0000 Subject: codehigh (11feb23) git-svn-id: svn://tug.org/texlive/trunk@65787 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/codehigh/codehigh.sty | 38 +++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'Master/texmf-dist/tex/latex') diff --git a/Master/texmf-dist/tex/latex/codehigh/codehigh.sty b/Master/texmf-dist/tex/latex/codehigh/codehigh.sty index d9bfaec0e7c..62438d7dac1 100644 --- a/Master/texmf-dist/tex/latex/codehigh/codehigh.sty +++ b/Master/texmf-dist/tex/latex/codehigh/codehigh.sty @@ -12,11 +12,11 @@ \NeedsTeXFormat{LaTeX2e} \RequirePackage{expl3} -\ProvidesExplPackage{codehigh}{2022-04-29}{2022E} +\ProvidesExplPackage{codehigh}{2023-02-11}{2023A} {Highlight codes and demos with l3regex and lpeg} %\RequirePackage{xparse} -\RequirePackage{l3benchmark} +%\RequirePackage{l3benchmark} \RequirePackage{catchfile} \RequirePackage{xcolor} \RequirePackage{ninecolors} @@ -599,6 +599,40 @@ \tl_use:N #1 } +%%% ------------------------------------------------------- +%%> \section{Fake Verbatim Command} +%%% ------------------------------------------------------- + +\tl_new:N \l__codehigh_fake_code_tl + +\NewDocumentCommand \fakeverb { +m } + { + \group_begin: + \tl_set:Nn \l__codehigh_fake_code_tl {#1} + \__codehigh_fake_verb:N \l__codehigh_fake_code_tl + \group_end: + } + +\cs_new_protected:Npn \__codehigh_fake_verb:N #1 + { + \regex_replace_all:nnN { \c{\\} } { \\ } #1 + % use \cO to avoid errors of unmatched braces + \regex_replace_all:nnN { \c{\{} } { \cO\{ } #1 + \regex_replace_all:nnN { \c{\}} } { \cO\} } #1 + % use \cO to avoid doubled hash characters + \regex_replace_all:nnN { \c{\#} } { \cO\# } #1 + % need to escape ^ because ^^ and ^^^^ are special + \regex_replace_all:nnN { \c{\^} } { \^ } #1 + % why we can not use \c{\ } instead of \c{\h}? + \regex_replace_all:nnN { \c{\h} } { \ } #1 + \regex_replace_all:nnN { \c{\%} } { \% } #1 + % remove spaces after control words + \regex_replace_all:nnN { . } { \c{string}\0 } #1 + \tl_set:Ne #1 { #1 } + %\tl_log:N #1 + \ttfamily \frenchspacing \tl_to_str:N #1 + } + %%% ------------------------------------------------------- %%> \section{Tracing CodeHigh} %%% ------------------------------------------------------- -- cgit v1.2.3