texlive[61929] Master/texmf-dist: codehigh (7feb22)

commits+karl at tug.org commits+karl at tug.org
Mon Feb 7 22:38:40 CET 2022


Revision: 61929
          http://tug.org/svn/texlive?view=revision&revision=61929
Author:   karl
Date:     2022-02-07 22:38:39 +0100 (Mon, 07 Feb 2022)
Log Message:
-----------
codehigh (7feb22)

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

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/codehigh/README.txt

Removed Paths:
-------------
    trunk/Master/texmf-dist/doc/latex/codehigh/README

Deleted: trunk/Master/texmf-dist/doc/latex/codehigh/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/codehigh/README	2022-02-07 21:38:12 UTC (rev 61928)
+++ trunk/Master/texmf-dist/doc/latex/codehigh/README	2022-02-07 21:38:39 UTC (rev 61929)
@@ -1,4 +0,0 @@
-Package: Highlight codes and demos with l3regex and lpeg
-Author: Jianrui Lyu <tolvjr at 163.com>
-Repository: https://github.com/lvjr/codehigh
-License: The LaTeX Project Public License 1.3c

Added: trunk/Master/texmf-dist/doc/latex/codehigh/README.txt
===================================================================
--- trunk/Master/texmf-dist/doc/latex/codehigh/README.txt	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/codehigh/README.txt	2022-02-07 21:38:39 UTC (rev 61929)
@@ -0,0 +1,4 @@
+Package: Highlight codes and demos with l3regex and lpeg
+Author: Jianrui Lyu <tolvjr at 163.com>
+Repository: https://github.com/lvjr/codehigh
+License: The LaTeX Project Public License 1.3c


Property changes on: trunk/Master/texmf-dist/doc/latex/codehigh/README.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
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	2022-02-07 21:38:12 UTC (rev 61928)
+++ trunk/Master/texmf-dist/doc/latex/codehigh/codehigh.tex	2022-02-07 21:38:39 UTC (rev 61929)
@@ -2,6 +2,13 @@
 \documentclass[oneside]{book}
 \usepackage[a4paper,margin=2cm]{geometry}
 
+\newcommand*{\myversion}{2022D}
+\newcommand*{\mydate}{Version \myversion\ (\the\year-\mylpad\month-\mylpad\day)}
+\newcommand*{\mylpad}[1]{\ifnum#1<10 0\the#1\else\the#1\fi}
+
+\setlength{\parindent}{0pt}
+\setlength{\parskip}{4pt plus 1pt minus 1pt}
+
 \usepackage{codehigh}
 \usepackage{hyperref}
 \hypersetup{
@@ -10,10 +17,6 @@
   linkcolor=green3,
 }
 
-\newcommand*{\myversion}{2021C}
-\newcommand*{\mydate}{Version \myversion\ (\the\year-\mylpad\month-\mylpad\day)}
-\newcommand*{\mylpad}[1]{\ifnum#1<10 0\the#1\else\the#1\fi}
-
 \begin{document}
 
 \title{\textsf{\color{green3}Codehigh: Highlight Codes and Demos with l3RegEx and LPeg}}
@@ -23,7 +26,7 @@
 
 \tableofcontents
 
-\chapter{Package Interface}
+\chapter{Package Interfaces}
 
 \section{Introduction}
 
@@ -35,9 +38,9 @@
 \footnote{\url{http://www.inf.puc-rio.br/~roberto/lpeg/}}.
 \verb!LPeg! is much more powerful and faster than \verb!l3regex!.
 
-At present, this package is in \underline{\color{red3}\textbf{experimental}} status.
-Don’t use it in important documents, unless you have time
-to update them for the newer versions of \verb!codehigh! package in the future.
+%At present, this package is in \underline{\color{red3}\textbf{experimental}} status.
+%Don’t use it in important documents, unless you have time
+%to update them for the newer versions of \verb!codehigh! package in the future.
 
 \section{Highlighting Code}
 
@@ -76,7 +79,7 @@
 }
 \end{codehigh}
 This language is for highlighting LaTeX2 classes and packages.
-Note that private commands and public commands are highlighted with different colors.
+It highlights private commands and public commands with different colors.
 
 The following example is typeset by \verb!codehigh! environment with option \verb!language=latex/latex3!.
 \begin{codehigh}[language=latex/latex3]
@@ -91,7 +94,7 @@
   }
 \end{codehigh}
 This language is for highlighting LaTeX3 classes and packages.
-Note that private commands/variables and public commands/variables are highlighted with different colors.
+It highlights private commands/variables and public commands/variables with different colors.
 
 The following example is typeset by \verb!codehigh! environment with option \verb!language=latex/math!.
 \begin{codehigh}[language=latex/math]
@@ -147,6 +150,9 @@
 \dochighinput[language=latex/latex3]{codehigh.sty}
 \end{codehigh}
 
+In reading an input file, lines starting wtih \verb!%%%! will be omitted,
+and lines starting with \verb!%%>! will be extracted and typeset as normal text.
+
 \section{Customization}
 
 The following example changes default background colors with \verb!\CodeHigh! command:
@@ -171,7 +177,7 @@
 To modify or add languages and themes, please read the source files
 \verb!codehigh.sty! and \verb!codehigh.lua! for reference.
 
-\chapter{Source Code}
+\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	2022-02-07 21:38:12 UTC (rev 61928)
+++ trunk/Master/texmf-dist/tex/latex/codehigh/codehigh.sty	2022-02-07 21:38:39 UTC (rev 61929)
@@ -6,13 +6,13 @@
 %%% License   : The LaTeX Project Public License 1.3c
 %%% ----------------------------------------------------------------------------
 
-%~%% -------------------------------------------------------
-%~%  \section{Variables and Functions}
-%~%% -------------------------------------------------------
+%%% -------------------------------------------------------
+%%> \section{Variables and Functions}
+%%% -------------------------------------------------------
 
 \NeedsTeXFormat{LaTeX2e}
 \RequirePackage{expl3}
-\ProvidesExplPackage{codehigh}{2021-05-12}{2021C}
+\ProvidesExplPackage{codehigh}{2022-02-07}{2022D}
   {Highlight codes and demos with l3regex and lpeg}
 
 %\RequirePackage{xparse}
@@ -25,8 +25,6 @@
   \RequirePackage{luatexbase}
 \fi
 
-\ExplSyntaxOn
-
 \int_new:N \l__codehigh_a_int
 \int_new:N \l__codehigh_b_int
 \tl_new:N \l__codehigh_a_tl
@@ -40,7 +38,8 @@
 \cs_generate_variant:Nn \str_remove_once:Nn {NV}
 \cs_generate_variant:Nn \tl_set_rescan:Nnn {NnV}
 
-\prg_generate_conditional_variant:Nnn \regex_extract_once:NnN {cVN} {T, TF}
+\prg_generate_conditional_variant:Nnn \str_if_eq:nn {en} {T, TF}
+\prg_generate_conditional_variant:Nnn \regex_extract_once:NnN {NVN, cVN} {T, TF}
 \prg_generate_conditional_variant:Nnn \regex_split:NnN {cVN} {T, TF}
 
 \group_begin:
@@ -49,9 +48,9 @@
   \tl_gset:Nn \g__codehigh_eol_eol_tl {^^M^^M}
 \group_end:
 
-%~%% -------------------------------------------------------
-%~%  \section{Set CodeHign Options}
-%~%% -------------------------------------------------------
+%%% -------------------------------------------------------
+%%> \section{Set CodeHigh Options}
+%%% -------------------------------------------------------
 
 \bool_new:N \l__codehigh_lite_bool
 \bool_new:N \l__codehigh_long_bool
@@ -69,9 +68,9 @@
     demo .bool_set:N = \l__codehigh_demo_bool,
   }
 
-%~%% -------------------------------------------------------
-%~%  \section{CodeHign Environments and Commands}
-%~%% -------------------------------------------------------
+%%% -------------------------------------------------------
+%%> \section{CodeHigh Environments and Commands}
+%%% -------------------------------------------------------
 
 \NewDocumentCommand \NewCodeHighEnv {mm}
   {
@@ -136,17 +135,50 @@
     \seq_map_inline:Nn \l__codehigh_input_seq
       {
         \tl_gset:Nn \g__codehigh_code_tl {##1}
-        \__codehigh_typeset_code:
-        \par
-        \medskip
+        \__codehigh_typeset_comment:N \g__codehigh_code_tl
+        \tl_if_blank:VF \g__codehigh_code_tl
+          {
+            \__codehigh_typeset_code:
+            \par
+            \medskip
+          }
       }
   }
 
+\regex_const:Nn \l__codehigh_comment_regex { ^ \% \% ( [\%>] ) ( [^\r]+ ) [\r] }
+\tl_new:N \l__codehigh_comment_tl % comment lines that need to be typeset
+\bool_new:N \l__codehigh_comment_bool
+
+%% remove lines starting with %%%, and typeset lines starting with %%>
+\cs_new_protected:Npn \__codehigh_typeset_comment:N #1
+  {
+    \tl_set_eq:NN \l_tmpa_tl #1
+    \tl_put_right:NV \l_tmpa_tl \g__codehigh_eol_tl
+    \tl_clear:N \l__codehigh_comment_tl
+    \bool_set_false:N \l__codehigh_comment_bool
+    \bool_do_until:Nn \l__codehigh_comment_bool
+      {
+        %% Unfortunately we need both \regex_extract_once and \regex_replace_once
+        \regex_extract_once:NVNTF \l__codehigh_comment_regex \l_tmpa_tl \l_tmpa_seq
+          {
+            \regex_replace_once:NnN \l__codehigh_comment_regex {} \l_tmpa_tl
+            \str_if_eq:enT { \seq_item:Nn \l_tmpa_seq {2} } {>}
+              {
+                \tl_put_right:Nx \l__codehigh_comment_tl
+                  { \seq_item:Nn \l_tmpa_seq {3} }
+              }
+          }
+          { \bool_set_true:N \l__codehigh_comment_bool }
+      }
+    \exp_args:NV \scantokens \l__codehigh_comment_tl
+    \tl_gset_eq:NN #1 \l_tmpa_tl
+  }
+
 \NewCodeHighInput \dochighinput {long}
 
-%~%% -------------------------------------------------------
-%~%  \section{Typeset CodeHign Code}
-%~%% -------------------------------------------------------
+%%% -------------------------------------------------------
+%%> \section{Typeset CodeHigh Code}
+%%% -------------------------------------------------------
 
 \dim_new:N \l__codehigh_main_boxsep_dim
 
@@ -231,9 +263,9 @@
     \group_end:
   }
 
-%~%% -------------------------------------------------------
-%~%  \section{Typeset CodeHign Demo}
-%~%% -------------------------------------------------------
+%%% -------------------------------------------------------
+%%> \section{Typeset CodeHigh Demo}
+%%% -------------------------------------------------------
 
 \box_new:N \g__codehigh_demo_box
 
@@ -302,9 +334,9 @@
       }
   }
 
-%~%% -------------------------------------------------------
-%~%  \section{Add CodeHign Languages}
-%~%% -------------------------------------------------------
+%%% -------------------------------------------------------
+%%> \section{Add CodeHigh Languages}
+%%% -------------------------------------------------------
 
 \keys_define:nn {codehigh}
   {
@@ -372,9 +404,9 @@
 \AddCodeHighRule[latex/latex3]{3}{Bracket}   {[\[\]]}
 \AddCodeHighRule[latex/latex3]{9}{Comment}   {\%.*?\r}
 
-%~%% -------------------------------------------------------
-%~%  \section{Add CodeHigh Themes}
-%~%% -------------------------------------------------------
+%%% -------------------------------------------------------
+%%> \section{Add CodeHigh Themes}
+%%% -------------------------------------------------------
 
 \keys_define:nn {codehigh}
   {
@@ -411,9 +443,9 @@
 \SetCodeHighStyle[default]{8}{purple3}
 \SetCodeHighStyle[default]{9}{gray3}
 
-%~%% -------------------------------------------------------
-%~%  \section{Parse and Highlight Code}
-%~%% -------------------------------------------------------
+%%% -------------------------------------------------------
+%%> \section{Parse and Highlight Code}
+%%% -------------------------------------------------------
 
 \int_new:N \l__codehigh_item_count_int
 \tl_new:N \l__codehigh_code_to_parse_tl
@@ -517,9 +549,9 @@
   }
 \cs_generate_variant:Nn \__codehigh_typeset_text:nN { VN, vc }
 
-%~%% -------------------------------------------------------
-%~%  \section{Don't Highlight Code}
-%~%% -------------------------------------------------------
+%%% -------------------------------------------------------
+%%> \section{Don't Highlight Code}
+%%% -------------------------------------------------------
 
 \cs_new_protected:Npn \__codehigh_parse_code_lite:N #1
   {
@@ -528,5 +560,3 @@
     \tl_use:N #1
   }
 
-\ExplSyntaxOff
-



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