summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/codehigh
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-02-12 03:01:46 +0000
committerNorbert Preining <norbert@preining.info>2023-02-12 03:01:46 +0000
commitf76939750d63d6088b9bdeac794ce3fdf33d1269 (patch)
tree0cd0d327b53fe3a657722ae4188983b8b100468d /macros/latex/contrib/codehigh
parent73abb311c03e955ad9f7b7464390a5722b20b915 (diff)
CTAN sync 202302120301
Diffstat (limited to 'macros/latex/contrib/codehigh')
-rw-r--r--macros/latex/contrib/codehigh/codehigh.pdfbin119611 -> 125913 bytes
-rw-r--r--macros/latex/contrib/codehigh/codehigh.sty38
-rw-r--r--macros/latex/contrib/codehigh/codehigh.tex59
3 files changed, 94 insertions, 3 deletions
diff --git a/macros/latex/contrib/codehigh/codehigh.pdf b/macros/latex/contrib/codehigh/codehigh.pdf
index 088eb890e8..21c152b571 100644
--- a/macros/latex/contrib/codehigh/codehigh.pdf
+++ b/macros/latex/contrib/codehigh/codehigh.pdf
Binary files differ
diff --git a/macros/latex/contrib/codehigh/codehigh.sty b/macros/latex/contrib/codehigh/codehigh.sty
index d9bfaec0e7..62438d7dac 100644
--- a/macros/latex/contrib/codehigh/codehigh.sty
+++ b/macros/latex/contrib/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}
%%% -------------------------------------------------------
diff --git a/macros/latex/contrib/codehigh/codehigh.tex b/macros/latex/contrib/codehigh/codehigh.tex
index c3bddd4632..5f1e0295e7 100644
--- a/macros/latex/contrib/codehigh/codehigh.tex
+++ b/macros/latex/contrib/codehigh/codehigh.tex
@@ -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 @@ Note that \verb!codehigh! package will load \verb!ninecolors!%
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}