texlive[74188] Master/texmf-dist: codehigh (21feb25)
commits+karl at tug.org
commits+karl at tug.org
Fri Feb 21 23:19:07 CET 2025
Revision: 74188
https://tug.org/svn/texlive?view=revision&revision=74188
Author: karl
Date: 2025-02-21 23:19:07 +0100 (Fri, 21 Feb 2025)
Log Message:
-----------
codehigh (21feb25)
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.lua
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 2025-02-21 22:18:56 UTC (rev 74187)
+++ trunk/Master/texmf-dist/doc/latex/codehigh/codehigh.tex 2025-02-21 22:19:07 UTC (rev 74188)
@@ -2,7 +2,7 @@
\documentclass[oneside]{book}
\usepackage[a4paper,margin=2cm]{geometry}
-\newcommand*{\myversion}{2025B}
+\newcommand*{\myversion}{2025C}
\newcommand*{\mydate}{Version \myversion\ (\the\year-\mylpad\month-\mylpad\day)}
\newcommand*{\mylpad}[1]{\ifnum#1<10 0\the#1\else\the#1\fi}
@@ -117,6 +117,8 @@
\end{tabular}
\end{codehigh}
+There is also a \texttt{codehigh*} environment which shows each space character as \textvisiblespace{} in the code.
+
\section{Highlighting Demo}
The followings are typeset by \verb!demohigh! environment with option \verb!language=latex/table!.
@@ -143,6 +145,8 @@
Note that \verb!demohigh! environment will measure the width of source lines.
When it is too large, the result will be put below.
+There is also a \texttt{demohigh*} environment which shows each space character as \textvisiblespace{} in the code.
+
\section{Highlighting File}
Using \verb!\dochighinput! command, you can input and highlight some file.
Modified: trunk/Master/texmf-dist/tex/latex/codehigh/codehigh.lua
===================================================================
--- trunk/Master/texmf-dist/tex/latex/codehigh/codehigh.lua 2025-02-21 22:18:56 UTC (rev 74187)
+++ trunk/Master/texmf-dist/tex/latex/codehigh/codehigh.lua 2025-02-21 22:19:07 UTC (rev 74188)
@@ -90,6 +90,10 @@
return b, e, s
end
+---- We can not use "catcodetable at string" because space has catcode 10 with it,
+---- which causes multiple spaces are printed as single space in "tex.tprint".
+-- local cctab = luatexbase.registernumber("catcodetable at string")
+
---- We don't have "catcodetable at other" inside source2e
-- local cctab = luatexbase.registernumber("catcodetable at other")
---- Here is the catcodetable from luatexbase package
Modified: trunk/Master/texmf-dist/tex/latex/codehigh/codehigh.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/codehigh/codehigh.sty 2025-02-21 22:18:56 UTC (rev 74187)
+++ trunk/Master/texmf-dist/tex/latex/codehigh/codehigh.sty 2025-02-21 22:19:07 UTC (rev 74188)
@@ -12,7 +12,7 @@
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
-\ProvidesExplPackage{codehigh}{2025-02-15}{2025B}
+\ProvidesExplPackage{codehigh}{2025-02-21}{2025C}
{Highlight codes and demos with l3regex and lpeg}
%\RequirePackage{xparse}
@@ -65,11 +65,14 @@
\keys_set:nn {codehigh} {#2}
}
+\cs_new_eq:NN \codehighspace \space
+
\keys_define:nn {codehigh}
{
lite .bool_set:N = \l__cdhh_lite_bool,
long .bool_set:N = \l__cdhh_long_bool,
demo .bool_set:N = \l__cdhh_demo_bool,
+ visiblespace .code:n = { \cs_set_eq:NN \codehighspace \verbvisiblespace }
}
%%% -------------------------------------------------------
@@ -153,6 +156,8 @@
\NewCodeHighEnv {codehigh} {}
\NewCodeHighEnv {demohigh} {demo}
+\NewCodeHighEnv {codehigh*} {visiblespace}
+\NewCodeHighEnv {demohigh*} {demo,visiblespace}
\tl_new:N \l__cdhh_input_tl
\seq_new:N \l__cdhh_input_seq
@@ -520,7 +525,7 @@
{
\tl_concat:NNN \l__cdhh_a_tl
\l__cdhh_regex_before_text_tl \l__cdhh_regex_match_text_tl
- \str_remove_once:NV \l__cdhh_code_to_parse_tl \l__cdhh_a_tl
+ \tl_remove_once:NV \l__cdhh_code_to_parse_tl \l__cdhh_a_tl
\__cdhh_tracing:nn {parser}
{\tl_log:N \l__cdhh_code_to_parse_tl}
\__cdhh_typeset_text:nN {0}
@@ -603,8 +608,15 @@
\cs_new_protected:Npn \__cdhh_typeset_text:nN #1 #2
{
\__cdhh_tracing:nn {parser} { \tl_log:e { type: #1; ~ text: #2 } }
- \sys_if_engine_luatex:T
- { \tl_replace_all:Nnn #2 { ~ } { \leavevmode \space } }
+ \sys_if_engine_luatex:TF
+ {
+ \tl_replace_all:NVn #2
+ \c_catcode_other_space_tl { \leavevmode \codehighspace }
+ }
+ {
+ \tl_replace_all:NVn #2
+ \c_catcode_active_space_tl { \leavevmode \codehighspace }
+ }
\__cdhh_seq_set_split:NnV \l__cdhh_typeset_text_seq {^^J} #2
\seq_map_indexed_inline:Nn \l__cdhh_typeset_text_seq
{
@@ -623,7 +635,7 @@
\cs_new_protected:Npn \__cdhh_parse_code_lite:N #1
{
\regex_replace_all:nnN { \n } { \c{par} \c{leavevmode} } #1
- \regex_replace_all:nnN { \ } { \c{relax} \c{space} } #1
+ \regex_replace_all:nnN { \ } { \c{relax} \c{codehighspace} } #1
\tl_use:N #1
}
@@ -632,6 +644,7 @@
%%% -------------------------------------------------------
\tl_const:Nn \c__cdhh_fake_escape_tl { \\\{\}\#\^\ \% }
+\tl_new:N \l__cdhh_multibyte_char_tl
\NewDocumentCommand \fakeverb { +m }
{
@@ -638,17 +651,25 @@
\group_begin:
\group_align_safe_begin:
\ttfamily \frenchspacing
+ \tl_clear:N \l__cdhh_multibyte_char_tl
\tl_analysis_map_inline:nn {#1}
{
- \int_compare:nNnTF {##2} = { -1 }
+ \int_compare:nNnTF {##2} > { 127 } % utf8 characters in pdftex
+ { \tl_put_right:Ne \l__cdhh_multibyte_char_tl {##1} }
{
- \exp_args:NNo \tl_if_in:NnTF \c__cdhh_fake_escape_tl {##1}
- { \exp_after:wN \cs_to_str:N ##1 }
+ \tl_use:N \l__cdhh_multibyte_char_tl
+ \tl_clear:N \l__cdhh_multibyte_char_tl
+ \int_compare:nNnTF {##2} = { -1 }
+ {
+ \exp_args:NNo \tl_if_in:NnTF \c__cdhh_fake_escape_tl {##1}
+ { \exp_after:wN \cs_to_str:N ##1 }
+ { \exp_after:wN \token_to_str:N ##1 }
+ }
{ \exp_after:wN \token_to_str:N ##1 }
+ \/ % disable ligatures (#17)
}
- { \exp_after:wN \token_to_str:N ##1 }
- \/ % disable ligatures (#17)
}
+ \tl_use:N \l__cdhh_multibyte_char_tl
\group_align_safe_end:
\group_end:
}
More information about the tex-live-commits
mailing list.