texlive[70029] branches/branch2023.final/Master/texmf-dist: piton

commits+karl at tug.org commits+karl at tug.org
Tue Feb 20 22:09:04 CET 2024


Revision: 70029
          https://tug.org/svn/texlive?view=revision&revision=70029
Author:   karl
Date:     2024-02-20 22:09:04 +0100 (Tue, 20 Feb 2024)
Log Message:
-----------
piton (branch) (20feb24)

Modified Paths:
--------------
    branches/branch2023.final/Master/texmf-dist/doc/lualatex/piton/piton-french.pdf
    branches/branch2023.final/Master/texmf-dist/doc/lualatex/piton/piton-french.tex
    branches/branch2023.final/Master/texmf-dist/doc/lualatex/piton/piton.pdf
    branches/branch2023.final/Master/texmf-dist/source/lualatex/piton/piton.dtx
    branches/branch2023.final/Master/texmf-dist/tex/lualatex/piton/piton.lua
    branches/branch2023.final/Master/texmf-dist/tex/lualatex/piton/piton.sty

Modified: branches/branch2023.final/Master/texmf-dist/doc/lualatex/piton/piton-french.pdf
===================================================================
(Binary files differ)

Modified: branches/branch2023.final/Master/texmf-dist/doc/lualatex/piton/piton-french.tex
===================================================================
--- branches/branch2023.final/Master/texmf-dist/doc/lualatex/piton/piton-french.tex	2024-02-20 21:08:54 UTC (rev 70028)
+++ branches/branch2023.final/Master/texmf-dist/doc/lualatex/piton/piton-french.tex	2024-02-20 21:09:04 UTC (rev 70029)
@@ -222,8 +222,7 @@
 Il est possible de n'insérer qu'une partie du fichier : cf. partie~\ref{part-of-a-file},
 p.~\pageref{part-of-a-file}.
 
-\colorbox{yellow!50}{\textbf{Nouveau 2.2}}\enskip La clé |path| de la commande |\PitonOptions| permet de spécifier
-un chemin pour le fichier à inclure. 
+La clé |path| de la commande |\PitonOptions| permet de spécifier un chemin pour le fichier à inclure. 
 \end{itemize}
 
 
@@ -356,26 +355,29 @@
 fichier (avec l'extension) et écrit le contenu de l'environnement courant dans ce fichier. À la première
 utilisation du fichier par \pkg{piton}, celui-ci est effacé.
 
+\item \index{path-write} \colorbox{yellow!50}{\bfseries Nouveau 2.5}\enskip La clé \Definition{path-write} indique
+un chemin où seront écrits les fichiers écrits par l'emploi de la clé |write| précédente.
+
 \item \index{line-numbers} La clé \Definition{line-numbers} active la numérotation des lignes (en débordement à gauche) dans les
-environnements \verb|{Piton}| et dans les listings produits par la commande |\PitonInputFile|.
+environnements |{Piton}| et dans les listings produits par la commande |\PitonInputFile|.
 
 Cette clé propose en fait plusieurs sous-clés.
 \begin{itemize}
 \item La clé \Definition{line-numbers/skip-empty-lines} demande que les lignes vides soient considérées comme non existantes en
-ce qui concerne la numérotation des lignes (si la clé \verb|/absolute| est active, la clé \verb|/skip-empty-lines|
-n'a pas d'effet dans \verb|\PitonInputFile|). La valeur initiale de cette clé est \verb|true| (et non
-\verb|false|).\footnote{Avec le langage Python, les lignes vides des \emph{docstrings} sont prises en compte.}
+ce qui concerne la numérotation des lignes (si la clé |/absolute| est active, la clé |/skip-empty-lines|
+n'a pas d'effet dans |\PitonInputFile|). La valeur initiale de cette clé est |true| (et non
+|false|).\footnote{Avec le langage Python, les lignes vides des \emph{docstrings} sont prises en compte.}
 
 \item La clé \Definition{line/numbers/label-empty-lines} demande que les labels (c'est-à-dire les numéros) des lignes vides
-soient affichés. Si la clé \verb|/skip-empty-lines| est active, la clé \verb|/label-empty-lines| est sans effet. La
-valeur initiale de cette clé est \verb|true|.
+soient affichés. Si la clé |/skip-empty-lines| est active, la clé |/label-empty-lines| est sans effet. La
+valeur initiale de cette clé est |true|.
 
-\item La clé \Definition{line-numbers/absolute} demande, pour les listings générés par \verb|\PitonInputFile|, que les numéros de
+\item La clé \Definition{line-numbers/absolute} demande, pour les listings générés par |\PitonInputFile|, que les numéros de
 lignes affichés soient absolus (c'est-à-dire ceux du fichier d'origine). Elle n'a d'intérêt que si on n'insère qu'une
-partie du fichier (cf. part~\ref{part-of-a-file}, p.~\pageref{part-of-a-file}). La clé |/absolute| est sans effet dans les environnements \verb|{Piton}|.
+partie du fichier (cf. part~\ref{part-of-a-file}, p.~\pageref{part-of-a-file}). La clé |/absolute| est sans effet dans les environnements |{Piton}|.
 
 \item La clé \Definition{line-numbers/resume} reprend la numérotation là où elle avait été laissée au dernier listing. En fait,
-la clé \verb|line-numbers/resume| a un alias, qui est \verb|resume| tout court. 
+la clé |line-numbers/resume| a un alias, qui est |resume| tout court. 
 
 \item La clé \Definition{line-numbers/start} impose que la numérotation commence à ce numéro. 
 
@@ -581,10 +583,9 @@
 tous les commentaires (que ce soit en Python, en C, en OCaml, etc.) seront composés en gris.
 
 \bigskip
-\colorbox{yellow!50}{\textbf{Nouveau 2.2}}\enskip Mais il est aussi possible de définir un style localement pour un
-certain langage informatique en passant le nom du langage en argument optionnel (entre crochets) de la commande
-|\SetPitonStyle|.\footnote{On rappelle que, dans \pkg{piton}, les noms des langages informatiques ne sont pas
-  sensibles à la casse.}
+Mais il est aussi possible de définir un style localement pour un certain langage informatique en passant le nom du
+langage en argument optionnel (entre crochets) de la commande |\SetPitonStyle|.\footnote{On rappelle que, dans
+  \pkg{piton}, les noms des langages informatiques ne sont pas sensibles à la casse.}
 
 \medskip
 Par exemple, avec la commande 
@@ -678,7 +679,7 @@
 Par exemple, avec l'instruction suivante, un nouvel environnement |{Python}| sera défini avec le même comportement
 que l'environnement |{Piton}|:
 
-{\color{gray}\verb|\NewPitonEnvironment{Python}{O{}}{\PitonOptions{#1}}{}|}
+{\color{gray}|\NewPitonEnvironment{Python}{O{}}{\PitonOptions{#1}}{}|}
 
 \bigskip
 Si on souhaite un environnement |{Python}| qui compose le code inclus dans une boîte de \pkg{tcolorbox}, on peut
@@ -1078,7 +1079,7 @@
 
 Par exemple, avec le réglage suivant (fait dans le préambule du document) :
 
-\verb|\PitonOptions{comment-latex = LaTeX}|
+|\PitonOptions{comment-latex = LaTeX}|
 
 les commentaires LaTeX commenceront par~|#LaTeX|.
 
@@ -1155,7 +1156,7 @@
 \item Cette clé |detected-commands| ne peut être utilisée que dans le préambule du document.
 
 \item Les noms de commandes LaTeX doivent apparaître sans la contre-oblique 
-(ex. : |detected-commands = { emph , bfseries }|). 
+(ex. : |detected-commands = { emph , textbf }|). 
 
 \item Ces commandes doivent être des commandes LaTeX à un seul argument obligatoire entre accolades (et ces
 accolages doivent être explicites).
@@ -1262,12 +1263,12 @@
 particulier composé dans un groupe TeX et ne pourra donc pas servir à changer le formatage d'autres unités lexicales.
 
 \medskip
-Dans les langages où le caractère \verb|$| ne joue pas un rôle syntaxique important, on peut assez naturellement
-vouloir activer le mécanisme «|escape-math|» avec le caractère \verb|$|:
+Dans les langages où le caractère |$| ne joue pas un rôle syntaxique important, on peut assez naturellement
+vouloir activer le mécanisme «|escape-math|» avec le caractère |$|:
 \begin{Verbatim}
 \PitonOptions{~emphase#begin-escape-math=$,end-escape-math=$@}
 \end{Verbatim}
-Remarquer que le caractère \verb|$| ne doit \emph{pas} être protégé par une contre-oblique.
+Remarquer que le caractère |$| ne doit \emph{pas} être protégé par une contre-oblique.
 
 \bigskip
 Néanmoins, il est sans doute plus prudent d'utiliser |\(| et |\)|.
@@ -1965,7 +1966,8 @@
        tex.print(pyluatex.get_last_output())
        tex.print("\\end{Piton}")
        tex.print("") 
-     }
+     }% 
+   \ignorespacesafterend
  }
 \end{Verbatim}
 
@@ -2005,7 +2007,8 @@
        tex.print(pyluatex.get_last_output())
        tex.print("\\end{Piton}")
        tex.print("") 
-     }
+     }%
+   \ignorespacesafterend
  }
 
 
@@ -2121,7 +2124,7 @@
   Interpol.Inside & le contenu des interpolations dans les f-strings (c'est-à-dire les éléments qui se trouvent entre
                     \texttt{\{} et~\texttt{\}} ; si l'utilisateur n'a pas fixé ce style, ces éléments sont analysés et formatés par \pkg{piton}
                     au même titre que le reste du code. \\
-                    Operator & les opérateurs suivants : \texttt{!= == << >> - \~{} + / * \% = < > \& .} \verb+|+ \verb|@| \\
+                    Operator & les opérateurs suivants : \texttt{!= == << >> - \~{} + / * \% = < > \& .} \verb+|+ |@| \\
   Operator.Word & les opérateurs suivants : |in|, |is|, |and|, |or| et |not| \\
   Name.Builtin & la plupart des fonctions prédéfinies par Python \\
   Name.Decorator & les décorateurs (instructions débutant par \verb|@|) \\
@@ -2239,12 +2242,12 @@
 String.Long & les chaînes de caractères (entre \texttt{"}) \\
 String.Interpol &  les éléments \texttt{\%d}, \texttt{\%i}, \texttt{\%f}, \texttt{\%c}, etc. dans les chaînes de
                   caractères ; ce style hérite du style |String.Long| \\
-Operator & les opérateurs suivants : \texttt{!= == << >> - \~{} + / * \% = < > \& .} \verb+|+ \verb|@| \\
+Operator & les opérateurs suivants : \texttt{!= == << >> - \~{} + / * \% = < > \& .} \verb+|+ |@| \\
 Name.Type & les types prédéfinis suivants :
   |bool|, |char|, |char16_t|, |char32_t|, |double|, |float|, |int|, |int8_t|, |int16_t|, |int32_t|, 
   |int64_t|, |long|, |short|, |signed|, |unsigned|, |void| et |wchar_t| \\ 
 Name.Builtin & les fonctions prédéfinies suivantes : |printf|, |scanf|, |malloc|, |sizeof| et  |alignof|  \\
-  Name.Class & le nom des classes au moment de leur définition, c'est-à-dire après le mot-clé \verb|class| \\
+  Name.Class & le nom des classes au moment de leur définition, c'est-à-dire après le mot-clé |class| \\
 Name.Function & le nom des fonctions définies par l'utilisateur \emph{au moment de leur définition} \\
 UserFunction & le nom des fonctions précédemment définies par l'utilisateur (la valeur initiale de ce paramètre est
                vide et ces éléments sont affichés en noir --- ou plutôt dans la couleur courante) \\

Modified: branches/branch2023.final/Master/texmf-dist/doc/lualatex/piton/piton.pdf
===================================================================
(Binary files differ)

Modified: branches/branch2023.final/Master/texmf-dist/source/lualatex/piton/piton.dtx
===================================================================
--- branches/branch2023.final/Master/texmf-dist/source/lualatex/piton/piton.dtx	2024-02-20 21:08:54 UTC (rev 70028)
+++ branches/branch2023.final/Master/texmf-dist/source/lualatex/piton/piton.dtx	2024-02-20 21:09:04 UTC (rev 70029)
@@ -72,12 +72,12 @@
 % \iffalse
 %<*STY>
 % \fi
-\def\PitonFileVersion{2.4}
-\def\PitonFileDate{2024/01/15}
+\def\PitonFileVersion{2.5}
+\def\PitonFileDate{2024/02/20}
 % \iffalse
 %</STY>
 %<*LUA>
--- Version 2.4 of 2024/01/15
+-- Version 2.5 of 2024/02/20
 %</LUA>
 %\fi
 %
@@ -213,9 +213,8 @@
 % It's possible to insert only a part of the file: cf.
 % part~\ref{part-of-a-file}, p.~\pageref{part-of-a-file}. 
 %
-% \colorbox{yellow!50}{\textbf{New 2.2}}\enskip The key |path| of the command
-% |\PitonOptions| specifies a path where the files included by |\PitonInputFile|
-% will be searched. 
+% The key |path| of the command |\PitonOptions| specifies a path where the files
+% included by |\PitonInputFile| will be searched.
 % \end{itemize}
 %
 % \subsection{The syntax of the command \textbackslash piton}
@@ -331,8 +330,8 @@
 % considered (that key is case-insensitive). Five values are allowed :
 % |Python|, |OCaml|, |C|, |SQL| and |minimal|. The initial value is |Python|.
 % 
-% \item \index{path} The key \Definition{path} specifies a path where the files included by
-% |\PitonInputFile| will be searched.
+% \item \index{path} The key \Definition{path} specifies a path where the files
+% included by |\PitonInputFile| will be searched.
 % 
 % \item  \index{gobble} The key \Definition{gobble} takes in as value a
 % positive integer~$n$: the first $n$ characters are discarded (before the
@@ -360,6 +359,10 @@
 % and write the content of the current environment in that file. At the first
 % use of a file by \pkg{piton}, it is erased.
 %
+% \item \index{path-write}\colorbox{yellow!50}{\bfseries New 2.5}\enskip The key
+% \Definition{path-write} specifies a path where the files written by the key
+% |write| will be written.
+%
 % \item \index{line-numbers} The key \Definition{line-numbers} activates the
 % line numbering in the environments |{Piton}| and in the listings resulting
 % from the use of |\PitonInputFile|.
@@ -610,11 +613,11 @@
 % informatic language they use (Python, C, OCaml, etc.).
 % 
 % \bigskip
-% \colorbox{yellow!50}{\textbf{New 2.2}}\enskip But it's also possible to define
-% a style locally for a given informatic langage by providing the name of that
-% language as optional argument (between square brackets) to the command
-% |\SetPitonStyle|.\footnote{We recall, that, in the package \pkg{piton}, the
-% names of the informatic languages are case-insensitive.}
+% But it's also possible to define a style locally for a given informatic
+% langage by providing the name of that language as optional argument (between
+% square brackets) to the command |\SetPitonStyle|.\footnote{We recall, that, in
+% the package \pkg{piton}, the names of the informatic languages are
+% case-insensitive.}
 %
 % \bigskip
 % For example, with the command
@@ -1009,7 +1012,7 @@
 % identifiers.
 %
 % \smallskip
-% That command takes in three arguments: one 
+% That command takes in three arguments: 
 %
 % \begin{itemize}
 % \item The optionnal argument (within square brackets) specifies the informatic
@@ -1216,7 +1219,7 @@
 % \item The key |detected-commands| must be used in the preamble of the LaTeX document.
 % 
 % \item The names of the LaTeX commands must appear without the leading
-% backslash (eg. |detected-commands = { emph, bfseries }|). 
+% backslash (eg. |detected-commands = { emph, textbf }|). 
 %
 % \item These commands must be LaTeX commands with only one (mandatory) argument
 % between braces (and these braces must be explicit). 
@@ -2509,7 +2512,7 @@
 %    \end{macrocode}
 %
 % \medskip
-% The following boolean corresponds to the key |math-comments| (only at load-time).
+% The following boolean corresponds to the key |math-comments| (available only at load-time).
 %    \begin{macrocode}
 \bool_new:N \g_@@_math_comments_bool
 %    \end{macrocode}
@@ -2681,9 +2684,19 @@
 %    \end{macrocode}
 % 
 % \medskip
+% The following parameter corresponds to the key |path| (which is the path used
+% to include files by |\PitonInputFile|).
 %    \begin{macrocode}
 \str_new:N \l_@@_path_str
 %    \end{macrocode}
+%
+% \medskip
+% The following parameter corresponds to the key |path-write| (which is the path
+% used when writing files from listings inserted in the environments of
+% \pkg{piton} by use of the key |write|).
+%    \begin{macrocode}
+\str_new:N \l_@@_path_write_str
+%    \end{macrocode}
 % 
 % \medskip
 % In order to have a better control over the keys.
@@ -3417,7 +3430,7 @@
     comment-latex .value_required:n = true ,
     comment-latex .usage:n = preamble ,
 
-    math-comments .bool_set:N = \g_@@_math_comments_bool ,
+    math-comments .bool_gset:N = \g_@@_math_comments_bool ,
     math-comments .default:n  = true ,
     math-comments .usage:n = preamble , 
 %    \end{macrocode}
@@ -3430,6 +3443,8 @@
     language         .value_required:n  = true ,
     path             .str_set:N         = \l_@@_path_str ,
     path             .value_required:n  = true , 
+    path-write       .str_set:N         = \l_@@_path_write_str ,
+    path-write       .value_required:n  = true , 
     gobble           .int_set:N         = \l_@@_gobble_int , 
     gobble           .value_required:n  = true ,
     auto-gobble      .code:n            = \int_set:Nn \l_@@_gobble_int { -1 } , 
@@ -3958,7 +3973,12 @@
 % 
 % Now, the key |write|.
 %    \begin{macrocode}
-            \lua_now:e { piton.write = "\l_@@_write_str" } 
+            \str_if_empty:NTF \l_@@_path_write_str
+              { \lua_now:e { piton.write = "\l_@@_write_str" } }
+              { 
+                \lua_now:e 
+                 { piton.write = "\l_@@_path_write_str / \l_@@_write_str" } 
+              } 
             \str_if_empty:NF \l_@@_write_str
               { 
                 \seq_if_in:NVTF \g_@@_write_seq \l_@@_write_str 
@@ -3968,7 +3988,7 @@
                     \seq_gput_left:NV \g_@@_write_seq \l_@@_write_str
                   }
               }  
-            \vtop \bgroup 
+            \vbox \bgroup 
             \lua_now:e 
               { 
                 piton.GobbleParse
@@ -3980,7 +4000,7 @@
               } 
               { ##1 }
             \vspace { 2.5 pt } 
-            \egroup 
+            \egroup
             \bool_if:NT \g_@@_footnote_bool { \end { savenotes } } 
 %    \end{macrocode}
 % If the user has used the key |width| with the special value~|min|, we write on
@@ -4234,7 +4254,7 @@
 % \medskip
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_math_scantokens:n #1 
-  { \normalfont \scantextokens { $#1$ } }
+  { \normalfont \scantextokens { \begin{math} #1 \end{math} } }
 %    \end{macrocode}
 % 
 % \medskip
@@ -4294,12 +4314,10 @@
 \keys_define:nn { piton / Styles }
   {
     String          .meta:n = { String.Long = #1 , String.Short = #1 } ,
-    Comment.Math    .tl_set:c = pitonStyle Comment.Math , 
-    Comment.Math    .default:n = \@@_math_scantokens:n ,
-    Comment.Math    .initial:n = ,
-    ParseAgain      .tl_set:c = pitonStyle ParseAgain , 
+    Comment.Math    .tl_set:c = pitonStyle _ Comment.Math  ,
+    ParseAgain      .tl_set:c = pitonStyle _ ParseAgain , 
     ParseAgain      .value_required:n = true ,
-    ParseAgain.noCR .tl_set:c = pitonStyle ParseAgain.noCR , 
+    ParseAgain.noCR .tl_set:c = pitonStyle _ ParseAgain.noCR , 
     ParseAgain.noCR .value_required:n = true ,
     unknown         .code:n = 
       \@@_error:n { Unknown~key~for~SetPitonStyle }
@@ -4377,7 +4395,11 @@
 % However, maybe we will document in a future version the possibility to write
 % change the style \emph{locally} in a document)].
 %    \begin{macrocode}
-\bool_if:NT \g_@@_math_comments_bool { \SetPitonStyle { Comment.Math } }
+\AtBeginDocument 
+  { 
+    \bool_if:NT \g_@@_math_comments_bool 
+       { \SetPitonStyle { Comment.Math = \@@_math_scantokens:n } } 
+  }
 %    \end{macrocode}
 % 
 % \bigskip
@@ -4638,7 +4660,7 @@
 %   \begin{macrocode}
 \@@_msg_new:nn { syntax~error }
   {
-    Your~code~\l_piton_language_str\ is~not~syntactically~correct.\\
+    Your~code~of~the~language~"\l_piton_language_str"~is~not~syntactically~correct.\\ 
     It~won't~be~printed~in~the~PDF~file.
   }
 %    \end{macrocode}
@@ -4715,7 +4737,9 @@
     left-margin,~
     line-numbers/,~
     marker/,~
+    math-comments,~
     path,~
+    path-write,~
     prompt-background-color,~
     resume,~
     show-spaces,~
@@ -4722,8 +4746,8 @@
     show-spaces-in-strings,~
     splittable,~
     tabs-auto-gobble,~
-    tab-size,~width~
-    and~write.
+    tab-size,~
+    width~and~write.
   }
 %    \end{macrocode}
 %
@@ -4784,10 +4808,13 @@
 \directlua 
   {
     lpeg.locale(lpeg)
-    local P , alpha , C , Cf, space = lpeg.P , lpeg.alpha , lpeg.C , lpeg.Cf , lpeg.space
-    local One_P = space ^ 0 
-                  * C ( alpha ^ 1 ) / ( function (s) return P ( string.char(92) .. s ) end ) 
-                  * space ^ 0 
+    local P , alpha , C , Cf, space 
+      = lpeg.P , lpeg.alpha , lpeg.C , lpeg.Cf , lpeg.space 
+    local S = lpeg.S 
+    local One_P 
+      = space ^ 0 
+        * C ( alpha ^ 1 ) / ( function (s) return P ( string.char(92) .. s ) end ) 
+        * space ^ 0 
     function piton.addListCommands( key_value )
        piton.ListCommands =  
          piton.ListCommands + 
@@ -5014,10 +5041,10 @@
 % corresponding to the keys |begin-escape| and |end-escape|. 
 %    \begin{macrocode}
 local Word
-if piton.begin_escape ~= nil -- before : ''
+if piton.begin_escape ~= nil 
 then Word = Q ( ( ( 1 - space - P(piton.begin_escape) - P(piton.end_escape) ) 
-                   - S "'\"\r[()]" - digit ) ^ 1 )
-else Word = Q ( ( ( 1 - space ) - S "'\"\r[()]" - digit ) ^ 1 )
+                   - S "'\"\r[({})]" - digit ) ^ 1 )
+else Word = Q ( ( ( 1 - space ) - S "'\"\r[({})]" - digit ) ^ 1 )
 end
 %    \end{macrocode}
 %
@@ -5040,7 +5067,7 @@
 %
 % \bigskip
 %    \begin{macrocode}
-local Delim = Q ( S "[()]" )
+local Delim = Q ( S "[({})]" )
 %    \end{macrocode}
 % 
 % \bigskip
@@ -5911,7 +5938,7 @@
 
 local Keyword = 
   K ( 'Keyword' ,
-      P "assert" + P "as" + P "begin" + P "class" + P "constraint" + P "done" 
+      P "assert" + P "and" + P "as" + P "begin" + P "class" + P "constraint" + P "done" 
   + P "downto" + P "do" + P "else" + P "end" + P "exception" + P "external" 
   + P "for" + P "function" + P "functor" + P "fun"  + P "if" 
   + P "include" + P "inherit" + P "initializer" + P "in"  + P "lazy" + P "let" 
@@ -7029,6 +7056,8 @@
 % \subsubsection{The LPEG language Minimal}
 % 
 %    \begin{macrocode}
+local Punct = Q ( S ",:;!\\" )
+
 local CommentMath = 
   P "$" * K ( 'Comment.Math' , ( 1 - S "$\r" ) ^ 1  ) * P "$"
 
@@ -7155,6 +7184,8 @@
 
 local Identifier = K ( 'Identifier' , identifier )
 
+local Delim = Q ( S "{[()]}" )
+
 local MainMinimal = 
        EOL
      + Space 
@@ -7559,6 +7590,10 @@
 %
 % \verb|https://github.com/fpantigny/piton|
 %
+% \subsection*{Changes between versions 2.4 and 2.5}
+%
+% New key |path-write|
+%
 % \subsection*{Changes between versions 2.3 and 2.4}
 %
 % The key |identifiers| of the command |\PitonOptions| is now deprecated and

Modified: branches/branch2023.final/Master/texmf-dist/tex/lualatex/piton/piton.lua
===================================================================
--- branches/branch2023.final/Master/texmf-dist/tex/lualatex/piton/piton.lua	2024-02-20 21:08:54 UTC (rev 70028)
+++ branches/branch2023.final/Master/texmf-dist/tex/lualatex/piton/piton.lua	2024-02-20 21:09:04 UTC (rev 70029)
@@ -20,7 +20,7 @@
 -- -------------------------------------------
 -- 
 -- This file is part of the LuaLaTeX package 'piton'.
--- Version 2.4 of 2024/01/15
+-- Version 2.5 of 2024/02/20
 
 
 if piton.comment_latex == nil then piton.comment_latex = ">" end
@@ -91,10 +91,10 @@
       + digit^1
     )
 local Word
-if piton.begin_escape ~= nil -- before : ''
+if piton.begin_escape ~= nil
 then Word = Q ( ( ( 1 - space - P(piton.begin_escape) - P(piton.end_escape) )
-                   - S "'\"\r[()]" - digit ) ^ 1 )
-else Word = Q ( ( ( 1 - space ) - S "'\"\r[()]" - digit ) ^ 1 )
+                   - S "'\"\r[({})]" - digit ) ^ 1 )
+else Word = Q ( ( ( 1 - space ) - S "'\"\r[({})]" - digit ) ^ 1 )
 end
 local Space = ( Q " " ) ^ 1
 
@@ -104,7 +104,7 @@
 
 local Tab = P "\t" * Lc ( '\\l__piton_tab_tl' )
 local SpaceIndentation = Lc ( '\\__piton_an_indentation_space:' ) * ( Q " " )
-local Delim = Q ( S "[()]" )
+local Delim = Q ( S "[({})]" )
 local VisualSpace = space * Lc "\\l__piton_space_tl"
 local Beamer = P ( false )
 local BeamerBeginEnvironments = P ( true )
@@ -600,7 +600,7 @@
 
 local Keyword =
   K ( 'Keyword' ,
-      P "assert" + P "as" + P "begin" + P "class" + P "constraint" + P "done"
+      P "assert" + P "and" + P "as" + P "begin" + P "class" + P "constraint" + P "done"
   + P "downto" + P "do" + P "else" + P "end" + P "exception" + P "external"
   + P "for" + P "function" + P "functor" + P "fun"  + P "if"
   + P "include" + P "inherit" + P "initializer" + P "in"  + P "lazy" + P "let"
@@ -1325,6 +1325,8 @@
        * Lc '\\__piton_end_line:'
      )
 languages['sql'] = languageSQL
+local Punct = Q ( S ",:;!\\" )
+
 local CommentMath =
   P "$" * K ( 'Comment.Math' , ( 1 - S "$\r" ) ^ 1  ) * P "$"
 
@@ -1449,6 +1451,8 @@
 
 local Identifier = K ( 'Identifier' , identifier )
 
+local Delim = Q ( S "{[()]}" )
+
 local MainMinimal =
        EOL
      + Space

Modified: branches/branch2023.final/Master/texmf-dist/tex/lualatex/piton/piton.sty
===================================================================
--- branches/branch2023.final/Master/texmf-dist/tex/lualatex/piton/piton.sty	2024-02-20 21:08:54 UTC (rev 70028)
+++ branches/branch2023.final/Master/texmf-dist/tex/lualatex/piton/piton.sty	2024-02-20 21:09:04 UTC (rev 70029)
@@ -19,8 +19,8 @@
 %% LaTeX version 2005/12/01 or later.
 %% -------------------------------------------
 %% 
-\def\PitonFileVersion{2.4}
-\def\PitonFileDate{2024/01/15}
+\def\PitonFileVersion{2.5}
+\def\PitonFileDate{2024/02/20}
 
 
 \NeedsTeXFormat{LaTeX2e}
@@ -165,6 +165,7 @@
 \str_new:N \l_piton_language_str
 \str_set:Nn \l_piton_language_str { python }
 \str_new:N \l__piton_path_str
+\str_new:N \l__piton_path_write_str
 \bool_new:N \l__piton_in_PitonOptions_bool
 \bool_new:N \l__piton_in_PitonInputFile_bool
 \int_new:N \l__piton_nb_lines_int
@@ -511,7 +512,7 @@
     comment-latex .value_required:n = true ,
     comment-latex .usage:n = preamble ,
 
-    math-comments .bool_set:N = \g__piton_math_comments_bool ,
+    math-comments .bool_gset:N = \g__piton_math_comments_bool ,
     math-comments .default:n  = true ,
     math-comments .usage:n = preamble ,
     language         .code:n =
@@ -519,6 +520,8 @@
     language         .value_required:n  = true ,
     path             .str_set:N         = \l__piton_path_str ,
     path             .value_required:n  = true ,
+    path-write       .str_set:N         = \l__piton_path_write_str ,
+    path-write       .value_required:n  = true ,
     gobble           .int_set:N         = \l__piton_gobble_int ,
     gobble           .value_required:n  = true ,
     auto-gobble      .code:n            = \int_set:Nn \l__piton_gobble_int { -1 } ,
@@ -874,7 +877,12 @@
             \ttfamily
             \dim_zero:N \parskip
             \bool_if:NT \g__piton_footnote_bool { \begin { savenotes } }
-            \lua_now:e { piton.write = "\l__piton_write_str" }
+            \str_if_empty:NTF \l__piton_path_write_str
+              { \lua_now:e { piton.write = "\l__piton_write_str" } }
+              {
+                \lua_now:e
+                 { piton.write = "\l__piton_path_write_str / \l__piton_write_str" }
+              }
             \str_if_empty:NF \l__piton_write_str
               {
                 \seq_if_in:NVTF \g__piton_write_seq \l__piton_write_str
@@ -884,7 +892,7 @@
                     \seq_gput_left:NV \g__piton_write_seq \l__piton_write_str
                   }
               }
-            \vtop \bgroup
+            \vbox \bgroup
             \lua_now:e
               {
                 piton.GobbleParse
@@ -1049,7 +1057,7 @@
     \str_clear:N \l__piton_SetPitonStyle_option_str
   }
 \cs_new_protected:Npn \__piton_math_scantokens:n #1
-  { \normalfont \scantextokens { $#1$ } }
+  { \normalfont \scantextokens { \begin{math} #1 \end{math} } }
 \clist_new:N \g__piton_style_clist
 \clist_set:Nn \g__piton_styles_clist
   {
@@ -1105,12 +1113,10 @@
 \keys_define:nn { piton / Styles }
   {
     String          .meta:n = { String.Long = #1 , String.Short = #1 } ,
-    Comment.Math    .tl_set:c = pitonStyle Comment.Math ,
-    Comment.Math    .default:n = \__piton_math_scantokens:n ,
-    Comment.Math    .initial:n = ,
-    ParseAgain      .tl_set:c = pitonStyle ParseAgain ,
+    Comment.Math    .tl_set:c = pitonStyle _ Comment.Math  ,
+    ParseAgain      .tl_set:c = pitonStyle _ ParseAgain ,
     ParseAgain      .value_required:n = true ,
-    ParseAgain.noCR .tl_set:c = pitonStyle ParseAgain.noCR ,
+    ParseAgain.noCR .tl_set:c = pitonStyle _ ParseAgain.noCR ,
     ParseAgain.noCR .value_required:n = true ,
     unknown         .code:n =
       \__piton_error:n { Unknown~key~for~SetPitonStyle }
@@ -1155,7 +1161,11 @@
     ParseAgain.noCR    = \__piton_piton_no_cr:n ,
     ParseAgain         = \__piton_piton:n ,
   }
-\bool_if:NT \g__piton_math_comments_bool { \SetPitonStyle { Comment.Math } }
+\AtBeginDocument
+  {
+    \bool_if:NT \g__piton_math_comments_bool
+       { \SetPitonStyle { Comment.Math = \__piton_math_scantokens:n } }
+  }
 \NewDocumentCommand { \SetPitonIdentifier } { o m m }
   {
     \clist_set:Nn \l_tmpa_clist { #2 }
@@ -1301,7 +1311,7 @@
   }
 \__piton_msg_new:nn { syntax~error }
   {
-    Your~code~\l_piton_language_str\ is~not~syntactically~correct.\\
+    Your~code~of~the~language~"\l_piton_language_str"~is~not~syntactically~correct.\\
     It~won't~be~printed~in~the~PDF~file.
   }
 \NewDocumentCommand \PitonSyntaxError { }
@@ -1357,7 +1367,9 @@
     left-margin,~
     line-numbers/,~
     marker/,~
+    math-comments,~
     path,~
+    path-write,~
     prompt-background-color,~
     resume,~
     show-spaces,~
@@ -1364,8 +1376,8 @@
     show-spaces-in-strings,~
     splittable,~
     tabs-auto-gobble,~
-    tab-size,~width~
-    and~write.
+    tab-size,~
+    width~and~write.
   }
 \__piton_msg_new:nn { label~with~lines~numbers }
   {
@@ -1397,10 +1409,13 @@
 \directlua
   {
     lpeg.locale(lpeg)
-    local P , alpha , C , Cf, space = lpeg.P , lpeg.alpha , lpeg.C , lpeg.Cf , lpeg.space
-    local One_P = space ^ 0
-                  * C ( alpha ^ 1 ) / ( function (s) return P ( string.char(92) .. s ) end )
-                  * space ^ 0
+    local P , alpha , C , Cf, space
+      = lpeg.P , lpeg.alpha , lpeg.C , lpeg.Cf , lpeg.space
+    local S = lpeg.S
+    local One_P
+      = space ^ 0
+        * C ( alpha ^ 1 ) / ( function (s) return P ( string.char(92) .. s ) end )
+        * space ^ 0
     function piton.addListCommands( key_value )
        piton.ListCommands =
          piton.ListCommands +



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