diff options
author | Karl Berry <karl@freefriends.org> | 2023-02-11 21:16:41 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-02-11 21:16:41 +0000 |
commit | f9e3b88ca0a578b474fab0440a030136f034ab2e (patch) | |
tree | 62948f912e8aa0353fda5787b73bbc89cc5e4e77 /Master/texmf-dist/tex/latex | |
parent | 28c6dbff46efa29add42b37b26f7c7cf7b51199e (diff) |
codehigh (11feb23)
git-svn-id: svn://tug.org/texlive/trunk@65787 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/codehigh/codehigh.sty | 38 |
1 files changed, 36 insertions, 2 deletions
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} @@ -600,6 +600,40 @@ } %%% ------------------------------------------------------- +%%> \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} %%% ------------------------------------------------------- |