texlive[71132] Master/texmf-dist: piton (29apr24)

commits+karl at tug.org commits+karl at tug.org
Mon Apr 29 22:32:02 CEST 2024


Revision: 71132
          https://tug.org/svn/texlive?view=revision&revision=71132
Author:   karl
Date:     2024-04-29 22:32:02 +0200 (Mon, 29 Apr 2024)
Log Message:
-----------
piton (29apr24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/lualatex/piton/README.md
    trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.pdf
    trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex
    trunk/Master/texmf-dist/doc/lualatex/piton/piton.pdf
    trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx
    trunk/Master/texmf-dist/tex/lualatex/piton/piton.lua
    trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty

Modified: trunk/Master/texmf-dist/doc/lualatex/piton/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/piton/README.md	2024-04-29 20:31:51 UTC (rev 71131)
+++ trunk/Master/texmf-dist/doc/lualatex/piton/README.md	2024-04-29 20:32:02 UTC (rev 71132)
@@ -11,7 +11,7 @@
 
 ## Presentation
 
-The LaTeX package `piton` provides a command `\piton` and an environment `{Piton}` to typeset Python, OCaml, SQL or C++  codes by using the Lua library LPEG. It requires the use of `lualatex`. It won't work with `xelatex` nor `pdflatex`. 
+The package `piton` provides tools to typeset computer listings, with syntactic highlighting, by using the Lua library LPEG. It requires the use of `lualatex` and won't work with `xelatex` nor `pdflatex`. 
 
 
 

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

Modified: trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex	2024-04-29 20:31:51 UTC (rev 71131)
+++ trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex	2024-04-29 20:32:02 UTC (rev 71132)
@@ -70,11 +70,17 @@
       }
   } 
 
-
-
 \usepackage{makeidx}
 \makeindex
 
+\NewDocumentCommand{\Definition}{m}
+  {{\setlength{\fboxsep}{1pt}\colorbox{gray!20}{\ttfamily \vphantom{gl}#1}}}
+
+\NewDocumentCommand{\DefinitionCommand}{m}
+  {{\setlength{\fboxsep}{1pt}\colorbox{gray!20}{\ttfamily
+        \vphantom{gl}\textbackslash #1}}}
+
+
 \NewDocumentCommand{\indexcommand}{m}{\index{#1@\texttt{\textbackslash #1}}}
 
 \NewDocumentCommand{\indexenv}{m}{\index{#1@\texttt{\{#1\}}}}
@@ -101,9 +107,8 @@
 \maketitle
 
 \begin{abstract}
-L'extension \pkg{piton} propose des outils pour composer des codes informatiques en Python, OCaml, C et SQL avec
-une coloration syntaxique en utilisant la bibliothèque Lua LPEG. L'extension \pkg{piton} nécessite l'emploi de
-LuaLaTeX.
+L'extension \pkg{piton} propose des outils pour composer des codes informatiques avec coloration syntaxique. Elle
+nécessite l'emploi de la LuaLaTeX car le travail principal est fait en utilisant la bibliothèque Lua LPEG. 
 \end{abstract}
 
 
@@ -112,8 +117,8 @@
 
 L'extension \pkg{piton} utilise la librairie Lua nommée LPEG\footnote{LPEG est une librairie de capture de motifs
   (\emph{pattern-matching} en anglais) pour Lua, écrite en C, fondée sur les PEG (\emph{parsing expression
-    grammars}): \url{http://www.inf.puc-rio.br/~roberto/lpeg/}} pour «parser» le code Python, OCaml, C ou SQL et le
-composer avec un coloriage syntaxique. Comme elle utilise le Lua de LuaLaTeX, elle fonctionne uniquement avec |lualatex|
+    grammars}): \url{http://www.inf.puc-rio.br/~roberto/lpeg/}} pour «parser» des listings informatiques avec
+coloriage syntaxique. Comme elle utilise le Lua de LuaLaTeX, elle fonctionne uniquement avec |lualatex| 
 (et ne va pas fonctionner avec les autres moteurs de compilation LaTeX, que ce soit |latex|, |pdflatex| ou
 |xelatex|). Elle n'utilise aucun programme extérieur et la compilation ne requiert donc pas |--shell-escape|. La
 compilation est très rapide puisque tout le travail du parseur est fait par la librairie LPEG, écrite en C.
@@ -143,8 +148,16 @@
         return s 
 \end{Piton}
 
+\bigskip
+Les principaux concurrents de l'extension \pkg{piton} sont certainement les extensions bien connues \pkg{listings}
+et \pkg{minted}.
 
+\bigskip
+Le nom de cette extension (\pkg{piton}) a été choisi un peu arbitrairement en référence aux pitons d'alpinisme qui
+servent à gravir les montagnes.
 
+
+
 \section{Installation}
 
 L'extension \pkg{piton} est composée de deux fichiers : |piton.sty| et |piton.lua| (le fichier LaTeX |piton.sty|
@@ -162,9 +175,17 @@
 
 \subsection{Choix du langage}
 
-L'extension \pkg{piton} prend en charge quatre langages informatiques : Python, OCaml, SQL et C, ou plutôt \CC. Il
-prend aussi en charge un langage minimal appelé «|minimal|» : cf.~p.~\pageref{minimal}.
+Les langages informatiques pris en charge par \pkg{piton} se classent en deux catégories :
+\begin{itemize}
+\item les langages reconnus nativement par \pkg{piton} qui sont au nombre de cinq : Python, OCaml, SQL, C (ou 
+plutôt \CC) et un langage nommé |minimal|\footnote{Le langage |minimal| peut servir pour formater du pseudo-code
+  : cf.~p.~\pageref{minimal}.} ;
+\item les langages définis par l'utilisateur avec la commande |\NewPitonLanguage| décrite
+p.~\pageref{NewPitonLanguage} (les parseurs de ces langages ne pourront jamais être aussi précis que ceux proposés
+nativement par \pkg{piton)}.
+\end{itemize}
 
+
 \smallskip
 Par défaut, le langage est Python.
 
@@ -173,9 +194,13 @@
 On peut changer de langage avec la clé |language| de |\PitonOptions| : 
 
 \smallskip
-|\PitonOptions{language = C}|
+|\PitonOptions{language = OCaml}|
 
 \smallskip
+En fait, le nom des langages, pour \pkg{piton}, est toujours \textbf{insensible à la casse}. Dans cet exemple, on
+aurait tout aussi bien pu écrire |Ocaml| ou |ocaml|.
+
+\smallskip
 Pour les développeurs, précisons que le nom du langage courant est stocké (en minuscules) dans la variable publique
 L3 nommée |\l_piton_language_str|. 
 
@@ -192,7 +217,8 @@
 \smallskip
 Si, à la fin du prambule, l'extension \pkg{xcolor} n'a pas été chargée (par l'utilisateur ou par une extension
 chargée dans le préambule), \pkg{piton} charge l'extension \pkg{xcolor} avec |\usepackage{xcolor}|, c'est-à-dire
-sans aucune option. L'extension \pkg{piton} ne charge pas d'autre extension.
+sans aucune option. L'extension \pkg{piton} ne charge pas d'autre extension. Elle n'utilise pas de programme
+extérieur. 
 
 \subsection{Les commandes et environnements à la disposition de l'utilisateur}
 
@@ -214,7 +240,7 @@
 \item L'environnement \colorbox{gray!20}{\ttfamily \{Piton\}} doit être utilisé pour composer des codes de
 plusieurs lignes. Comme cet environnement prend son argument selon un mode verbatim, il ne peut pas être utilisé
 dans l'argument d'une commande LaTeX. Pour les besoins de personnalisation, il est possible de définir de nouveaux
-environnements similaires à |{Piton}| en utilisant la commande |\NewPitonEnvironment| : cf. partie
+environnements similaires à |{Piton}| en utilisant la commande \DefinitionCommand{NewPitonEnvironment} : cf. partie
 \ref{NewPitonEnvironment} p.~\pageref{NewPitonEnvironment}.
 
 \item La commande \colorbox{gray!20}{\ttfamily \textbackslash PitonInputFile} doit être utilisée pour insérer et
@@ -223,12 +249,9 @@
 Il est possible de n'insérer qu'une partie de ce fichier : cf. partie~\ref{part-of-a-file},
 p.~\pageref{part-of-a-file}.
 
+La clé \Definition{path} de la commande |\PitonOptions| permet de spécifier une \emph{liste} de chemins où sera
+recherché le fichier à inclure (dans cette liste, les chemins sont séparés par des virgules).
 
-\colorbox{yellow!50}{\textbf{Nouveau 2.8}}\par\nobreak
-
-La clé |path| de la commande |\PitonOptions| permet de spécifier une \emph{liste} de chemins où sera recherché le
-fichier à inclure (dans cette liste, les chemins sont séparés par des virgules).
-
 L'extension \pkg{piton} propose aussi des commandes \colorbox{gray!20}{\ttfamily\textbackslash PitonInputFileT}, 
 \colorbox{gray!20}{\ttfamily \textbackslash PitonInputFileF} et
 \colorbox{gray!20}{\ttfamily \textbackslash PitonInputFileTF} avec des arguments correspondant aux lettres |T| et
@@ -330,8 +353,6 @@
 
 \subsection{Les clés de la commande \textbackslash PitonOptions}
 
-\NewDocumentCommand{\Definition}{m}
-  {{\setlength{\fboxsep}{1pt}\colorbox{gray!20}{\ttfamily \vphantom{gl}#1}}}
 
 \indexcommand{PitonOptions}
 
@@ -577,8 +598,8 @@
 
 \bigskip
 \indexcommand{PitonStyle}
-La commande |\PitonStyle| prend en argument le nom d'un style et permet de récupérer la valeur (en tant que liste
-d'instructions LaTeX) de ce style.
+La commande \DefinitionCommand{PitonStyle} prend en argument le nom d'un style et permet de récupérer la valeur (en
+tant que liste d'instructions LaTeX) de ce style.
 
 \smallskip
 Par exemple, on peut écrire, dans le texte courant, |{\PitonStyle{Keyword}{function}}| et on aura 
@@ -599,7 +620,8 @@
 \begin{Verbatim}
 \SetPitonStyle{Comment = \color{gray}}
 \end{Verbatim}
-tous les commentaires (que ce soit en Python, en C, en OCaml, etc.) seront composés en gris.
+tous les commentaires (que ce soit en Python, en C, en OCaml, etc. ou dans un langage défini avec
+|\NewPitonLanguage|) seront composés en gris. 
 
 \bigskip
 Mais il est aussi possible de définir un style localement pour un certain langage informatique en passant le nom du
@@ -637,7 +659,7 @@
 changer la valeur de ce style, comme tous les autres styles, avec la commande |\SetPitonStyle|.
 
 \medskip
-Dans l'exemple suivant, on règle les styles |Name.Function| et |UserFunction| de manière à que ce, quand on clique
+Dans l'exemple suivant, on règle les styles |Name.Function| et |UserFunction| de manière à ce que, quand on clique
 sur le nom d'une fonction Python précédemment définie par l'utilisateur, on soit renvoyé vers la définition
 (informatique) de cette fonction. Cette programmation utilise les fonctions |\hypertarget| et |\hyperlink| de \pkg{hyperref}.
 
@@ -661,7 +683,7 @@
 \SetPitonStyle{Name.Function = \MyDefFunction, ~emphase#UserFunction@ = \MyUserFunction}
 \end{Verbatim}
 
-\bigskip
+\smallskip
 
 \begin{Piton}
 def transpose(v,i,j):
@@ -675,6 +697,10 @@
             transpose(v,i,i+1)
 \end{Piton}
 
+\medskip
+(Certains lecteurs de \textsc{pdf} affichent un cadre autour du mot |transpose| cliquable et d'autres non.) 
+
+
 \endgroup
 
 \PitonClearUserFunctions[Python]
@@ -683,9 +709,9 @@
 \begin{small}
 Bien sûr, la liste des noms de fonctions Python précédemment définies est gardée en mémoire de LuaLaTeX (de manière
 globale, c'est-à-dire indépendamment des groupes TeX). L'extension \pkg{piton} fournit une commande qui permet de
-vider cette liste : c'est la commande |\PitonClearUserFunctions|. Quand elle est utilisée sans argument, cette
+vider cette liste : c'est la commande \DefinitionCommand{PitonClearUserFunctions}. Quand elle est utilisée sans argument, cette
 commande s'applique à tous les langages informatiques utilisées par l'utilisateur mais on peut spécifier en
-argument optionnel (entre crochets) une liste de langages informatiques auquels elle s'appliquera.\footnote{On
+argument optionnel (entre crochets) une liste de langages informatiques auxquels elle s'appliquera.\footnote{On
   rappelle que, dans \pkg{piton}, les noms des langages informatiques ne sont pas sensibles à la casse. }
 \end{small}
 
@@ -742,7 +768,140 @@
     return x*x
 \end{Python}
 
+\section{Définition de nouveaux langages avec la syntaxe de listings}
 
+\indexcommand{NewPitonLanguage}
+\label{NewPitonLanguage}
+\index{listings@\pkg{listings} (extension)}
+
+\colorbox{yellow!50}{\textbf{Nouveau 3.0}}
+
+\medskip
+L'extension \pkg{listings} est une célèbre extension LaTeX pour formater des codes informatiques.  
+
+\medskip
+Elle propose une commande |\lstdefinelanguage| pour définir de nouveaux langages. Cette commande est aussi
+utilisée en interne par \pkg{listings} pour sa définition des languages (en fait, pour cela, \pkg{listings} utilise
+une commande nommée |\lst at definelanguage| mais celle-ci a la même syntaxe que |\lstdefinelanguage|).
+
+\medskip
+L'extension \pkg{piton} propose une commande \DefinitionCommand{NewPitonLanguage} pour définir de nouveaux
+langages (utilisables avec les outils de \pkg{piton}) avec quasiment la même syntaxe que |\lstdefinelanguage|.
+
+\medskip
+Précisons tout de suite que l'extension \pkg{piton} n'utilise \emph{pas} cette commande pour définir les langages
+qu'elle propose nativement (Python, C, OCaml, \CC\ et |minimal|), ce qui permet de proposer des parseurs plus puissants.
+
+\medskip
+Par exemple, dans le fichier |lstlang1.sty|, qui est un des fichiers de definition des langages proposés par défaut
+par \pkg{listings}, on trouve les instructions suivantes (dans la version 1.10a).
+
+\begin{Verbatim}[formatcom=\small\color{gray}]
+\lst~@definelanguage{Java}%
+  {morekeywords={abstract,boolean,break,byte,case,catch,char,class,%
+      const,continue,default,do,double,else,extends,false,final,%
+      finally,float,for,goto,if,implements,import,instanceof,int,%
+      interface,label,long,native,new,null,package,private,protected,%
+      public,return,short,static,super,switch,synchronized,this,throw,%
+      throws,transient,true,try,void,volatile,while},%
+   sensitive,%
+   morecomment=[l]//,%
+   morecomment=[s]{/*}{*/},%
+   morestring=[b]",%
+   morestring=[b]',%
+  }[keywords,comments,strings]
+\end{Verbatim}
+
+\medskip
+Pour définir un language nommé |Java| pour \pkg{piton}, il suffit d'écrire le code suivant, 
+{\bfseries où le dernier argument de |\lst at definelanguage|, qui est entre crochets, a été supprimé} 
+(en fait, les symboles \verb+%+ pourraient être supprimés sans problème).
+
+\begin{Verbatim}[formatcom=\small\color{gray}]
+~emphase#\NewPitonLanguage@{Java}%
+  {morekeywords={abstract,boolean,break,byte,case,catch,char,class,%
+      const,continue,default,do,double,else,extends,false,final,%
+      finally,float,for,goto,if,implements,import,instanceof,int,%
+      interface,label,long,native,new,null,package,private,protected,%
+      public,return,short,static,super,switch,synchronized,this,throw,%
+      throws,transient,true,try,void,volatile,while},%
+   sensitive,%
+   morecomment=[l]//,%
+   morecomment=[s]{/*}{*/},%
+   morestring=[b]",%
+   morestring=[b]',%
+  }
+\end{Verbatim}
+
+
+\NewPitonLanguage{Java}
+  {morekeywords={abstract,boolean,break,byte,case,catch,char,class,
+      const,continue,default,do,double,else,extends,false,final,
+      finally,float,for,goto,if,implements,import,instanceof,int,
+      interface,label,long,native,new,null,package,private,protected,
+      public,return,short,static,super,switch,synchronized,this,throw,
+      throws,transient,true,try,void,volatile,while},
+   sensitive,
+   morecomment=[l]//,
+   morecomment=[s]{/*}{*/},
+   morestring=[b]",
+   morestring=[b]',
+  }
+
+
+\medskip
+On peut alors utiliser le language Java comme n'importe quel autre langage prédéfini de \pkg{piton}. 
+
+Voici un exemple de code Java formaté dans un environnement~|{Piton}| avec la clé~|language=Java|.\footnote{On
+  rappelle que, pour \pkg{piton}, les noms de langages informatiques ne sont pas sensibles à la casse, ce qui fait
+  que l'on aurait pu aussi bien utiliser : |language=java|.}
+
+\bigskip
+\begingroup
+\small
+\PitonOptions{split-on-empty-lines}
+\begin{Piton}[language = Java]
+public class Cipher { // cryptage par le chiffre de César
+    public static void main(String[] args) {
+        String str = "The quick brown fox Jumped over the lazy Dog";
+        System.out.println( Cipher.encode( str, 12 ));
+        System.out.println( Cipher.decode( Cipher.encode( str, 12), 12 ));
+    }
+
+    public static String decode(String enc, int offset) {
+        return encode(enc, 26-offset);
+    }
+
+    public static String encode(String enc, int offset) {
+        offset = offset % 26 + 26;
+        StringBuilder encoded = new StringBuilder();
+        for (char i : enc.toCharArray()) {
+            if (Character.isLetter(i)) {
+                if (Character.isUpperCase(i)) {
+                    encoded.append((char) ('A' + (i - 'A' + offset) % 26 ));
+                } else {
+                    encoded.append((char) ('a' + (i - 'a' + offset) % 26 ));
+                }
+            } else {
+                encoded.append(i);
+            }
+        }
+        return encoded.toString();
+    }
+}
+\end{Piton}
+\endgroup
+
+\bigskip
+Les clés de la commande |\lstdeflinelanguage| de \pkg{listings} prises en charge par |\NewPitonLanguage| sont :
+|morekeywords|, |otherkeywords|, |sensitive|, |keywordsprefix|, |moretexcs|, |morestring| (avec les lettres |b|,
+|d|, |s| et |m|), |morecomment| (avec les lettres |i|, |l|, |s| et |n|), |moredelim| (avec les lettres |i|,
+|l|, |s|, |*| et |**|), |moredirectives|, |tag|, |alsodigit| et |alsoletter|.
+
+Pour la description de ces clés, on renvoie à la documentation de \pkg{listings} (taper |texdoc| |listings| dans un terminal). 
+
+
+
 \section{Fonctionnalités avancées}
 
 
@@ -756,7 +915,7 @@
 \index{split-on-empty-lines}
 \index{split-separation}
 
-Par défaut les listings produits par l'environnement |{Piton}| et par la commande |\PitonInputFile| sont
+Par défaut, les listings produits par l'environnement |{Piton}| et par la commande |\PitonInputFile| sont
 insécables.
 
 
@@ -764,9 +923,7 @@
 telles coupures. 
 
 \begin{itemize}
-\item \colorbox{yellow!50}{\textbf{Nouveau 2.7}}\par\nobreak
-
-La clé \Definition{split-on-empty-lines} autorise les coupures sur les lignes vides\footnote{Les lignes considérées
+\item La clé \Definition{split-on-empty-lines} autorise les coupures sur les lignes vides\footnote{Les lignes considérées
   comme vides sont celles qui ne comportent que des espaces.} du listing. Dans les listings informatiques, les
 lignes vides séparent le plus souvent les définitions des fonctions informatiques et il est donc souvent judicieux
 de pouvoir couper au niveau de ces lignes.
@@ -1003,7 +1160,7 @@
 \indexcommand{SetPitonIdentifier}
 \label{SetPitonIdentifier}
 
-La commande |\SetPitonIdentifier| permet de changer le formatage de certains identificateurs.
+La commande \DefinitionCommand{SetPitonIdentifier} permet de changer le formatage de certains identificateurs.
 
 \smallskip
 Cette commande prend trois arguments : un optionnel et deux obligatoires.
@@ -1128,7 +1285,7 @@
 
 \begin{itemize}
 \item Il est possible de changer le marquage syntaxique utilisé (qui vaut initialement~|#>|). Pour ce faire, il
-existe une clé |comment-latex|, \emph{disponible uniquement dans le préambule du document}, qui permet de choisir les
+existe une clé \Definition{comment-latex}, \emph{disponible uniquement dans le préambule du document}, qui permet de choisir les
 caractères qui (précédés par~|#|) serviront de marqueur syntaxique.
 
 Par exemple, avec le réglage suivant (fait dans le préambule du document) :
@@ -1201,8 +1358,8 @@
 \index{detected-commands (key)}
 \label{detected-commands}
 
-La clé |detected-commands| de |\PitonOptions| permet de spécifier une liste de noms de commandes LaTeX qui seront
-directement détectées par \pkg{piton}.
+La clé \Definition{detected-commands} de |\PitonOptions| permet de spécifier une liste de noms de commandes LaTeX
+qui seront directement détectées par \pkg{piton}.
 
 \begin{itemize}
 \item Cette clé |detected-commands| ne peut être utilisée que dans le préambule du document.
@@ -1211,7 +1368,7 @@
 (ex. : |detected-commands = { emph , textbf }|). 
 
 \item Ces commandes doivent être des commandes LaTeX à un seul argument obligatoire entre accolades (et ces
-accolades doivent être explicites).
+accolades doivent apparaître explicitement dans le listing).
 \end{itemize}
 
 \medskip
@@ -1548,13 +1705,13 @@
 l'extension \pkg{footnotehyper}.
 
 \smallskip
-Si \pkg{piton} est chargée avec l'option |footnote| (avec |\usepackage[footnote]{piton}|) l'extension
+Si \pkg{piton} est chargée avec l'option \Definition{footnote} (avec |\usepackage[footnote]{piton}|) l'extension
 \pkg{footnote} est chargée (si elle ne l'est pas déjà) et elle est utilisée pour extraire les notes de pied de
 page.
 
 \smallskip
-Si \pkg{piton} est chargée avec l'option |footnotehyper|, l'extension \pkg{footnotehyper} est chargée (si
-elle ne l'est pas déjà) et elle est utilisée pour extraire les notes de pied de page.
+Si \pkg{piton} est chargée avec l'option \Definition{footnotehyper}, l'extension \pkg{footnotehyper} est chargée
+(si elle ne l'est pas déjà) et elle est utilisée pour extraire les notes de pied de page.
 
 \smallskip
 Attention : Les extensions \pkg{footnote} et \pkg{footnotehyper} sont incompatibles.
@@ -1575,13 +1732,13 @@
 \smallskip
 Même s'il est recommandé d'indenter les listings Python avec des espaces (cf. PEP~8), \pkg{piton} accepte les
 caractères de tabulations (U+0009) en début de ligne. Chaque caractère U+0009 est remplacé par $n$ espaces. La
-valeur initiale de~$n$ est~4 mais on peut la changer avec la clé |tab-size| de |\PitonOptions|.
+valeur initiale de~$n$ est~4 mais on peut la changer avec la clé \Definition{tab-size} de |\PitonOptions|. 
 
 \smallskip
-Il existe aussi une clé |tabs-auto-gobble| qui détermine le nombre minimal de caractères U+0009 débutant chaque
-ligne (non vide) de l'environnement |{Piton}| et applique |gobble| avec cette valeur (avant le remplacement des
-caractères U+0009 par des espaces, bien entendu). Cette clé est donc similaire à la clé |auto-gobble| mais agit sur
-des caractères U+0009 au lieu de caractères U+0020 (espaces).
+Il existe aussi une clé \Definition{tabs-auto-gobble} qui détermine le nombre minimal de caractères U+0009 débutant
+chaque ligne (non vide) de l'environnement |{Piton}| et applique |gobble| avec cette valeur (avant le remplacement
+des caractères U+0009 par des espaces, bien entendu). Cette clé est donc similaire à la clé |auto-gobble| mais agit
+sur des caractères U+0009 au lieu de caractères U+0020 (espaces).
 
 
 \section{API pour les développeurs}
@@ -2444,6 +2601,39 @@
 
 \newpage
 
+\subsection{Les langages définis par la commande \textbackslash NewPitonLanguage}
+
+\indexcommand{NewPitonLanguage}
+
+\vspace{1cm}
+La commande |\NewPitonLanguage| qui permet de définir de nouveaux langages en utilisant la syntaxe de l'extension
+\pkg{listings} a été présentée p.~\pageref{NewPitonLanguage}.
+
+Tous les langages définis avec la commande |\NewPitonLanguage| partagent les mêmes styles.
+
+\vspace{1cm}
+
+\begin{center}
+\begin{tabularx}{0.9\textwidth}{@{}>{\ttfamily}l>{\raggedright\arraybackslash}X@{}}
+\toprule
+\normalfont Style  & Usage \\
+\midrule
+Number & les nombres \\
+String.Long & les chaînes de caractères définies dans |\NewPitonLanguage| par la clé |morestring| \\
+Comment & les commentaires définis dans |\NewPitonLanguage| par la clé |morecomment|  \\
+Comment.LaTeX & les commentaires qui sont composés par \pkg{piton} comme du code LaTeX (et
+                appelés simplement «commentaires LaTeX» dans ce document) \\
+Keyword & les mots-clés, définis dans |\NewPitonLanguage| par les clés |morekeywords| et |moretexcs| (et également la
+  clé |sensitive| qui indique si les mots-clés sont sensibles à la casse) \\ 
+Directive & les directives définies dans |\NewPitonLanguage| par la clé |moredirectives| \\
+\bottomrule
+\end{tabularx}
+\end{center}
+
+
+
+\newpage
+
 \phantomsection
 \addcontentsline{toc}{section}{Index}
 

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

Modified: trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx
===================================================================
--- trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx	2024-04-29 20:31:51 UTC (rev 71131)
+++ trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx	2024-04-29 20:32:02 UTC (rev 71132)
@@ -59,7 +59,14 @@
 
 \NewDocumentCommand{\indexenv}{m}{\index{#1@\texttt{\{#1\}}}}
 
+\NewDocumentCommand{\Definition}{m}
+  {{\setlength{\fboxsep}{1pt}\colorbox{gray!20}{\ttfamily \vphantom{gl}#1}}}
 
+\NewDocumentCommand{\DefinitionCommand}{m}
+  {{\setlength{\fboxsep}{1pt}\colorbox{gray!20}{\ttfamily
+        \vphantom{gl}\textbackslash #1}}}
+
+
 \PitonOptions{gobble=2}
 
 \EnableCrossrefs
@@ -72,12 +79,12 @@
 % \iffalse
 %<*STY>
 % \fi
-\def\PitonFileVersion{2.8}
-\def\PitonFileDate{2024/04/14}
+\def\PitonFileVersion{3.0}
+\def\PitonFileDate{2024/04/29}
 % \iffalse
 %</STY>
 %<*LUA>
-piton_version = "2.8" -- 2024/04/14
+piton_version = "3.0" -- 2024/04/29
 %</LUA>
 %\fi
 %
@@ -90,9 +97,8 @@
 % \maketitle
 %
 % \begin{abstract}
-% The package \pkg{piton} provides tools to typeset computer listings in Python,
-% OCaml, C and SQL with syntactic highlighting by using the Lua library LPEG. It
-% requires LuaLaTeX.
+% The package \pkg{piton} provides tools to typeset computer listings, with
+% syntactic highlighting, by using the Lua library LPEG. It requires LuaLaTeX.
 % \end{abstract}
 % 
 % 
@@ -103,12 +109,12 @@
 % The package \pkg{piton} uses the Lua library LPEG\footnote{LPEG is a
 % pattern-matching library for Lua, written in C, based on \emph{parsing
 % expression grammars}:
-% \url{http://www.inf.puc-rio.br/~roberto/lpeg/}} for parsing Python, OCaml, C
-% or SQL listings and typesets them with syntactic highlighting. Since it uses
-% the Lua of LuaLaTeX, it works with |lualatex| only (and won't work with the
-% other engines: |latex|, |pdflatex| and |xelatex|). It does not use external
-% program and the compilation does not require |--shell-escape|. The compilation
-% is very fast since all the parsing is done by the library LPEG, written in C. 
+% \url{http://www.inf.puc-rio.br/~roberto/lpeg/}} for parsing informatic
+% listings and typesets them with syntactic highlighting. Since it uses the Lua
+% of LuaLaTeX, it works with |lualatex| only (and won't work with the other
+% engines: |latex|, |pdflatex| and |xelatex|). It does not use external program
+% and the compilation does not require |--shell-escape|. The compilation is very
+% fast since all the parsing is done by the library LPEG, written in C. 
 % 
 % \bigskip
 % Here is an example of code typeset by \pkg{piton}, with the environment |{Piton}|.
@@ -134,8 +140,17 @@
 %             s += (-1)**k/(2*k+1)*x**(2*k+1)
 %         return s 
 %    \end{Piton}
+%
+%
+% \bigskip
+% The main alternatives to the package \pkg{piton} are probably the packages
+% \pkg{listings} and \pkg{minted}.
 % 
+% \bigskip
+% The name of this extension (\pkg{piton}) has been choosen arbitrarily by
+% reference to the pitons used by the climbers in alpinism.
 % 
+% 
 % \section{Installation}
 % 
 % The package \pkg{piton} is contained in two files: |piton.sty| and |piton.lua|
@@ -158,13 +173,22 @@
 % If, at the end of the preamble, the package \pkg{xcolor} has not been loaded
 % (by the final user or by another package), \pkg{piton} loads \pkg{xcolor} with
 % the instruction |\usepackage{xcolor}| (that is to say without any option).
-% The package \pkg{piton} doesn't load any other package.
+% The package \pkg{piton} doesn't load any other package. It does not any
+% exterior program.
 %
 % \subsection{Choice of the computer language}
 %
-% In current version, the package \pkg{piton} supports four computer languages:
-% Python, OCaml, SQL and C (in fact \CC). It supports also a special language
-% called ``|minimal|'': cf. p.~\pageref{minimal}.
+% The package \pkg{piton} supports two kinds of languages:
+% \begin{itemize}
+% \item the languages natively supported by \pkg{piton}, which are Python, OCaml,
+% C~(in fact \CC), SQL and a language called |minimal|\footnote{That language
+% |minimal| may be used to format pseudo-codes: cf. p.~\pageref{minimal}};
+% \item the languages defined by the final user by using the built-in command
+% |\NewPitonLanguage| described p.~\pageref{NewPitonLanguage} (the parsers of
+% those languages can't be as precise as those of the native languages supported
+% by \pkg{piton}).
+% \end{itemize}
+% 
 %
 % \smallskip
 % By default, the language used is Python.
@@ -172,9 +196,14 @@
 % \smallskip
 % \index{language (key)}
 % It's possible to change the current language with the command |\PitonOptions|
-% and its key |language|: |\PitonOptions{language = C}|.
+% and its key |language|: |\PitonOptions{language = OCaml}|.
 %
 % \smallskip
+% In fact, for \pkg{piton}, the names of the informatic languages are always
+% \textbf{case-insensitive}. In this example, we might have written |Ocaml| or
+% |ocaml|. 
+%
+% \smallskip
 % For the developpers, let's say that the name of the current language is stored
 % (in lower case) in the L3 public variable |\l_piton_language_str|.
 %
@@ -186,7 +215,7 @@
 %
 % \indexenv{Piton}
 % 
-% The package \pkg{piton} provides several tools to typeset Python code: the
+% The package \pkg{piton} provides several tools to typeset Python codes: the
 % command |\piton|, the environment |{Piton}| and the command |\PitonInputFile|.
 %
 % \begin{itemize}\setlength{\fboxsep}{1pt}
@@ -211,20 +240,16 @@
 % It's possible to insert only a part of the file: cf.
 % part~\ref{part-of-a-file}, p.~\pageref{part-of-a-file}. 
 %
+% The key \Definition{path} of the command |\PitonOptions| specifies a
+% \emph{list} of pathes where the files included by |\PitonInputFile| will be
+% searched. That list is comma separated.
 %
-% \colorbox{yellow!50}{\bfseries New 2.8}\par\nobreak
-%
-% 
-% The key |path| of the command |\PitonOptions| specifies a \emph{list} of
-% pathes where the files included by |\PitonInputFile| will be searched. That
-% list is comma separated.
-%
 % The extension \pkg{piton} also provides the commands
 % \colorbox{gray!20}{\ttfamily \textbackslash PitonInputFileT},
 % \colorbox{gray!20}{\ttfamily \textbackslash PitonInputFileF} and
 % \colorbox{gray!20}{\ttfamily \textbackslash PitonInputFileTF} with
 % supplementary arguments corresponding to the letters~|T| and~|F|. Those
-% arguments will be exectued if the file to include has been found (letter~|T|)
+% arguments will be executed if the file to include has been found (letter~|T|)
 % or not found (letter~|F|).
 % \end{itemize}
 %
@@ -323,8 +348,6 @@
 % \subsection{The keys of the command \textbackslash PitonOptions}
 %
 %
-% \NewDocumentCommand{\Definition}{m}
-%   {{\setlength{\fboxsep}{1pt}\colorbox{gray!20}{\ttfamily \vphantom{gl}#1}}}
 %
 % \indexcommand{PitonOptions}
 % 
@@ -554,10 +577,11 @@
 %
 % \subsubsection{Notion of style}
 %
-% The package \pkg{piton} provides the command |\SetPitonStyle| to customize the
-% different styles used to format the syntactic elements of the Python listings.
-% The customizations done by that command are limited to the current TeX
-% group.\footnote{We remind that a LaTeX environment is, in particular, a TeX group.}
+% The package \pkg{piton} provides the command
+% \DefinitionCommand{SetPitonStyle} to customize the different styles used to
+% format the syntactic elements of the Python listings. The customizations done
+% by that command are limited to the current TeX group.\footnote{We remind that
+% a LaTeX environment is, in particular, a TeX group.}
 %
 % \bigskip
 % \indexcommand{SetPitonStyle}
@@ -601,8 +625,9 @@
 %
 % \bigskip
 % \indexcommand{PitonStyle}
-% The command |\PitonStyle| takes in as argument the name of a style and allows
-% to retrieve the value (as a list of LaTeX instructions) of that style.
+% The command \DefinitionCommand{PitonStyle} takes in as argument the name of a
+% style and allows to retrieve the value (as a list of LaTeX instructions) of
+% that style.
 %
 % \smallskip
 % For example, it's possible to write |{\PitonStyle{Keyword}{function}}| and we
@@ -626,11 +651,12 @@
 % \SetPitonStyle{Comment = \color{gray}}
 % \end{Verbatim}
 % all the comments will be composed in gray in all the listings, whatever
-% informatic language they use (Python, C, OCaml, etc.).
+% informatic language they use (Python, C, OCaml, etc. or a language defined by
+% the command |\NewPitonLanguage|).
 % 
 % \bigskip
 % 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
+% language 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.}
@@ -694,7 +720,7 @@
 % \SetPitonStyle{Name.Function = \MyDefFunction, ~emphase#UserFunction@ = \MyUserFunction}
 % \end{Verbatim}
 %
-% \bigskip
+% \smallskip
 %
 % \begin{Piton}
 % def transpose(v,i,j):
@@ -710,6 +736,10 @@
 %
 % \endgroup
 %
+% \medskip
+% (Some \textsc{pdf} viewers display a frame around the clickable word
+% |transpose| but other do not.)
+%
 % \PitonClearUserFunctions[Python]
 %
 % \bigskip
@@ -717,12 +747,12 @@
 % Of course, the list of the names of Python functions previously défined is
 % kept in the memory of LuaLaTeX (in a global way, that is to say independently
 % of the TeX groups). The extension \pkg{piton} provides a command to clear that
-% list : it's the command |\PitonClearUserFunctions|. When it is used without
-% argument, that command is applied to all the informatic languages used by the
-% user but it's also possible to use it with an optional argument (between
-% square brackets) which is a list of informatic languages to which the command
-% will be applied.\footnote{We remind that, in \pkg{piton}, the name of the
-% informatic languages are case-insensitive.}
+% list : it's the command \DefinitionCommand{PitonClearUserFunctions}. When it
+% is used without argument, that command is applied to all the informatic
+% languages used by the user but it's also possible to use it with an optional
+% argument (between square brackets) which is a list of informatic languages to
+% which the command will be applied.\footnote{We remind that, in \pkg{piton},
+% the name of the informatic languages are case-insensitive.}
 % \end{small}
 % 
 % \subsection{Creation of new environments}
@@ -736,9 +766,10 @@
 % |\newenvironment| (of standard LaTeX) or |\NewDocumentEnvironment| (of
 % LaTeX3). 
 %
-% That's why \pkg{piton} provides a command |\NewPitonEnvironment|. That
-% command takes in three mandatory arguments. 
-
+% That's why \pkg{piton} provides a command
+% \DefinitionCommand{NewPitonEnvironment}. That command takes in three mandatory
+% arguments.
+%
 % That command has the same syntax as the classical environment
 % |\NewDocumentEnvironment|.\footnote{However, the specifier of argument |b|
 % (used to catch the body of the environment as a LaTeX argument) is
@@ -783,7 +814,149 @@
 %     return x*x
 % \end{Python}
 %
+% \section{Definition of new languages with the syntax of listings}
 %
+% \indexcommand{NewPitonLanguage}
+% \label{NewPitonLanguage}
+% \index{listings@\pkg{listings} (extension)}
+% \colorbox{yellow!50}{\textbf{New 3.0}}
+%
+% \medskip
+% The package \pkg{listings} is a famous LaTeX package to format informatic
+% listings.
+%
+% That package provides a command |\lstdefinelanguage| which allows the user to
+% define new languages. That command is also used by \pkg{listings} itself to
+% provide the definition of the predefined languages in \pkg{listings} (in fact,
+% for this task, \pkg{listings} uses a command called |\lst at definelanguage| but
+% that command has the same syntax as |\lstdefinelanguage|). 
+%
+% \medskip
+% The package \pkg{piton} provides a command
+% \DefinitionCommand{NewPitonLanguage} to define new languages (avaiblable in
+% |\piton|, |{Piton}|, etc.) with a syntax which is almost the same as the
+% syntax of~|\lstdefinelanguage|.
+%
+% Let's precise that \pkg{piton} does \emph{not} use that command to define the
+% languages provided natively (Python, OCaml, \CC, SQL and |minimal|), which
+% allows more powerful parsers.
+%
+% \medskip
+% For example, in the file |lstlang1.sty|, which is one of the definition files
+% of \pkg{listings}, we find the following instructions (in version 1.10a).
+% 
+%\begin{Verbatim}[formatcom=\small\color{gray}]
+% \lst~@definelanguage{Java}%
+%   {morekeywords={abstract,boolean,break,byte,case,catch,char,class,%
+%       const,continue,default,do,double,else,extends,false,final,%
+%       finally,float,for,goto,if,implements,import,instanceof,int,%
+%       interface,label,long,native,new,null,package,private,protected,%
+%       public,return,short,static,super,switch,synchronized,this,throw,%
+%       throws,transient,true,try,void,volatile,while},%
+%    sensitive,%
+%    morecomment=[l]//,%
+%    morecomment=[s]{/*}{*/},%
+%    morestring=[b]",%
+%    morestring=[b]',%
+%   }[keywords,comments,strings]
+% \end{Verbatim}
+%
+% \medskip
+% In order to define a language called |Java| for \pkg{piton}, one has only to
+% write the following code {\bfseries where the last argument of
+% |\lst at definelanguage|, between square brackets, has been discarded} (in fact,
+% the symbols \verb+%+ may be deleted without any problem).
+%
+% \begin{Verbatim}[formatcom=\small\color{gray}]
+% ~emphase#\NewPitonLanguage@{Java}%
+%   {morekeywords={abstract,boolean,break,byte,case,catch,char,class,%
+%       const,continue,default,do,double,else,extends,false,final,%
+%       finally,float,for,goto,if,implements,import,instanceof,int,%
+%       interface,label,long,native,new,null,package,private,protected,%
+%       public,return,short,static,super,switch,synchronized,this,throw,%
+%       throws,transient,true,try,void,volatile,while},%
+%    sensitive,%
+%    morecomment=[l]//,%
+%    morecomment=[s]{/*}{*/},%
+%    morestring=[b]",%
+%    morestring=[b]',%
+%   }
+% \end{Verbatim}
+%
+% 
+% \NewPitonLanguage{Java}
+%   {morekeywords={abstract,boolean,break,byte,case,catch,char,class,
+%       const,continue,default,do,double,else,extends,false,final,
+%       finally,float,for,goto,if,implements,import,instanceof,int,
+%       interface,label,long,native,new,null,package,private,protected,
+%       public,return,short,static,super,switch,synchronized,this,throw,
+%       throws,transient,true,try,void,volatile,while},
+%    sensitive,
+%    morecomment=[l]//,
+%    morecomment=[s]{/*}{*/},
+%    morestring=[b]",
+%    morestring=[b]',
+%   }
+%
+% \medskip
+% It's possible to use the language Java like any other language defined by
+% \pkg{piton}.
+%
+% Here is an example of code formatted in an environment |{Piton}| with
+% the key |language=Java|.\footnote{We recall that, for \pkg{piton}, the names
+% of the informatic languages are case-insensitive. Hence, it's possible to
+% write, for instance, |language=java|.}
+%
+% 
+% \bigskip
+% \begingroup
+% \small
+% \PitonOptions{split-on-empty-lines}
+% \begin{Piton}[language = java]
+% public class Cipher {  // Caesar cipher
+%     public static void main(String[] args) {
+%         String str = "The quick brown fox Jumped over the lazy Dog";
+%         System.out.println( Cipher.encode( str, 12 ));
+%         System.out.println( Cipher.decode( Cipher.encode( str, 12), 12 ));
+%     }
+%
+%     public static String decode(String enc, int offset) {
+%         return encode(enc, 26-offset);
+%     }
+%
+%     public static String encode(String enc, int offset) {
+%         offset = offset % 26 + 26;
+%         StringBuilder encoded = new StringBuilder();
+%         for (char i : enc.toCharArray()) {
+%             if (Character.isLetter(i)) {
+%                 if (Character.isUpperCase(i)) {
+%                     encoded.append((char) ('A' + (i - 'A' + offset) % 26 ));
+%                 } else {
+%                     encoded.append((char) ('a' + (i - 'a' + offset) % 26 ));
+%                 }
+%             } else {
+%                 encoded.append(i);
+%             }
+%         }
+%         return encoded.toString();
+%     }
+% }
+% \end{Piton}
+% \endgroup
+%
+% \bigskip
+
+% The keys of the command |\lstdeflinelanguage| of \pkg{listings} supported by |\NewPitonLanguage| are:
+% |morekeywords|, |otherkeywords|, |sensitive|, |keywordsprefix|, |moretexcs|,
+% |morestring| (with the letters |b|,
+% |d|, |s| and |m|), |morecomment| (with the letters |i|, |l|, |s| and |n|),
+% |moredelim| (with the letters |i|,
+% |l|, |s|, |*| and |**|), |moredirectives|, |tag|, |alsodigit| and |alsoletter|.
+%
+% For the description of those keys, we redirect the reader to the documentation
+% of the package \pkg{listings} (type |texdoc| |listings| in a terminal). 
+%
+%
 % \section{Advanced features}
 %
 % \subsection{Page breaks and line breaks}
@@ -800,8 +973,7 @@
 % and |splittable| to allow such breaks.
 %
 % \begin{itemize}
-% \item \colorbox{yellow!50}{\textbf{New 2.7}}\par\nobreak
-% The key \Definition{split-on-empty-lines} allows breaks on the empty
+% \item The key \Definition{split-on-empty-lines} allows breaks on the empty
 % lines\footnote{The ``empty lines'' are the lines which contains only spaes.} in
 % the listing. In the informatic listings, the empty lines usually seperate the
 % definitions of the informatic functions and it's pertinent to allow breaks
@@ -1059,8 +1231,8 @@
 %
 % \label{SetPitonIdentifier}
 %
-% The command |\SetPitonIdentifier| allows to change the formatting of some
-% identifiers.
+% The command \DefinitionCommand{SetPitonIdentifier} allows to change the
+% formatting of some identifiers.
 %
 % \smallskip
 % That command takes in three arguments: 
@@ -1067,8 +1239,8 @@
 %
 % \begin{itemize}
 % \item The optionnal argument (within square brackets) specifies the informatic
-% langage. If this argument is not present, the tunings done by
-% |\SetPitonIdentifier| will apply to all the informatic langages of
+% language. If this argument is not present, the tunings done by
+% |\SetPitonIdentifier| will apply to all the informatic languages of
 % \pkg{piton}.\footnote{We recall, that, in the package \pkg{piton}, the
 % names of the informatic languages are case-insensitive.}
 %
@@ -1187,9 +1359,9 @@
 %
 % \begin{itemize}
 % \item It's possible to change the syntatic mark (which, by default, is |#>|).
-% For this purpose, there is a key |comment-latex| available only in the
-% preamble of the document, allows to choice the characters which,
-% preceded by |#|, will be the syntatic marker.
+% For this purpose, there is a key \Definition{comment-latex} available only in
+% the preamble of the document, allows to choice the characters which, preceded
+% by |#|, will be the syntatic marker.
 %
 % For example, if the preamble contains the following instruction:
 % 
@@ -1260,7 +1432,7 @@
 % \index{detected-commands (key)}
 % \label{detected-commands}
 %
-% The key |detected-commands| of |\PitonOptions| allow to specify a
+% The key \Definition{detected-commands} of |\PitonOptions| allows to specify a
 % (comma-separated) list of names of LaTeX commands that will be detected 
 % directly by \pkg{piton}.
 %
@@ -1271,7 +1443,7 @@
 % 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). 
+% between braces (and these braces must appear explicitly in the informatic listing). 
 % \end{itemize}
 %
 % \medskip
@@ -1375,7 +1547,7 @@
 % of LaTeX, they are, in particular, composed within a TeX group and therefore,
 % they can't be used to change the formatting of other lexical units.
 %
-% In the langages where the character \verb|$| does not play a important role,
+% In the languages where the character \verb|$| does not play a important role,
 % it's possible to activate that mechanism ``|escape-math|'' with the character
 % \verb|$|:
 % \begin{Verbatim}
@@ -1609,15 +1781,15 @@
 % package \pkg{footnote} or the package \pkg{footnotehyper}.
 %
 % \smallskip
-% If \pkg{piton} is loaded with the option |footnote| (with
+% If \pkg{piton} is loaded with the option \Definition{footnote} (with
 % |\usepackage[footnote]{piton}| or with |\PassOptionsToPackage|), the
 % package \pkg{footnote} is loaded (if it is not yet loaded) and it is used to
 % extract the footnotes.
 %
 % \smallskip
-% If \pkg{piton} is loaded with the option |footnotehyper|, the package
-% \pkg{footnotehyper} is loaded (if it is not yet loaded) ant it is used to
-% extract footnotes.
+% If \pkg{piton} is loaded with the option \Definition{footnotehyper}, the
+% package \pkg{footnotehyper} is loaded (if it is not yet loaded) ant it is used
+% to extract footnotes.
 %
 % \smallskip
 % Caution: The packages \pkg{footnote} and \pkg{footnotehyper} are incompatible.
@@ -1641,15 +1813,15 @@
 % PEP~8), \pkg{piton} accepts the characters of tabulation (that is to say the
 % characters U+0009) at the beginning of the lines. Each character U+0009 is
 % replaced by $n$~spaces. The initial value of $n$ is $4$ but it's possible to
-% change it with the key |tab-size| of |\PitonOptions|.
+% change it with the key \Definition{tab-size} of |\PitonOptions|.
 %
 % \smallskip
-% There exists also a key |tabs-auto-gobble| which computes the minimal value
-% $n$ of the number of consecutive characters U+0009 beginning each (non empty)
-% line of the environment |{Piton}| and applies |gobble| with that value of~$n$
-% (before replacement of the tabulations by spaces, of course). Hence, that key
-% is similar to the key |auto-gobble| but acts on U+0009 instead of U+0020
-% (spaces).
+% There exists also a key \Definition{tabs-auto-gobble} which computes the
+% minimal value $n$ of the number of consecutive characters U+0009 beginning
+% each (non empty) line of the environment |{Piton}| and applies |gobble| with
+% that value of~$n$ (before replacement of the tabulations by spaces, of
+% course). Hence, that key is similar to the key |auto-gobble| but acts on
+% U+0009 instead of U+0020 (spaces).
 %
 %
 % \bigskip
@@ -2341,7 +2513,36 @@
 % for pseudo-code.
 %
 % \newpage
+% \subsection{The languages defined by \textbackslash NewPitonLanguage}
 %
+% \vspace{1cm}
+% The command |\NewPitonLanguage| which define new informatic languages with the
+% syntax of the extension \pkg{listings} has been described p.~\pageref{NewPitonLanguage}.
+%
+% All the languages defined by the command |\NewPitonLanguage| use the same styles.
+% \vspace{1cm}
+%
+% \begin{center}
+% \begin{tabularx}{0.9\textwidth}{@{}>{\ttfamily}l>{\raggedright\arraybackslash}X@{}}
+% \toprule
+% \normalfont Style  & Use \\
+% \midrule
+% Number & the numbers \\
+% String.Long & the strings defined in |\NewPitonLanguage| by the key |morestring| \\
+% Comment & the comments defined in |\NewPitonLanguage| by the key |morecomment|  \\
+% Comment.LaTeX & the comments which are composed by \pkg{piton} as LaTeX code (merely named ``LaTeX comments'' in this document) \\
+% Keyword & the keywords defined in |\NewPitonLanguage| by the keys |morekeywords|
+%           and |moretexcs| (and also the  key |sensitive| which specifies whether
+%           the keywords are case-sensitive or not) \\ 
+% Directive & the directives defined in |\NewPitonLanguage| by the key |moredirectives| \\
+% \bottomrule
+% \end{tabularx}
+% \end{center}
+%
+%
+%
+% \newpage
+%
 % \section{Implementation}
 %
 % \medskip
@@ -3808,12 +4009,111 @@
 %
 % \bigskip
 %    \begin{macrocode}
-\NewDocumentCommand { \NewPitonLanguage } { m m }
-  { \lua_now:e { piton.new_language("#1","\lua_escape:n{#2}") } }
+\NewDocumentCommand { \NewPitonLanguage } { O { } m ! o }
+  {
+    \tl_if_novalue:nTF { #3 }
 %    \end{macrocode}
+% The last argument is provided by curryfication.
+%    \begin{macrocode}
+      { \@@_NewPitonLanguage:nnn { #1 } { #2 } }
+%    \end{macrocode}
+% The two last arguments are provided by curryfication.
+%    \begin{macrocode}
+      { \@@_NewPitonLanguage:nnnnn { #1 } { #2 } { #3 } }
+  }
+%    \end{macrocode}
 % 
 % \bigskip
+% The following property list will contain the definitions of the informatic
+% languages as provided by the final user. However, if a language is defined
+% over another base language, the corresponding list will contain the \emph{whole}
+% definition of the language.
 %    \begin{macrocode}
+\prop_new:N \g_@@_languages_prop
+%    \end{macrocode}
+% 
+% \bigskip
+% The function |\@@_NewPitonLanguage:nnn| will be used when the language is
+% \emph{not} defined above a base language (and a base dialect).
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_NewPitonLanguage:nnn #1 #2 #3 
+  { 
+%    \end{macrocode}
+% We store in |\l_tmpa_tl| the name of the language with the potential dialect,
+% that is to say, for example : |[AspectJ]{Java}|. We use |\tl_if_blank:nF|
+% because the final user may have written |\NewPitonLanguage[ ]{Java}{...}|.
+%    \begin{macrocode}
+    \tl_set:Nx \l_tmpa_tl 
+      { 
+        \tl_if_blank:nF { #1 } { [ \str_lowercase:n { #1 } ] } 
+        \str_lowercase:n { #2 } 
+      }
+%    \end{macrocode}
+% We store in LaTeX the definition of the language because some languages may be
+% defined with that language as base language.
+%    \begin{macrocode}
+    \prop_gput:Non \g_@@_languages_prop \l_tmpa_tl { #3 }
+%    \end{macrocode}
+% The Lua part of the package \pkg{piton} will be loaded in a
+% |\AtBeginDocument|. Hence, we will put also in a |\AtBeginDocument| the
+% utilisation of the Lua function |piton.new_language| (which does the main job).
+%    \begin{macrocode}
+    \exp_args:NV \@@_NewPitonLanguage:nn \l_tmpa_tl { #3 }
+  }
+%    \end{macrocode}
+% 
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_NewPitonLanguage:nn #1 #2
+  {
+    \hook_gput_code:nnn { begindocument } { . }
+      { \lua_now:e { piton.new_language("#1","\lua_escape:n{#2}") } }
+  }
+%    \end{macrocode}
+%
+% \bigskip
+% Now the case when the language is defined upon a base language.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_NewPitonLanguage:nnnnn #1 #2 #3 #4 #5
+  {
+%    \end{macrocode}
+% We store in |\l_tmpa_tl| the name of the base language with the dialect, that
+% is to say, for example : |[AspectJ]{Java}|. We use |\tl_if_blank:nF| because
+% the final user may have used |\NewPitonLanguage[Handel]{C}[ ]{C}{...}|
+%    \begin{macrocode}
+    \tl_set:Nx \l_tmpa_tl 
+      { 
+         \tl_if_blank:nF { #3 } { [ \str_lowercase:n { #3 } ] } 
+         \str_lowercase:n { #4 }
+      } 
+%    \end{macrocode}
+% We retrieve in |\l_tmpb_tl| the definition (as provided by the final user) of
+% that base language. Caution: |\g_@@_languages_prop| does not contain all the
+% languages provided by \pkg{piton} but only those defined by using
+% |\NewPitonLanguage|. 
+%    \begin{macrocode}
+     \prop_get:NoNTF \g_@@_languages_prop \l_tmpa_tl \l_tmpb_tl 
+%    \end{macrocode}
+% We can now define the new language by using the previous function.
+%    \begin{macrocode}
+       { \@@_NewPitonLanguage:nnno { #1 } { #2 } { #5 } \l_tmpb_tl }
+       { \@@_error:n { Language~not~defined } }
+  }
+%    \end{macrocode}
+%
+%  \bigskip
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_NewPitonLanguage:nnnn #1 #2 #3 #4
+%    \end{macrocode}
+% In the following line, we write |#4,#3| and not |#3,#4| because we want that the
+% keys which correspond to base language appear before the keys which are added
+% in the language we define.
+%    \begin{macrocode}
+  { \@@_NewPitonLanguage:nnn { #1 } { #2 } { #4 , #3 } }
+\cs_generate_variant:Nn \@@_NewPitonLanguage:nnnn { n n n o }
+%    \end{macrocode}
+% 
+% \bigskip
+%    \begin{macrocode}
 \NewDocumentCommand { \piton } { }
   { \peek_meaning:NTF \bgroup \@@_piton_standard \@@_piton_verbatim }
 %    \end{macrocode}
@@ -4514,7 +4814,7 @@
 % Now, specific styles for the languages created with |\NewPitonLanguage| with
 % the syntax of \pkg{listings}.
 %    \begin{macrocode}
-    directive
+    Directive
   }  
 
 \clist_map_inline:Nn \g_@@_styles_clist  
@@ -4602,7 +4902,7 @@
     TypeParameter      = \color[HTML]{336666} \itshape ,
     Preproc            = \color[HTML]{AA6600} \slshape ,
     Identifier         = \@@_identifier:n , 
-    directive          = \color[HTML]{AA6600} ,
+    Directive          = \color[HTML]{AA6600} ,
     UserFunction       = , 
     Prompt             = , 
     ParseAgain.noCR    = \@@_piton_no_cr:n , 
@@ -4787,7 +5087,19 @@
 % \bigskip
 % \subsubsection{The error messages of the package}
 % 
+%
 %    \begin{macrocode}
+\@@_msg_new:nn { Language~not~defined }
+  { 
+    Language~not~defined \\
+    The~language~'\l_tmpa_tl'~has~not~been~defined~previoulsy.\\
+    If~you~go~on,~your~command~\token_to_str:N \NewPitonLanguage\ 
+    will~be~ignored.
+  }
+%    \end{macrocode}
+%
+% 
+%    \begin{macrocode}
 \@@_msg_new:nn { bad~version~of~piton.lua }
   {
     Bad~number~version~of~'piton.lua'\\
@@ -6529,12 +6841,12 @@
   K ( 'Name.Type' ,
       P "bool" + "char" + "char16_t" + "char32_t" + "double" + "float" + "int" +
       "int8_t" + "int16_t" + "int32_t" + "int64_t" + "long" + "short" + "signed"
-      + "unsigned" + "void" + "wchar_t" )
+      + "unsigned" + "void" + "wchar_t" ) * Q "*" ^ 0 
 
 local DefFunction = 
   Type 
   * Space 
-  * Q "*" ^ -1 
+  * Q "*" ^ -1
   * K ( 'Name.Function.Internal' , identifier ) 
   * SkipSpace 
   * # P "("
@@ -7394,7 +7706,7 @@
 %    \end{macrocode}
 % 
 % \bigskip
-% Of course, the \textsc{lpeg} |b_braces| is for balanced braces (without the
+% Of course, the \textsc{lpeg} |strict_braces| is for balanced braces (without the
 % question of strings of an informatic language). In fact, it \emph{won't} be
 % used for an informatic language (as dealt by \pkg{piton}) but for LaTeX
 % instructions; 
@@ -7419,7 +7731,7 @@
   local def_table = cut_definition : match ( definition )
 %    \end{macrocode}
 % The definition of the language, provided by the final user of \pkg{piton} is
-% now in the Lua table |def_table|. We will use it several times.
+% now in the Lua table |def_table|. We will use it \emph{several times}.
 %
 % \medskip
 % The following \textsc{lpeg} will be used to extract arguments in the values of
@@ -7551,18 +7863,18 @@
         local keywords = P ( false )
 %    \end{macrocode}
 %    \begin{macrocode}
-        local style = [[ \PitonStyle{Keyword} ]]
-        if x[1] == "moredirectives" then style = [[ \PitonStyle{directive} ]] end
+        local style = [[\PitonStyle{Keyword}]]
+        if x[1] == "moredirectives" then style = [[ \PitonStyle{Directive} ]] end
         style =  tex_option_arg : match ( x[2] ) or style
-        local n = tonumber (style )
+        local n = tonumber ( style )
         if n then 
-         if n > 1 then style = [[ \PitonStyle{Keyword ]] .. style .. "}" end
+          if n > 1 then style = [[\PitonStyle{Keyword]] .. style .. "}" end
         end 
 %    \end{macrocode}
 %    \begin{macrocode}
         for _ , word in ipairs ( split_clist : match ( x[2] ) ) do
           if x[1] == "moretexcs" then
-            keywords = Q ( [[ \ ]] .. word ) + keywords
+            keywords = Q ( [[\]] .. word ) + keywords
           else 
             if sensitive 
 %    \end{macrocode}
@@ -7597,44 +7909,42 @@
   for _ , x in ipairs ( def_table ) do
     if x[1] == "morestring" then
       arg1 , arg2 , arg3 , arg4 = args_for_morekeywords : match ( x[2] ) 
-      arg2 = arg2 or [[ \PitonStyle{String.Long} ]]
-      if arg1 == "s" then
-        long_string =
-          Q ( arg3 ) 
-          * ( Q ( ( 1 - P ( arg4 ) - S "$\r" ) ^ 1 ) -- $
-              + EOL 
-            ) ^ 0  
-          * Q ( arg4 ) 
-      else  
-        central_pattern = 1 - S ( " \r" .. arg3 ) 
-        if arg1 : match "b" then 
-          central_pattern = P ( [[ \ ]] .. arg3 )  + central_pattern
-        end
+      arg2 = arg2 or [[\PitonStyle{String.Long}]]
+      if arg1 ~= "s" then 
+        arg4 = arg3 
+      end 
+      central_pattern = 1 - S ( " \r" .. arg4 ) 
+      if arg1 : match "b" then 
+        central_pattern = P ( [[\]] .. arg3 ) + central_pattern
+      end
 %    \end{macrocode}
 % In fact, the specifier |d| is point-less: when it is not in force, it's still
 % possible to double the delimiter with a correct behaviour of \pkg{piton}
 % since, in that case, \pkg{piton} will compose \emph{two} contiguous strings...
 %    \begin{macrocode}
-        if arg1 : match "d" or arg1 == "m" then 
-          central_pattern = P ( arg3 .. arg3 )  + central_pattern
-        end
-        if arg1 == "m" 
-        then prefix = P ( false ) 
-        else prefix = lpeg.B ( 1 - letter - ")" - "]" ) 
-        end
+      if arg1 : match "d" or arg1 == "m" then 
+        central_pattern = P ( arg3 .. arg3 ) + central_pattern
+      end
+      if arg1 == "m" 
+      then prefix = lpeg.B ( 1 - letter - ")" - "]" ) 
+      else prefix = P ( true ) 
+      end
 %    \end{macrocode}
+% We can write the pattern which matches the string.
+%    \begin{macrocode}
+     local pattern = 
+         prefix 
+         * Q ( arg3 ) 
+         * ( VisualSpace + Q ( central_pattern ^ 1 ) + EOL ) ^ 0 
+         * Q ( arg4 ) 
+%    \end{macrocode}
 % First, we create |long_string| because we need that \textsc{lpeg} in the
 % nested comments.
 %    \begin{macrocode}
-        long_string = long_string +
-           prefix 
-           * Q ( arg3 ) 
-           * ( VisualSpace + Q ( central_pattern ^ 1 ) + EOL ) ^ 0 
-           * Q ( arg3 ) 
-      end
+      long_string = long_string + pattern 
       LongString = LongString +
          Ct ( Cc "Open" * Cc ( "{" ..  arg2 .. "{" ) * Cc "}}" )
-         * long_string 
+         * pattern
          * Ct ( Cc "Close" ) 
     end 
   end
@@ -7655,12 +7965,12 @@
   for _ , x in ipairs ( def_table ) do
     if x[1] == "morecomment" then 
       local arg1 , arg2 , other_args = args_for_morecomment : match ( x[2] ) 
-      arg2 = arg2 or [[ \PitonStyle{Comment} ]]
+      arg2 = arg2 or [[\PitonStyle{Comment}]]
 %    \end{macrocode}
 % If the letter |i| is present in the first argument (eg: 
 % |morecomment = [si]{(*}{*)}|, then the corresponding comments are discarded. 
 %    \begin{macrocode}
-      if arg1 : match "i" then arg2 = [[ \PitonStyle{Discard} ]] end
+      if arg1 : match "i" then arg2 = [[\PitonStyle{Discard}]] end
       if arg1 : match "l" then 
         local arg3 = ( tex_braced_arg + C ( P ( 1 ) ^ 0 * -1 ) )
                      : match ( other_args ) 
@@ -7772,8 +8082,12 @@
        + Beamer
        + DetectedCommands
        + CommentDelim
+%    \end{macrocode}
+% We must put |LongString| before |Delim| because, in PostScript, the strings
+% are delimited by parenthesis and those parenthesis would be catched by |Delim|.
+%    \begin{macrocode}
+       + LongString
        + Delim
-       + LongString
        + Keyword * ( Space + Punct + Delim + EOL + -1 ) 
        + Punct 
        + K ( 'Identifier' , letter * alphanum ^ 0 )
@@ -7802,11 +8116,11 @@
     Ct (
          ( space ^ 0 * P "\r" ) ^ -1 
          * BeamerBeginEnvironments 
-         * Lc [[ \@@_begin_line: ]]
+         * Lc [[\@@_begin_line:]]
          * SpaceIndentation ^ 0 
          * LPEG1[lang]
          * -1 
-         * Lc [[ \@@_end_line: ]]
+         * Lc [[\@@_end_line:]]
        )
 %    \end{macrocode}
 %
@@ -7855,11 +8169,11 @@
       Ct (
            ( space ^ 0 * P "\r" ) ^ -1 
            * BeamerBeginEnvironments 
-           * Lc [[ \@@_begin_line: ]]
+           * Lc [[\@@_begin_line:]]
            * SpaceIndentation ^ 0 
            * LPEG1[lang]
            * -1 
-           * Lc [[ \@@_end_line: ]]
+           * Lc [[\@@_end_line:]]
          )
   end
 end
@@ -7886,6 +8200,13 @@
 %
 % \verb|https://github.com/fpantigny/piton|
 %
+% \subsection*{Changes between versions 2.8 and 3.0}
+%
+% New command |\NewPitonLanguage|. Thanks to that command, it's now possible to
+% define new informatic languages with the syntax used by \pkg{listings}.
+% Therefore, it's possible to say that virtually all the informatic languages
+% are now supported by \pkg{piton}.
+%
 % \subsection*{Changes between versions 2.7 and 2.8}
 %
 % The key |path| now accepts a \emph{list} of pathes where the files to include

Modified: trunk/Master/texmf-dist/tex/lualatex/piton/piton.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/piton/piton.lua	2024-04-29 20:31:51 UTC (rev 71131)
+++ trunk/Master/texmf-dist/tex/lualatex/piton/piton.lua	2024-04-29 20:32:02 UTC (rev 71132)
@@ -20,7 +20,7 @@
 -- -------------------------------------------
 -- 
 -- This file is part of the LuaLaTeX package 'piton'.
-piton_version = "2.8" -- 2024/04/14
+piton_version = "3.0" -- 2024/04/29
 
 
 if piton.comment_latex == nil then piton.comment_latex = ">" end
@@ -801,7 +801,7 @@
   K ( 'Name.Type' ,
       P "bool" + "char" + "char16_t" + "char32_t" + "double" + "float" + "int" +
       "int8_t" + "int16_t" + "int32_t" + "int64_t" + "long" + "short" + "signed"
-      + "unsigned" + "void" + "wchar_t" )
+      + "unsigned" + "void" + "wchar_t" ) * Q "*" ^ 0
 
 local DefFunction =
   Type
@@ -1401,16 +1401,16 @@
         or x[1] == "moretexcs"
      then
         local keywords = P ( false )
-        local style = [[ \PitonStyle{Keyword} ]]
-        if x[1] == "moredirectives" then style = [[ \PitonStyle{directive} ]] end
+        local style = [[\PitonStyle{Keyword}]]
+        if x[1] == "moredirectives" then style = [[ \PitonStyle{Directive} ]] end
         style =  tex_option_arg : match ( x[2] ) or style
-        local n = tonumber (style )
+        local n = tonumber ( style )
         if n then
-         if n > 1 then style = [[ \PitonStyle{Keyword ]] .. style .. "}" end
+          if n > 1 then style = [[\PitonStyle{Keyword]] .. style .. "}" end
         end
         for _ , word in ipairs ( split_clist : match ( x[2] ) ) do
           if x[1] == "moretexcs" then
-            keywords = Q ( [[ \ ]] .. word ) + keywords
+            keywords = Q ( [[\]] .. word ) + keywords
           else
             if sensitive
             then keywords = Q ( word  ) + keywords
@@ -1432,35 +1432,30 @@
   for _ , x in ipairs ( def_table ) do
     if x[1] == "morestring" then
       arg1 , arg2 , arg3 , arg4 = args_for_morekeywords : match ( x[2] )
-      arg2 = arg2 or [[ \PitonStyle{String.Long} ]]
-      if arg1 == "s" then
-        long_string =
-          Q ( arg3 )
-          * ( Q ( ( 1 - P ( arg4 ) - S "$\r" ) ^ 1 ) -- $
-              + EOL
-            ) ^ 0
-          * Q ( arg4 )
-      else
-        central_pattern = 1 - S ( " \r" .. arg3 )
-        if arg1 : match "b" then
-          central_pattern = P ( [[ \ ]] .. arg3 )  + central_pattern
-        end
-        if arg1 : match "d" or arg1 == "m" then
-          central_pattern = P ( arg3 .. arg3 )  + central_pattern
-        end
-        if arg1 == "m"
-        then prefix = P ( false )
-        else prefix = lpeg.B ( 1 - letter - ")" - "]" )
-        end
-        long_string = long_string +
-           prefix
-           * Q ( arg3 )
-           * ( VisualSpace + Q ( central_pattern ^ 1 ) + EOL ) ^ 0
-           * Q ( arg3 )
+      arg2 = arg2 or [[\PitonStyle{String.Long}]]
+      if arg1 ~= "s" then
+        arg4 = arg3
       end
+      central_pattern = 1 - S ( " \r" .. arg4 )
+      if arg1 : match "b" then
+        central_pattern = P ( [[\]] .. arg3 ) + central_pattern
+      end
+      if arg1 : match "d" or arg1 == "m" then
+        central_pattern = P ( arg3 .. arg3 ) + central_pattern
+      end
+      if arg1 == "m"
+      then prefix = lpeg.B ( 1 - letter - ")" - "]" )
+      else prefix = P ( true )
+      end
+     local pattern =
+         prefix
+         * Q ( arg3 )
+         * ( VisualSpace + Q ( central_pattern ^ 1 ) + EOL ) ^ 0
+         * Q ( arg4 )
+      long_string = long_string + pattern
       LongString = LongString +
          Ct ( Cc "Open" * Cc ( "{" ..  arg2 .. "{" ) * Cc "}}" )
-         * long_string
+         * pattern
          * Ct ( Cc "Close" )
     end
   end
@@ -1476,8 +1471,8 @@
   for _ , x in ipairs ( def_table ) do
     if x[1] == "morecomment" then
       local arg1 , arg2 , other_args = args_for_morecomment : match ( x[2] )
-      arg2 = arg2 or [[ \PitonStyle{Comment} ]]
-      if arg1 : match "i" then arg2 = [[ \PitonStyle{Discard} ]] end
+      arg2 = arg2 or [[\PitonStyle{Comment}]]
+      if arg1 : match "i" then arg2 = [[\PitonStyle{Discard}]] end
       if arg1 : match "l" then
         local arg3 = ( tex_braced_arg + C ( P ( 1 ) ^ 0 * -1 ) )
                      : match ( other_args )
@@ -1574,8 +1569,8 @@
        + Beamer
        + DetectedCommands
        + CommentDelim
+       + LongString
        + Delim
-       + LongString
        + Keyword * ( Space + Punct + Delim + EOL + -1 )
        + Punct
        + K ( 'Identifier' , letter * alphanum ^ 0 )
@@ -1588,11 +1583,11 @@
     Ct (
          ( space ^ 0 * P "\r" ) ^ -1
          * BeamerBeginEnvironments
-         * Lc [[ \__piton_begin_line: ]]
+         * Lc [[\__piton_begin_line:]]
          * SpaceIndentation ^ 0
          * LPEG1[lang]
          * -1
-         * Lc [[ \__piton_end_line: ]]
+         * Lc [[\__piton_end_line:]]
        )
   if left_tag then
     local Tag = Q ( left_tag * other ^ 0 )
@@ -1637,11 +1632,11 @@
       Ct (
            ( space ^ 0 * P "\r" ) ^ -1
            * BeamerBeginEnvironments
-           * Lc [[ \__piton_begin_line: ]]
+           * Lc [[\__piton_begin_line:]]
            * SpaceIndentation ^ 0
            * LPEG1[lang]
            * -1
-           * Lc [[ \__piton_end_line: ]]
+           * Lc [[\__piton_end_line:]]
          )
   end
 end

Modified: trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty	2024-04-29 20:31:51 UTC (rev 71131)
+++ trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty	2024-04-29 20:32:02 UTC (rev 71132)
@@ -19,8 +19,8 @@
 %% LaTeX version 2005/12/01 or later.
 %% -------------------------------------------
 %% 
-\def\PitonFileVersion{2.8}
-\def\PitonFileDate{2024/04/14}
+\def\PitonFileVersion{3.0}
+\def\PitonFileDate{2024/04/29}
 
 
 \NeedsTeXFormat{LaTeX2e}
@@ -723,8 +723,42 @@
           { \dim_eval:n { \g__piton_tmp_width_dim } }
       }
   }
-\NewDocumentCommand { \NewPitonLanguage } { m m }
-  { \lua_now:e { piton.new_language("#1","\lua_escape:n{#2}") } }
+\NewDocumentCommand { \NewPitonLanguage } { O { } m ! o }
+  {
+    \tl_if_novalue:nTF { #3 }
+      { \__piton_NewPitonLanguage:nnn { #1 } { #2 } }
+      { \__piton_NewPitonLanguage:nnnnn { #1 } { #2 } { #3 } }
+  }
+\prop_new:N \g__piton_languages_prop
+\cs_new_protected:Npn \__piton_NewPitonLanguage:nnn #1 #2 #3
+  {
+    \tl_set:Nx \l_tmpa_tl
+      {
+        \tl_if_blank:nF { #1 } { [ \str_lowercase:n { #1 } ] }
+        \str_lowercase:n { #2 }
+      }
+    \prop_gput:Non \g__piton_languages_prop \l_tmpa_tl { #3 }
+    \exp_args:NV \__piton_NewPitonLanguage:nn \l_tmpa_tl { #3 }
+  }
+\cs_new_protected:Npn \__piton_NewPitonLanguage:nn #1 #2
+  {
+    \hook_gput_code:nnn { begindocument } { . }
+      { \lua_now:e { piton.new_language("#1","\lua_escape:n{#2}") } }
+  }
+\cs_new_protected:Npn \__piton_NewPitonLanguage:nnnnn #1 #2 #3 #4 #5
+  {
+    \tl_set:Nx \l_tmpa_tl
+      {
+         \tl_if_blank:nF { #3 } { [ \str_lowercase:n { #3 } ] }
+         \str_lowercase:n { #4 }
+      }
+     \prop_get:NoNTF \g__piton_languages_prop \l_tmpa_tl \l_tmpb_tl
+       { \__piton_NewPitonLanguage:nnno { #1 } { #2 } { #5 } \l_tmpb_tl }
+       { \__piton_error:n { Language~not~defined } }
+  }
+\cs_new_protected:Npn \__piton_NewPitonLanguage:nnnn #1 #2 #3 #4
+  { \__piton_NewPitonLanguage:nnn { #1 } { #2 } { #4 , #3 } }
+\cs_generate_variant:Nn \__piton_NewPitonLanguage:nnnn { n n n o }
 \NewDocumentCommand { \piton } { }
   { \peek_meaning:NTF \bgroup \__piton_piton_standard \__piton_piton_verbatim }
 \NewDocumentCommand { \__piton_piton_standard } { m }
@@ -1168,7 +1202,7 @@
     String.Short ,
     TypeParameter ,
     UserFunction ,
-    directive
+    Directive
   }
 
 \clist_map_inline:Nn \g__piton_styles_clist
@@ -1234,7 +1268,7 @@
     TypeParameter      = \color[HTML]{336666} \itshape ,
     Preproc            = \color[HTML]{AA6600} \slshape ,
     Identifier         = \__piton_identifier:n ,
-    directive          = \color[HTML]{AA6600} ,
+    Directive          = \color[HTML]{AA6600} ,
     UserFunction       = ,
     Prompt             = ,
     ParseAgain.noCR    = \__piton_piton_no_cr:n ,
@@ -1323,6 +1357,13 @@
     \token_to_str:N \piton\ but~there~is~no~environment~
     {piton}.~This~error~is~fatal.
   }
+\__piton_msg_new:nn { Language~not~defined }
+  {
+    Language~not~defined \\
+    The~language~'\l_tmpa_tl'~has~not~been~defined~previoulsy.\\
+    If~you~go~on,~your~command~\token_to_str:N \NewPitonLanguage\
+    will~be~ignored.
+  }
 \__piton_msg_new:nn { bad~version~of~piton.lua }
   {
     Bad~number~version~of~'piton.lua'\\



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