texlive[65787] Master/texmf-dist: codehigh (11feb23)

commits+karl at tug.org commits+karl at tug.org
Sat Feb 11 22:16:41 CET 2023


Revision: 65787
          http://tug.org/svn/texlive?view=revision&revision=65787
Author:   karl
Date:     2023-02-11 22:16:41 +0100 (Sat, 11 Feb 2023)
Log Message:
-----------
codehigh (11feb23)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/codehigh/codehigh.pdf
    trunk/Master/texmf-dist/doc/latex/codehigh/codehigh.tex
    trunk/Master/texmf-dist/tex/latex/codehigh/codehigh.sty

Modified: trunk/Master/texmf-dist/doc/latex/codehigh/codehigh.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/codehigh/codehigh.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/codehigh/codehigh.tex	2023-02-11 21:16:30 UTC (rev 65786)
+++ trunk/Master/texmf-dist/doc/latex/codehigh/codehigh.tex	2023-02-11 21:16:41 UTC (rev 65787)
@@ -2,7 +2,7 @@
 \documentclass[oneside]{book}
 \usepackage[a4paper,margin=2cm]{geometry}
 
-\newcommand*{\myversion}{2022E}
+\newcommand*{\myversion}{2023A}
 \newcommand*{\mydate}{Version \myversion\ (\the\year-\mylpad\month-\mylpad\day)}
 \newcommand*{\mylpad}[1]{\ifnum#1<10 0\the#1\else\the#1\fi}
 
@@ -16,6 +16,7 @@
   urlcolor=blue3,
   linkcolor=green3,
 }
+\usepackage{tabularx,booktabs}
 
 \begin{document}
 
@@ -177,6 +178,62 @@
 To modify or add languages and themes, please read the source files
 \verb!codehigh.sty! and \verb!codehigh.lua! for reference.
 
+\section{Fake Verbatim Command}
+
+\CodeHigh{language=latex/table,style/main=gray9,style/code=gray9,style/demo=white}
+
+To ease the pain of writing verbatim commands
+(such as in \verb|tabularx| and \verb|tabularray| tables),
+This package provides \verb|\fakeverb| command.
+
+This command will remove the backslashes in the following control symbols
+before typesetting its content:
+
+\renewcommand\arraystretch{1.3}
+\begin{center}
+\begin{tabularx}{0.9\linewidth}{llX}
+\toprule
+Input           & Result        & Remark \\
+\midrule
+\fakeverb{\\\\} & \fakeverb{\\} &
+  Need to be escaped only when typesetting other control symbols in this table \\
+\fakeverb{\\\{}	& \fakeverb{\{} &
+  Need to be escaped only when left and right curly braces are unmatched \\
+\fakeverb{\\\}}	& \fakeverb{\}} &
+  Need to be escaped only when left and right curly braces are unmatched \\
+\fakeverb{\\\#}	& \fakeverb{\#} &
+  Always need to be escaped \\
+\fakeverb{\\\^}	& \fakeverb{\^} &
+  Need to be escaped only when there are more than one in a row \\
+\texttt{\textbackslash\textvisiblespace} & \texttt{\textvisiblespace} &
+  Need to be escaped only when more than one in a row or after control words \\
+\fakeverb{\\\%}	& \fakeverb{\%} &
+  Always need to be escaped \\
+\bottomrule
+\end{tabularx}
+\end{center}
+
+The argument of \verb|\fakeverb| command need to be enclosed with curly braces.
+Therefore it could be safely used inside \verb|tabularray| tables and other LaTeX commands.
+
+Here is an example of using \verb!\fakeverb! commands inside \verb|tabularx| environment:
+
+\begin{demohigh}[language=latex/table]
+\begin{tabularx}{0.5\textwidth}{lX}
+\hline
+ Alpha & \fakeverb{\abc{}$&^_^uvw 123} \\
+\hline
+ Beta  & \fakeverb{\bfseries\ \#\%} \\
+\hline
+\end{tabularx}
+\end{demohigh}
+
+Here is another example of using \verb!\fakeverb! commands inside \verb|\fbox| command:
+
+\begin{demohigh}[language=latex/latex2]
+Hello\fbox{\fakeverb{$\left\\\{A\right.$\#}}Verb!
+\end{demohigh}
+
 \chapter{The Source Code}
 
 \dochighinput[language=latex/latex3]{codehigh.sty}

Modified: trunk/Master/texmf-dist/tex/latex/codehigh/codehigh.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/codehigh/codehigh.sty	2023-02-11 21:16:30 UTC (rev 65786)
+++ trunk/Master/texmf-dist/tex/latex/codehigh/codehigh.sty	2023-02-11 21:16:41 UTC (rev 65787)
@@ -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}
 %%% -------------------------------------------------------
 



More information about the tex-live-commits mailing list.