texlive[65673] Master/texmf-dist: piton (29jan23)

commits+karl at tug.org commits+karl at tug.org
Sun Jan 29 22:21:33 CET 2023


Revision: 65673
          http://tug.org/svn/texlive?view=revision&revision=65673
Author:   karl
Date:     2023-01-29 22:21:33 +0100 (Sun, 29 Jan 2023)
Log Message:
-----------
piton (29jan23)

Modified Paths:
--------------
    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.sty

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	2023-01-29 21:21:06 UTC (rev 65672)
+++ trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex	2023-01-29 21:21:33 UTC (rev 65673)
@@ -84,6 +84,8 @@
 en utilisant la bibliothèque Lua LPEG. L'extension \pkg{piton} nécessite l'emploi de LuaLaTeX.
 \end{abstract}
 
+
+
 \section{Présentation}
 
 L'extension \pkg{piton} utilise la librairie Lua nommée LPEG\footnote{LPEG est une librairie de capture de motifs
@@ -97,14 +99,15 @@
 \bigskip
 Voici un exemple de code Python composé avec l'environnement |{Piton}| proposé par \pkg{piton}.
 
+
 \bigskip
 \begin{Piton}
 from math import pi
 
 def arctan(x,n=10):
-    """Compute the mathematical value of arctan(x)
+    """Calcule la valeur mathématique de arctan(x)
 
-    n is the number of terms in the sum
+    n est le nombre de termes de la somme
     """
     if x < 0:
         return -arctan(-x) # appel récursif
@@ -118,6 +121,7 @@
         return s 
 \end{Piton}
 
+
 \bigskip
 
 L'extension LaTeX \pkg{piton} est entièrement contenue dans le fichier |piton.sty|. Ce
@@ -196,6 +200,11 @@
 |{| et |}|. Ces deux dernières commandes ne sont nécessaires que si on a besoin d'insérer des accolades
 non équilibrées.
 
+\smallskip
+\colorbox{yellow!50}{\textbf{Nouveau 1.3}}\enskip La commande |\|␣ insère un espace. Elle peut être utilisée si on
+veut insérer plusieurs espaces successifs.
+
+\smallskip
 Les autres caractères (y compris |#|, |^|, |_|, |&|, |$| % $
 et |@|) doivent être insérés sans contre-oblique.
 
@@ -208,6 +217,8 @@
 \piton{def pair(n): return n\%2==0 } \\
 \verb|\piton{c="#"    # une affectation }| & 
 \piton{c="#"     # une affectation } \\
+\verb|\piton{c="#" \ \ \ # une affectation }| & 
+\piton{c="#" \ \ \ # une affectation } \\
 \verb|\piton{my_dict = {'a': 3, 'b': 4}}| &
 \piton{my_dict = {'a': 3, 'b': 4}}
 \end{tabular}
@@ -240,6 +251,8 @@
 
 \end{itemize}
 
+
+
 \section{Personnalisation}
 
 \subsection{La commande \textbackslash PitonOptions}
@@ -287,6 +300,14 @@
 \item La clé \Definition{background-color} fixe la couleur de fond des environnements |{Piton}| et des listings
 produits par |\PitonInputFile| (ce fond a une largeur égale à la valeur courante de |\linewidth|).
 
+\colorbox{yellow!50}{\textbf{Nouveau 1.3}}\enskip La clé |background-color| accepte une couleur définie «à la
+volée», c'est-à-dire que l'on peut écrire par exemple |background-color = [cmyk]{0.1,0.05,0,0}|
+
+\item \colorbox{yellow!50}{\textbf{Nouveau 1.3}}\enskip Avec la clé \Definition{prompt-background-color},
+\pkg{piton} ajoute un fond coloré aux lignes débutant par le prompt «|>>>|» (et sa continuation «|...|»)
+caractéristique des consoles Python avec boucle \textsc{repl} (\emph{read-only-eval loop}). Pour un exemple
+d'utilisation de cette clé, voir la partie \ref{pythonrepl} p.~\pageref{pythonrepl}
+
 \item \colorbox{yellow!50}{\textbf{Modification 1.2}}\enskip En activant la clé \Definition{show-spaces-in-strings}, les
 espaces dans les chaînes courtes (c'est-à-dire celles délimitées par |'| ou |"|) sont matérialisés par le caractère
 ␣ (U+2423 : \textsc{open box}). Bien sûr, le caractère U+2423 doit être présent dans la fonte mono-chasse
@@ -300,7 +321,7 @@
 
 \smallskip
 Avec la clé \Definition{show-spaces}, tous les espaces sont matérialisés (et aucune coupure de ligne ne peut plus
-intervenir sur ces espace matérialisés, même si la clé |break-lines| est active).
+intervenir sur ces espaces matérialisés, même si la clé |break-lines| est active).
 \end{itemize}
 
 \bigskip
@@ -313,9 +334,9 @@
     from math import pi
 
     def arctan(x,n=10):
-        """Compute the mathematical value of arctan(x)
+        """Calcule la valeur mathématique de arctan(x)
 
-        n is the number of terms in the sum
+        n est le nombre de termes de la somme
         """
         if x < 0:
             return -arctan(-x) # appel récursif
@@ -331,6 +352,7 @@
 \end{Verbatim}
 \endgroup
 
+
 \begingroup
 \PitonOptions{line-numbers,auto-gobble,background-color = gray!15}
 \begin{Piton}
@@ -355,6 +377,7 @@
 \endgroup
 
 
+
 \bigskip
 La commande |\PitonOptions| propose d'autres clés qui seront décrites plus loin (voir en particulier la coupure des
 pages et des lignes p.~\pageref{breakable}).
@@ -402,7 +425,8 @@
 Les différents styles sont décrits dans la table \ref{Semantic}. Les réglages initiaux effectués par \pkg{piton}
 dans |piton.sty| sont inspirés par le style \pkg{manni} de Pygments.\footnote{Voir
   \url{https://pygments.org/styles/}. À remarquer que, par défaut, Pygments propose pour le style \pkg{manni} un
-  fond coloré dont la couleur est la couleur HTML |#F0F3F3|.}
+  fond coloré dont la couleur est la couleur HTML |#F0F3F3|. Il est possible d'avoir la même couleur dans |{Piton}|
+  avec l'instruction : |\PitonOptions{background-color = [HTML]{F0F3F3}}|}
 
 \begin{table}[htb]
 \centering
@@ -482,7 +506,7 @@
 \end{verbatim}
 
 \bigskip
-Avec ce nouvel environnement |{Python}|, on écrire : 
+Avec ce nouvel environnement |{Python}|, on peut écrire : 
 
 \begin{Verbatim}
 ~emphase#\begin{Python}@
@@ -513,11 +537,14 @@
 \item Il est possible d'avoir, dans les commentaires Python, les éléments entre \texttt{\$} composés en mode
 mathématique de LaTeX.
 \item Il est possible d'insérer du code LaTeX à n'importe quel endroit d'un listing Python.
-\item Dans le cas où la classe Beamer est utilisée, l'extension \pkg{piton} détecte automatiquement certaines
-commandes de Beamer.
 \end{itemize}
+Ces mécanismes vont être détaillés dans les sous-parties de cette partie.
 
+\smallskip
+À remarquer également que, dans le cas où \pkg{piton} est utilisée dans la classe \cls{beamer}, \pkg{piton} détecte
+la plupart des commandes et environnements de Beamer : voir la sous-section \ref{beamer}, p.~\pageref{beamer}.
 
+
 \subsubsection{Les «commentaires LaTeX»}
 
 Dans ce document, on appelle «commentaire LaTeX» des commentaires qui débutent par |#>|. Tout ce qui suit ces deux 
@@ -558,6 +585,16 @@
 \end{itemize}
 
 
+\bigskip
+\colorbox{yellow!50}{\textbf{Nouveau 1.3}}\enskip Si l'utilisateur a demandé l'affichage des numéros de ligne (avec
+|line-numbers| ou |all-line-numbers|), il est possible de faire référence à ce numéro de ligne avec la commande
+|\label| placée dans un commentaire LaTeX.\footnote{Cette fonctionnalité est implémentée en redéfinissant, dans les
+environnements |{Piton}|, la commande |\label|. Il peut donc y avoir des incompatibilités avec les extensions qui
+redéfinissent (globalement) cette commande |\label| (comme \pkg{varioref}, \pkg{refcheck}, \pkg{showlabels}, etc.)}
+
+
+
+
 \subsubsection{La clé «math-comments»}
 
 Il est possible de demander que, dans les commentaires Python normaux, c'est-à-dire débutant par~|#| (et non par
@@ -628,19 +665,46 @@
 
 
 
-\subsubsection{Comportement dans la classe Beamer}
 
-\colorbox{yellow!50}{\textbf{Nouveau 1.1}}
+\subsection{Comportement dans la classe Beamer}
 
-\smallskip
-Quand \pkg{piton} est utilisé dans la classe \cls{beamer}\footnote{L'extension \pkg{piton} détecte la classe \cls{beamer} mais il est aussi possible, si le
-  besoin s'en faisait sentir, d'activer ce comportement avec la clé |beamer| au chargement de \pkg{piton} :
-  |\usepackage[beamer]{piton}|}, les commandes suivantes de \cls{beamer}, classées selon
-leur nombre d'arguments obligatoires, sont directement
-reconnues dans les environnements |{Piton}| : 
+\label{beamer}
+
+Quand l'extension \pkg{piton} est utilisée dans la classe \cls{beamer}\footnote{L'extension \pkg{piton} détecte la
+  classe \cls{beamer} mais il est aussi possible, si le besoin s'en faisait sentir, d'activer ce comportement avec
+  la clé |beamer| au chargement de \pkg{piton} : |\usepackage[beamer]{piton}|}, le comportement de \pkg{piton} est
+légèrement modifié, comme décrit maintenant.
+
+\subsubsection{\{Piton\} et \textbackslash PitonInputFile sont ``overlay-aware''}
+
+Quand \pkg{piton} est utilisé avec Beamer, l'environnement |{Piton}| et la commande |\PitonInputFile| acceptent
+l'argument optionnel |<...>| de Beamer pour indiquer les «\emph{overlays}» concernés.
+
+On peut par exemple écrire :
+
+\begin{Verbatim}
+\begin{Piton}~emphase#<2-5>@
+...
+\end{Piton}
+\end{Verbatim}
+
+ou aussi 
+
+\begin{Verbatim}
+\PitonInputFile~emphase#<2-5>@{mon_fichier.py}
+\end{Verbatim}
+
+
+\subsubsection{Commandes de Beamer reconnues dans \{Piton\} et \textbackslash PitonInputFile}
+
+Quand \pkg{piton} est utilisé dans la classe \cls{beamer}, les commandes suivantes de \cls{beamer} (classées selon
+leur nombre d'arguments obligatoires) sont directement reconnues dans les environnements |{Piton}| (ainsi que dans
+les listings composés par la commande |\PitonInputFile|, même si c'est sans doute moins utile).
 %
 \begin{itemize}
-\item aucun argument obligatoire : |\pause| ;
+\item aucun argument obligatoire : |\pause|\footnote{On remarquera que, bien sûr, on peut aussi utiliser |\pause|
+  dans un «commentaire LaTeX», c'est-à-dire en écrivant |#> \pause|. Ainsi, si le code Python est copié, il est
+  interprétable par Python.} ;
 \item un argument obligatoire : |\action|, |\alert|, |\invisible|, |\only|, |\uncover| et |\visible| ;
 \item deux arguments obligatoire : |\alt| ; 
 \item trois arguments obligatoires : |\temporal|.
@@ -688,14 +752,17 @@
 
 
 \bigskip
-\colorbox{yellow!50}{\textbf{Nouveau 1.2}}
+\subsubsection{Environnements de Beamer reconnus dans \{Piton\} et \textbackslash PitonInputFile}
 
 Quand \pkg{piton} est utilisé dans la classe \pkg{beamer}, les environnements suivants de Beamer sont directement
-reconnus dans les environnements |{Piton}| : |{uncoverenv}|, |{onlyenv}|, |{visibleenv}| et |{invisibleenv}|.
+reconnus dans les environnements |{Piton}| (ainsi que dans les listings composés par la commande |\PitonInputFile|
+même si c'est sans doute moins utile).: |{uncoverenv}|, |{onlyenv}|, |{visibleenv}| et |{invisibleenv}|.
 
 \medskip
 Il y a néanmoins une restriction : ces environnements doivent englober des \emph{lignes entières de code Python}.
 
+\pagebreak
+
 \medskip
 On peut par exemple écrire :
 
@@ -764,10 +831,6 @@
 \end{itemize}
 
 \medskip
-\colorbox{yellow!50}{\textbf{Nouveau 1.2}}\enskip Depuis la version 1.2, la clé |break-lines| autorise les coupures
-de lignes dans |\piton{...}| et pas seulement dans |{Piton}|.
-
-\medskip
 L'extension \pkg{piton} fournit aussi plusieurs clés pour contrôler l'apparence des coupures de ligne autorisées par |break-lines-in-Piton|.
 
 \begin{itemize}
@@ -1207,6 +1270,8 @@
 
 \section{Utilisation avec pyluatex}
 
+\subsection{Utilisation standard de pyluatex}
+
 L'extension \pkg{pyluatex} est une extension qui permet l'exécution de code Python à partir de |lualatex| (pourvu
 que Python soit installé sur la machine et que la compilation soit effectuée avec |lualatex| et |--shell-escape|).
 
@@ -1260,7 +1325,7 @@
   }
 \ExplSyntaxOff
 
-Cet environnement |{PitonExcecute}| prend en argument optionnel (entre crochets) les options proposées par la
+Cet environnement |{PitonExecute}| prend en argument optionnel (entre crochets) les options proposées par la
 commande |\PitonOptions|.
 
 \bigskip
@@ -1282,8 +1347,104 @@
 print(f'The square of 12 is {square(12)}.')
 \end{PitonExecute}
 
+\bigskip
 
+\subsection{Utilisation de l'environnement \{pythonrepl\} de pyluatex}
 
+\label{pythonrepl}
+
+L'environnement |{pythonrepl}| de \pkg{pyluatex} passe son contenu à Python et renvoie ce que l'on obtient quand on
+fournit ce code à une boucle \textsc{repl} (\emph{read-eval-print loop}) de Python. On obtient un entrelacement
+d'instructions précédées par le prompt |>>>| de Python et des valeurs renovées par Python (et de ce qui a été
+demandé d'être affiché avec des \piton{print} de Python).
+
+\medskip
+Il est ensuite possible de passer cela à un environnement |{Piton}| qui va faire un coloriage syntaxique 
+et mettre sur fond grisé les lignes correspondant aux instructions fournies à l'interpréteur Python (gràce à la clé
+|prompt-background-color| de |\PitonOptions|).
+
+
+\medskip
+Voici la programmation d'un environnement |{PitonREPL}| qui effectue ce travail.
+
+\begin{Verbatim}
+\NewDocumentEnvironment { PitonREPL } { ! O { } }
+ { 
+   \PitonOptions
+     { background-color=white,
+       ~emphase#prompt-background-color = gray!10@,
+       ~#1
+     }
+   \PyLTVerbatimEnv
+   \begin{pythonrepl}
+ }
+ {
+   \directlua
+     {
+       tex.print("\\begin{Piton}")
+       tex.print(pyluatex.get_last_output())
+       tex.print("\\end{Piton}")
+       tex.print("") 
+     }
+   \end{pythonrepl}
+ }
+\end{Verbatim}
+
+\medskip
+Voici un exemple d'utilisation de ce nouvel environnement |{PitonREPL}|.
+
+\medskip
+\begin{Verbatim}
+~emphase#\begin{PitonREPL}@
+def valeur_absolue(x):
+    "Renvoie la valeur absolue de x"
+    if x > 0:
+       return x
+    else:
+       return -x
+
+valeur_absolue(-3)
+valeur_absolue(0)
+valeur_absolue(5)
+~emphase#\end{PitonREPL}@
+\end{Verbatim}
+
+\bigskip
+
+
+\NewDocumentEnvironment { PitonREPL } { }
+ { 
+   \PitonOptions{background-color=white,prompt-background-color = gray!10}
+   \PyLTVerbatimEnv
+   \begin{pythonrepl}
+ }
+ {
+   \directlua
+     {
+       tex.print("\\begin{Piton}")
+       tex.print(pyluatex.get_last_output())
+       tex.print("\\end{Piton}")
+       tex.print("") 
+     }
+   \end{pythonrepl}
+ }
+
+
+\begin{PitonREPL}
+def valeur_absolue(x):
+    "Renvoie la valeur absolue de x"
+    if x > 0:
+       return x
+    else:
+       return -x
+
+valeur_absolue(-3)
+valeur_absolue(0)
+valeur_absolue(5)
+\end{PitonREPL}
+
+
+
 \section*{Autre documentation}
 
 Le document |piton.pdf| (fourni avec l'extension \pkg{piton}) contient une traduction anglaise de la

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	2023-01-29 21:21:06 UTC (rev 65672)
+++ trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx	2023-01-29 21:21:33 UTC (rev 65673)
@@ -15,8 +15,8 @@
 %
 % \fi
 % \iffalse
-\def\myfileversion{1.2}
-\def\myfiledate{2023/01/16}
+\def\myfileversion{1.3}
+\def\myfiledate{2023/01/29}
 %
 %
 %<*batchfile> 
@@ -69,7 +69,6 @@
 \DocInput{piton.dtx}
 \end{document}
 %</driver>
-
 % \fi
 %
 % \catcode`\" = 11 
@@ -206,6 +205,11 @@
 % commands are necessary only if one need to insert braces which are not
 % balanced.
 %
+% \smallskip
+% \colorbox{yellow!50}{\textbf{New 1.3}}\enskip The command |\|␣ inserts a
+% space. It may be used in order to insert several consecutive spaces.
+%
+% \smallskip
 % The other characters (including |#|, |^|, |_|, |&|, |$| and |@|)
 % must be inserted without backslash.
 % 
@@ -218,6 +222,8 @@
 % \piton{def even(n): return n\%2==0} \\
 % \verb|\piton{c="#"    # an affectation }| & 
 % \piton{c="#"     # an affectation } \\
+% \verb|\piton{c="#" \ \ \ # an affectation }| & 
+% \piton{c="#" \ \ \ # an affectation } \\
 % \verb|\piton{MyDict = {'a': 3, 'b': 4 }}| &
 % \piton{MyDict = {'a': 3, 'b': 4 }}
 % \end{tabular}
@@ -312,6 +318,15 @@
 % environments |{Piton}| and the listings produced by |\PitonInputFile| (that
 % background has a width of |\linewidth|).
 %
+% \colorbox{yellow!50}{\textbf{New 1.3}}\enskip The key |background-color|
+% accepts a color defined «on the fly». For example, it's possible to write
+% |background-color = [cmyk]{0.1,0.05,0,0}|.
+%
+% \item \colorbox{yellow!50}{\textbf{New 1.3}}\enskip With the key
+% \Definition{prompt-background-color}, \pkg{piton} adds a color background to
+% the lines beginning with the prompt ``|>>>|'' (and its continuation ``|...|'')
+% charactéristic of the Python consoles with \textsc{repl} (\emph{read-eval-print loop}).
+%
 % \item \colorbox{yellow!50}{\textbf{Modified 1.2}}\enskip When the key
 % \Definition{show-spaces-in-strings} is activated, the spaces in the short strings (that
 % is to say those delimited by |'| or |"|) are replaced by the character~␣
@@ -389,7 +404,7 @@
 % 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 an LaTeX environment is, in particular, a TeX group.}
+% group.\footnote{We remind that a LaTeX environment is, in particular, a TeX group.}
 %
 % \bigskip
 % The command |\SetPitonStyle| takes in as argument a comma-separated list of
@@ -426,9 +441,8 @@
 % \bigskip
 % The different styles are described in the table \ref{Semantic}. The initial
 % settings done by \pkg{piton} in |piton.sty| are inspired by the style
-% \pkg{manni} de Pygments.\footnote{See: \url{https://pygments.org/styles/}.
-% Remark that, by default, Pygments provides for its style \pkg{manni} a colored
-% background whose color is the HTML color \texttt{\#F0F3F3}.}
+% \pkg{manni} de Pygments.\footnote{See:
+% \url{https://pygments.org/styles/}. Remark that, by default, Pygments provides for its style \pkg{manni} a colored background whose color is the HTML color \texttt{\#F0F3F3}. It's possible to have the same color in \texttt{\{Pion\}} with the instruction \texttt{\textbackslash PitonOptions\{background-color = [HTML]\{F0F3F3\}\}}.}
 %
 %
 %
@@ -549,6 +563,10 @@
 % \item It's also possible to insert LaTeX code almost everywhere in a Python listing.
 % \end{itemize}
 %
+% One should aslo remark that, when the extension \pkg{piton} is used with the
+% class \cls{beamer}, \pkg{piton} detects in |{Piton}| many commands and
+% environments of Beamer: cf. \ref{beamer} p.~\pageref{beamer}.
+%
 % \subsubsection{The ``LaTeX comments''}
 %
 % In this document, we call ``LaTeX comments'' the comments which begins by
@@ -589,6 +607,17 @@
 % \ref{example-comments} p.~\pageref{example-comments}
 % \end{itemize}
 %
+% \bigskip
+% \colorbox{yellow!50}{\textbf{New 1.3}}\enskip If the user has required line
+% numbers in the left margin (with the key |line-numbers| or the key
+% |all-line-numbers| of |\PitonOptions|), it's possible to refer to a number of
+% line with the command |\label| used in a LaTeX comment.\footnote{That feature
+% is implemented by using a redefinition of the standard command
+% \texttt{\textbackslash label} in the environments \texttt{\{Piton\}}.
+% Therefore, incompatibilities may occur with extensions which redefine
+% (globally) that command \texttt{\textbackslash label} (for example: \pkg{varioref},
+% \pkg{refcheck}, \pkg{showlabels}, etc.)}
+%
 % \subsubsection{The key ``math-comments''}
 %
 % It's possible to request that, in the standard Python comments (that is to say
@@ -665,19 +694,49 @@
 % this document). 
 % 
 %
-% \subsubsection{Behaviour in the class Beamer}
+% \subsection{Behaviour in the class Beamer}
 %
-% \colorbox{yellow!50}{\textbf{New 1.1}}
+% \label{beamer}
 %
-% \smallskip
-% When \pkg{piton} is used in the class \cls{beamer}\footnote{The extension
-% \pkg{piton} detects the class \cls{beamer} but, if needed, it's also possible
-% to activate that mechanism with the key |beamer| provided by \pkg{piton} at
-% load-time: |\textbackslash usepackage[beamer]\{piton\}|} , the following
-% commands of \cls{beamer}, classified upon their number of their number of
-% arguments, are automatically detected in the environments |{Piton}| :
+% When the package \pkg{piton} is used within the class
+% \cls{beamer}\footnote{The extension \pkg{piton} detects the class \cls{beamer}
+% but, if needed, it's also possible to activate that mechanism with the key
+% |beamer| provided by \pkg{piton} at load-time: |\textbackslash
+% usepackage[beamer]\{piton\}|}, the behaviour of \pkg{piton} is slightly
+% modified, as described now.
+%
+% \subsubsection{\{Piton\} et \textbackslash PitonInputFile are
+% ``overlay-aware''}
+%
+% When \pkg{piton} is used in the class \cls{beamer}, the environment |{Piton}|
+% and the command |\PitonInputFile| accept the optional argument |<...>| of
+% Beamer for the overlays which are involved.
+%
+% For example, it's possible to write:
+%
+% \begin{Verbatim}
+% \begin{Piton}~emphase#<2-5>@
+% ...
+% \end{Piton}
+% \end{Verbatim}
+%
+% and 
+%
+% \begin{Verbatim}
+% \PitonInputFile~emphase#<2-5>@{my_file.py}
+% \end{Verbatim}
+% 
+% \subsubsection{Commands of Beamer allowed in \{Piton\} and \textbackslash PitonInputFile}
+%
+% When \pkg{piton} is used in the class \cls{beamer} , the following commands of
+% \cls{beamer} (classified upon their number of arguments) are automatically
+% detected in the environments |{Piton}| (and in the listings processed by
+% |\PitonInputFile|):
 % \begin{itemize}
-% \item no mandatory argument : |\pause| ;
+% \item no mandatory argument : |\pause|\footnote{One should remark that it's
+% also  possible to use the command \texttt{\textbackslash pause} in a ``LaTeX
+% comment'', that is to say by writing \texttt{\#> \textbackslash pause}. By
+% this way, if the Python code is copied, it's still executable by Python}.  ;
 % \item one mandatory argument : |\action|, |\alert|, |\invisible|, |\only|, |\uncover| and |\visible| ;
 % \item two mandatory arguments : |\alt| ; 
 % \item three mandatory arguments  : |\temporal|.
@@ -699,9 +758,10 @@
 % \medskip
 % Remark that, since the environment |{Piton}| catches its body with a verbatim
 % mode, it's necessary to use the environments |{Piton}| within environments
-% |{frame}| of Beamer protected by the key |fragile|.\footnote{Remind that for an
-% environment \texttt{\{frame\}} of Beamer using the key |fragile|, the instruction
-% \texttt{\textbackslash end\{frame\}} must be alone on a single line (except for any leading whitespace).}
+% |{frame}| of Beamer protected by the key |fragile|.\footnote{Remind that for
+% an environment \texttt{\{frame\}} of Beamer using the key |fragile|, the
+% instruction \texttt{\textbackslash end\{frame\}} must be alone on a single
+% line (except for any leading whitespace).}
 %
 % \medskip
 % Here is a complete example of file:
@@ -727,11 +787,12 @@
 % correctly interpreted (without any escape character).
 % 
 % \bigskip
-% \colorbox{yellow!50}{\textbf{New 1.2}}
+% \subsubsection{Environments of Beamer allowed in \{Piton\} and \textbackslash PitonInputFile}
 %
 % When \pkg{piton} is used in the class \pkg{beamer}, the following environments
-% of Beamer are directly detected in the environments |{Piton}|: |{uncoverenv}|,
-% |{onlyenv}|, |{visibleenv}| and |{invisibleenv}|.
+% of Beamer are directly detected in the environments |{Piton}| (and in the
+% listings processed by |\PitonInputFile|): |{uncoverenv}|, |{onlyenv}|,
+% |{visibleenv}| and |{invisibleenv}|.
 %
 % However, there is a restriction: these environments must contain only \emph{whole
 % lines of Python code} in their body.
@@ -1696,12 +1757,22 @@
 % \medskip
 % The following string corresponds to the key |background-color| of |\PitonOptions|.
 %    \begin{macrocode}
-\str_new:N \l_@@_background_color_str
+\str_new:N \l_@@_bg_color_tl
 %    \end{macrocode}
 %
 % \medskip
+% The package \pkg{piton} will also detect the lines of code which correspond to
+% the user input in a Python console, that is to say the lines of code beginning
+% with |>>>| and |...|. It's possible, with the key |prompt-background-color|,
+% to require a background for these lines of code (and the other lines of code
+% will have the standard background color specified by |background-color|).
+%    \begin{macrocode}
+\str_new:N \l_@@_prompt_bg_color_tl
+%    \end{macrocode}
+% 
+% \medskip
 % We will compute the maximal width of the lines of an environment |{Piton}| in
-% |\g_@@_width_dim|. We need a global variable because when the key |footnote|
+% |\g_@@_width_dim|. We need a global variable because, when the key |footnote|
 % is in force, each line when be composed in an environment |{savenotes}| and
 % (when |slim| is in force) we need to exit |\g_@@_width_dim| from that
 % environment.
@@ -1839,6 +1910,56 @@
 %    \end{macrocode}
 % 
 % \bigskip
+% In the environment |{Piton}|, the command |\label| will be linked to the
+% following command.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_label:n #1
+  {
+    \bool_if:NTF \l_@@_line_numbers_bool
+      {
+        \@bsphack 
+        \protected at write \@auxout { }
+          { 
+            \string \newlabel { #1 } 
+            { 
+%    \end{macrocode}
+% Remember that the content of a line is typeset in a box \emph{before} the
+% composition of the potential number of line.
+%    \begin{macrocode}
+              { \int_eval:n { \g_@@_visual_line_int + 1 } } 
+              { \thepage } 
+            } 
+          } 
+        \@esphack
+     }
+     { \msg_error:nn { piton } { label~with~lines~numbers } }
+  }
+%    \end{macrocode}
+%
+%
+% \bigskip
+% The following token list will be evaluated at the beginning of
+% |\@@_begin_line:|... |\@@_end_line:| and cleared at the end. It will be used
+% by LPEG acting between the lines of the Python code in order to add
+% instructions to be executed at the beginning of the line.
+%    \begin{macrocode} 
+\tl_new:N \g_@@_begin_line_hook_tl
+%    \end{macrocode}
+%
+% \smallskip
+% For example, the LPEG |Prompt| will trigger the following command which will
+% insert an instruction in the hook |\g_@@_begin_line_hook| to specify that a
+% background must be inserted to the current line of code.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_prompt: 
+  { 
+    \tl_gset:Nn \g_@@_begin_line_hook_tl
+      { \tl_set:NV \l_@@_bg_color_tl \l_@@_prompt_bg_color_tl } 
+  }
+%    \end{macrocode}
+% 
+%
+% \bigskip
 % \subsubsection{Treatment of a line of code}
 % 
 %    \begin{macrocode}
@@ -1850,7 +1971,7 @@
       {
 %    \end{macrocode}
 % If the key |break-lines-in-Piton| is in force, we replace all the characters
-% U+0032 (that is to say the spaces) by |\@@_breakable_space:|. Remark that,
+% U+0020 (that is to say the spaces) by |\@@_breakable_space:|. Remark that,
 % except the spaces inserted in the LaTeX comments (and maybe in the math
 % comments), all these spaces are of catcode ``other'' (=12) and are
 % unbreakable.
@@ -1870,11 +1991,15 @@
 % 
 % \bigskip
 % In the contents provided by Lua, each line of the Python code will be
-% surrounded by |\@@_begin_line:| and |\@@_end_line:|. 
+% surrounded by |\@@_begin_line:| and |\@@_end_line:|. |\@@_begin_line:| is a
+% LaTeX that we will define now but |\@@_end_line:| is only a syntactic marker
+% that has no definition.
 %
 %    \begin{macrocode}
 \cs_set_protected:Npn \@@_begin_line: #1 \@@_end_line:
   { 
+    \group_begin:
+    \g_@@_begin_line_hook_tl
     \int_gzero:N \g_@@_indentation_int
 %    \end{macrocode}
 %
@@ -1884,7 +2009,7 @@
     \bool_if:NTF \l_@@_slim_bool
       { \hcoffin_set:Nn \l_tmpa_coffin }
       { 
-        \str_if_empty:NTF \l_@@_background_color_str
+        \str_if_empty:NTF \l_@@_bg_color_tl
           { 
             \vcoffin_set:Nnn \l_tmpa_coffin 
               { \dim_eval:n { \linewidth - \l_@@_left_margin_dim } } 
@@ -1910,7 +2035,7 @@
               { \tl_if_empty:nF { #1 } }
               \@@_print_number:
           }
-        \str_if_empty:NF \l_@@_background_color_str 
+        \tl_if_empty:NF \l_@@_bg_color_tl 
           { \skip_horizontal:n { 0.5 em } }
         \coffin_typeset:Nnnnn \l_tmpa_coffin T l \c_zero_dim \c_zero_dim 
       }  
@@ -1922,7 +2047,7 @@
       { \dim_gset:Nn \g_@@_width_dim { \box_wd:N \l_tmpa_box } }
     \box_set_dp:Nn \l_tmpa_box { \box_dp:N \l_tmpa_box + 1.25 pt } 
     \box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + 1.25 pt } 
-    \tl_if_empty:NTF \l_@@_background_color_str
+    \str_if_empty:NTF \l_@@_bg_color_tl
       { \box_use_drop:N \l_tmpa_box }
       {
         \vbox_top:n 
@@ -1929,7 +2054,7 @@
           { 
             \hbox:n
               { 
-                \exp_args:NV \color \l_@@_background_color_str
+                \@@_color:V \l_@@_bg_color_tl
                 \vrule height \box_ht:N \l_tmpa_box 
                        depth \box_dp:N \l_tmpa_box 
                        width \l_@@_width_on_aux_dim
@@ -1940,11 +2065,30 @@
           }
       }   
     \vspace { - 2.5 pt }
+    \group_end:
+    \tl_gclear:N \g_@@_begin_line_hook_tl
   }
 %    \end{macrocode}
 %
 % \bigskip
+% The following command |\@@_color:n| will accept both |\@@_color:n { red!15 }|
+% and |\@@_color:n { [rgb]{0.9,0.9,0}}|.
 %    \begin{macrocode}
+\cs_set_protected:Npn \@@_color:n #1
+  {
+    \tl_if_head_eq_meaning:nNTF { #1 } [ 
+      { 
+        \tl_set:Nn \l_tmpa_tl { #1 }
+        \tl_set_rescan:Nno \l_tmpa_tl { } \l_tmpa_tl 
+        \exp_last_unbraced:NV \color \l_tmpa_tl
+      }
+      { \color { #1 } }
+  }
+\cs_generate_variant:Nn \@@_color:n { V }
+%    \end{macrocode}
+% 
+% \bigskip
+%    \begin{macrocode}
 \cs_new_protected:Npn \@@_newline: 
   { 
     \int_gincr:N \g_@@_line_int
@@ -1977,7 +2121,7 @@
               \l_@@_continuation_symbol_tl 
             } 
             \skip_horizontal:n { 0.3 em }  
-            \str_if_empty:NF \l_@@_background_color_str 
+            \tl_if_empty:NF \l_@@_bg_color_tl 
               { \skip_horizontal:n { 0.5 em } }
           }  
         \bool_if:NT \l_@@_indent_broken_lines_bool
@@ -2035,8 +2179,10 @@
     resume           .value_forbidden:n = true ,
     splittable       .int_set:N         = \l_@@_splittable_int ,
     splittable       .default:n         = 1 , 
-    background-color .str_set:N         = \l_@@_background_color_str ,
+    background-color .str_set:N         = \l_@@_bg_color_tl ,
     background-color .value_required:n  = true ,
+    prompt-background-color .str_set:N         = \l_@@_prompt_bg_color_tl ,
+    prompt-background-color .value_required:n  = true ,
     slim             .bool_set:N        = \l_@@_slim_bool ,
     slim             .default:n         = true ,
     left-margin      .code:n =
@@ -2074,38 +2220,6 @@
 %
 % 
 %  \bigskip
-%    \begin{macrocode}
-\msg_new:nnnn { piton } { Unknown~key~for~PitonOptions }
-  { 
-    Unknown~key. \\
-    The~key~'\l_keys_key_str'~is~unknown~for~\token_to_str:N \PitonOptions.~
-    It~will~be~ignored.\\
-    For~a~list~of~the~available~keys,~type~H~<return>.
-  }
-  {
-    The~available~keys~are~(in~alphabetic~order):~
-    all-line-numbers,~
-    auto-gobble,~
-    break-lines,~
-    break-lines-in-piton,~
-    break-lines-in-Piton,~
-    continuation-symbol,~
-    continuation-symbol-on-indentation,~
-    end-of-broken-line,~
-    env-gobble,~
-    gobble,~
-    indent-broken-lines,~
-    left-margin,~
-    line-numbers,~
-    resume,~
-    show-spaces,~
-    show-spaces-in-strings,~
-    slim,~
-    splittable,~
-    tabs-auto-gobble,~
-    and~tab-size.
-  }
-%    \end{macrocode}
 % 
 % \bigskip
 % The argument of |\PitonOptions| is provided by curryfication.
@@ -2120,6 +2234,7 @@
 % The following counter will be used to count the lines in the code when the
 % user requires the numbers of the lines to be printed (with |line-numbers| or
 % |all-line-numbers|). 
+%
 %    \begin{macrocode}
 \int_new:N \g_@@_visual_line_int 
 %    \end{macrocode}
@@ -2128,7 +2243,7 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_print_number:
   {
-    \int_gincr:N \g_@@_visual_line_int 
+    \int_gincr:N \g_@@_visual_line_int
     \hbox_overlap_left:n
       { 
         { \color { gray } \footnotesize \int_to_arabic:n \g_@@_visual_line_int }
@@ -2164,7 +2279,7 @@
   {
     \bool_if:NT \l_@@_slim_bool
       {
-        \str_if_empty:NF \l_@@_background_color_str
+        \tl_if_empty:NF \l_@@_bg_color_tl
           {
             \tl_gput_right:Nx \g_@@_aux_tl
               {
@@ -2178,8 +2293,8 @@
 % 
 % \bigskip
 % \subsubsection{The main commands and environments for the final user}
-% 
-% \medskip 
+%
+% \bigskip
 %    \begin{macrocode}
 \NewDocumentCommand { \piton } { }
   { \peek_meaning:NTF \bgroup \@@_piton_standard \@@_piton_verbatim }
@@ -2190,15 +2305,21 @@
   {
     \group_begin:
     \ttfamily
+%    \end{macrocode}
+% The following tuning of LuaTeX in order to avoid all break of lines on the
+% hyphens. 
+%    \begin{macrocode}
+    \automatichyphenmode = 1
     \cs_set_eq:NN \\ \c_backslash_str
     \cs_set_eq:NN \% \c_percent_str  
     \cs_set_eq:NN \{ \c_left_brace_str
     \cs_set_eq:NN \} \c_right_brace_str
     \cs_set_eq:NN \$ \c_dollar_str
+    \cs_set_eq:cN { ~ } \space 
     \cs_set_protected:Npn \@@_begin_line: { }
     \cs_set_protected:Npn \@@_end_line: { }
     \tl_set:Nx \l_tmpa_tl 
-      { \lua_now:n { piton.pitonParse(token.scan_string()) } { #1 } }
+      { \lua_now:n { piton.ParseBis(token.scan_string()) } { #1 } }
     \bool_if:NTF \l_@@_show_spaces_bool
       { \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
 %    \end{macrocode}
@@ -2220,6 +2341,7 @@
   {
     \group_begin:
     \ttfamily
+    \automatichyphenmode = 1
     \cs_set_protected:Npn \@@_begin_line: { }
     \cs_set_protected:Npn \@@_end_line: { }
     \tl_set:Nx \l_tmpa_tl 
@@ -2231,8 +2353,12 @@
   }
 %    \end{macrocode}
 %
+
 %  \bigskip
-% The following command is not a user command. It will be used when you will
+%
+%
+% \bigskip
+% The following command is not a user command. It will be used when we will
 % have to ``rescan'' some chunks of Python code. For example, it will be the
 % initial value of the Piton style |InitialValues| (the default values of the
 % arguments of a Python function).
@@ -2242,8 +2368,17 @@
     \group_begin:
     \cs_set_protected:Npn \@@_begin_line: { }
     \cs_set_protected:Npn \@@_end_line: { }
-    \tl_set:Nx \l_tmpa_tl 
-      { \lua_now:n { piton.Parse(token.scan_string()) } { #1 } }
+    \bool_lazy_or:nnTF 
+      \l_@@_break_lines_in_piton_bool
+      \l_@@_break_lines_in_Piton_bool
+      {
+        \tl_set:Nx \l_tmpa_tl 
+          { \lua_now:n { piton.ParseTer(token.scan_string()) } { #1 } }
+      }
+      {
+        \tl_set:Nx \l_tmpa_tl 
+          { \lua_now:n { piton.Parse(token.scan_string()) } { #1 } }
+      }
     \bool_if:NT \l_@@_show_spaces_bool
       { \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
     \l_tmpa_tl 
@@ -2262,8 +2397,17 @@
     \cs_set_protected:Npn \@@_end_line: { }
     \cs_set_protected:Npn \@@_newline:
       { \msg_fatal:nn { piton } { cr~not~allowed } }
-    \tl_set:Nx \l_tmpa_tl 
-      { \lua_now:n { piton.Parse(token.scan_string()) } { #1 } }
+    \bool_lazy_or:nnTF 
+      \l_@@_break_lines_in_piton_bool
+      \l_@@_break_lines_in_Piton_bool
+      {
+        \tl_set:Nx \l_tmpa_tl 
+          { \lua_now:n { piton.ParseTer(token.scan_string()) } { #1 } }
+      }
+      {
+        \tl_set:Nx \l_tmpa_tl 
+          { \lua_now:n { piton.Parse(token.scan_string()) } { #1 } }
+      }
     \bool_if:NT \l_@@_show_spaces_bool
       { \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
     \l_tmpa_tl 
@@ -2272,11 +2416,12 @@
 %    \end{macrocode}
 % 
 % \bigskip
-% Despite its name, |\@@_pre_env:| will be used both in |\PitonInputFile| dans
+% Despite its name, |\@@_pre_env:| will be used both in |\PitonInputFile| and
 % in the environments such as |{Piton}|.
 %    \begin{macrocode}
 \cs_new:Npn \@@_pre_env:
   {
+    \automatichyphenmode = 1
     \int_gincr:N \g_@@_env_int 
     \tl_gclear:N \g_@@_aux_tl
     \cs_if_exist_use:c { c_@@ _ \int_use:N \g_@@_env_int _ tl }
@@ -2287,6 +2432,8 @@
     \int_gzero:N \g_@@_line_int
     \dim_zero:N \parindent 
     \dim_zero:N \lineskip 
+    \dim_zero:N \parindent 
+    \cs_set_eq:NN \label \@@_label:n
   }
 %    \end{macrocode}
 % 
@@ -2303,13 +2450,19 @@
 % 
 % \bigskip
 %    \begin{macrocode}
-\NewDocumentCommand { \PitonInputFile } { O { } m }
+\NewDocumentCommand { \PitonInputFile } { d < > O { } m }
   {
+    \tl_if_novalue:nF { #1 }
+      {
+        \bool_if:NTF \c_@@_beamer_bool
+          { \begin { uncoverenv } < #1 > }     
+          { \msg_error:nn { piton } { overlay~without~beamer } }
+      }
     \group_begin:
       \int_zero_new:N \l_@@_first_line_int
       \int_zero_new:N \l_@@_last_line_int 
       \int_set_eq:NN \l_@@_last_line_int \c_max_int
-      \keys_set:nn { PitonInputFile } { #1 }
+      \keys_set:nn { PitonInputFile } { #2 }
       \@@_pre_env:
       \mode_if_vertical:TF \mode_leave_vertical: \newline 
 %    \end{macrocode}
@@ -2317,7 +2470,7 @@
 % stored by Lua in |\l_@@_nb_lines_int|. That information will be used to allow
 % or disallow page breaks.
 %    \begin{macrocode}
-      \lua_now:n { piton.CountLinesFile(token.scan_argument()) } { #2 }  
+      \lua_now:n { piton.CountLinesFile(token.scan_argument()) } { #3 }  
 %    \end{macrocode}     
 % If the final user has used both |left-margin=auto| and |line-numbers| or
 % |all-line-numbers|, we have to compute the width of the maximal number of
@@ -2337,7 +2490,7 @@
                {
                   \lua_now:n 
                     { piton.CountNonEmptyLinesFile(token.scan_argument()) } 
-                    { #2 }
+                    { #3 }
                   \int_to_arabic:n 
                     { \g_@@_visual_line_int + \l_@@_nb_non_empty_lines_int }   
                 }
@@ -2351,15 +2504,18 @@
       \bool_if:NT \c_@@_footnote_bool { \begin { savenotes } } 
       \vtop \bgroup 
       \lua_now:e
-        { piton.ParseFile(token.scan_argument(),
+        { 
+          piton.ParseFile(token.scan_argument() ,
            \int_use:N \l_@@_first_line_int , 
            \int_use:N \l_@@_last_line_int ) 
         } 
-        { #2 }
+        { #3 }
       \egroup 
       \bool_if:NT \c_@@_footnote_bool { \end { savenotes } } 
       \@@_width_to_aux:
     \group_end:
+    \tl_if_novalue:nF { #1 }
+      { \bool_if:NT \c_@@_beamer_bool { \end { uncoverenv } } }
     \@@_write_aux:
   }
 %    \end{macrocode}
@@ -2369,7 +2525,6 @@
 %    \begin{macrocode}
 \NewDocumentCommand { \NewPitonEnvironment } { m m m m }
   { 
-    \dim_zero:N \parindent 
 %    \end{macrocode}
 % We construct a TeX macro which will catch as argument all the tokens until
 % |\end{|\texttt{\textsl{name_env}}|}| with, in that
@@ -2481,8 +2636,21 @@
 % This is the end of the definition of the command |\NewPitonEnvironment|.
 %
 % \bigskip
+% Now, we define the environment |{Piton}|, which is the main environment
+% provided by the package \pkg{piton}. Of course, you use
+% |\NewPitonEnvironment|. 
 %    \begin{macrocode}
-\NewPitonEnvironment { Piton } { } { } { }
+\bool_if:NTF \c_@@_beamer_bool
+  {
+    \NewPitonEnvironment { Piton } { d < > }
+      { 
+        \IfValueTF { #1 }
+          { \begin { uncoverenv } < #1 > }
+          { \begin { uncoverenv } }
+      }
+      { \end { uncoverenv } } 
+  }
+  { \NewPitonEnvironment { Piton } { } { } { } }
 %    \end{macrocode}
 %
 %
@@ -2666,6 +2834,53 @@
 % \subsubsection{The errors messages of the package}
 %
 %    \begin{macrocode}
+\msg_new:nnnn { piton } { Unknown~key~for~PitonOptions }
+  { 
+    Unknown~key. \\
+    The~key~'\l_keys_key_str'~is~unknown~for~\token_to_str:N \PitonOptions.~
+    It~will~be~ignored.\\
+    For~a~list~of~the~available~keys,~type~H~<return>.
+  }
+  {
+    The~available~keys~are~(in~alphabetic~order):~
+    all-line-numbers,~
+    auto-gobble,~
+    background-color,~
+    break-lines,~
+    break-lines-in-piton,~
+    break-lines-in-Piton,~
+    continuation-symbol,~
+    continuation-symbol-on-indentation,~
+    end-of-broken-line,~
+    env-gobble,~
+    gobble,~
+    indent-broken-lines,~
+    left-margin,~
+    line-numbers,~
+    prompt-background-color,~
+    resume,~
+    show-spaces,~
+    show-spaces-in-strings,~
+    slim,~
+    splittable,~
+    tabs-auto-gobble~
+    and~tab-size.
+  }
+%    \end{macrocode}
+%
+% \bigskip
+%    \begin{macrocode}
+\msg_new:nnn { piton } { label~with~lines~numbers } 
+  {
+    You~can't~use~the~command~\token_to_str:N \label\
+    because~the~key~'line-numbers'~(or~'all-line-numbers')~
+    is~not~active.\\
+    If~you~go~on,~that~command~will~ignored.
+  }
+%    \end{macrocode}
+% 
+% \bigskip
+%    \begin{macrocode}
 \msg_new:nnn { piton } { cr~not~allowed }
   {
     You~can't~put~any~carriage~return~in~the~argument~
@@ -2676,6 +2891,17 @@
     That~error~is~fatal.
   }
 %    \end{macrocode}
+%
+% \bigskip
+%    \begin{macrocode}
+\msg_new:nnn { piton } { overlay~without~beamer }
+  {
+    You~can't~use~an~argument~<...>~for~your~command~
+    \token_to_str:N \PitonInputFile\ because~you~are~not~
+    in~Beamer.\\
+    If~you~go~on,~that~argument~will~be~ignored.
+  }
+%    \end{macrocode}
 % 
 % \bigskip
 % \subsection{The Lua part of the implementation}
@@ -2818,7 +3044,8 @@
 % \paragraph{The basic syntactic LPEG}
 %
 %    \begin{macrocode}
-local alpha, digit, space = lpeg.alpha, lpeg.digit, lpeg.space
+local alpha, digit = lpeg.alpha, lpeg.digit
+local space = P " " 
 %    \end{macrocode}
 %
 % Remember that, for \textsc{lpeg}, the Unicode characters such as |à|, |â|,
@@ -2887,25 +3114,20 @@
 %
 % \bigskip
 %    \begin{macrocode}
-local Space = K ( ( space - P "\r" ) ^ 1 )
+local Space = ( K " " ) ^ 1
 
-local SkipSpace = K ( ( space - P "\r" ) ^ 0 )
+local SkipSpace = ( K " " ) ^ 0
 
 local Punct = K ( S ".,:;!" )
-%    \end{macrocode}
-%
-% \bigskip
-%    \begin{macrocode}
+
 local Tab = P "\t" * Lc ( '\\l_@@_tab_tl' )
 %    \end{macrocode}
 % 
 % \bigskip
 %    \begin{macrocode}
-local SpaceIndentation = 
-   Lc ( '\\@@_an_indentation_space:' ) * K " " 
+local SpaceIndentation = Lc ( '\\@@_an_indentation_space:' ) * ( K " " )
 %    \end{macrocode}
 %
-
 %
 % \bigskip
 %    \begin{macrocode}
@@ -3113,13 +3335,13 @@
 %
 % 
 % \bigskip
-% The following \textsc{lpeg} catches a space (U+0032) and replace it by
+% The following \textsc{lpeg} catches a space (U+0020) and replace it by
 % |\l_@@_space_tl|. It will be used in the short strings. Usually,
 % |\l_@@_space_tl| will contain a space and therefore there won't be difference.
 % However, when the key |show-spaces-in-strings| is in force, |\\l_@@_space_tl| will
 % contain ␣ (U+2423) in order to visualize the spaces.
 %    \begin{macrocode}
-local VisualSpace = P " " * Lc "\\l_@@_space_tl" 
+local VisualSpace = space * Lc "\\l_@@_space_tl" 
 %    \end{macrocode}
 %
 % \bigskip
@@ -3128,10 +3350,10 @@
 %
 %    \begin{macrocode}
 local SingleShortPureString = 
-  ( K ( ( P "\\'" + P "{{" + P "}}" + 1 - S " {}'" ) ^ 1 ) + VisualSpace )  ^ 1 
+  ( VisualSpace + K ( ( P "\\'" + P "{{" + P "}}" + 1 - S " {}'" ) ^ 1 ) ) ^ 1 
 
 local DoubleShortPureString = 
-  ( K ( ( P "\\\"" + P "{{" + P "}}" + 1 - S " {}\"" ) ^ 1 ) + VisualSpace ) ^ 1
+  ( VisualSpace + K ( ( P "\\\"" + P "{{" + P "}}" + 1 - S " {}\"" ) ^ 1 ) ) ^ 1
 
 local SingleLongPureString = 
   K ( ( 1 - P "'''" - S "{}'\r" ) ^ 1 )
@@ -3315,6 +3537,17 @@
 % \paragraph{EOL}
 %
 % \bigskip
+% The following LPEG will detect the Python prompts when the user is typesetting
+% an interactive session of Python (directly or throught |{pyconsole}| of
+% \pkg{pyluatex}). 
+%    \begin{macrocode}
+local Prompt = ( # ( P ">>>" + P "..." )  * Lc ( '\\@@_prompt:' ) ) ^ -1 
+%    \end{macrocode}
+% We remind that the marker |#| of LPEG specifies that the pattern will be
+% detected but won't consume any character.
+%
+%
+% \bigskip
 % The following \textsc{lpeg} |EOL| is for the end of lines.
 %    \begin{macrocode}
 local EOL
@@ -3336,6 +3569,7 @@
     Lc ( '\\@@_end_line:' ) 
     * BeamerEndEnvironments 
     * BeamerBeginEnvironments 
+    * Prompt
     * Lc ( '\\@@_newline: \\@@_begin_line:' )
   ) 
   *
@@ -3345,7 +3579,7 @@
   P "\r" 
   *
   (
-    ( space^0 * -1 )
+    ( space ^ 0 * -1 )
     + 
 %    \end{macrocode}
 % We recall that each line in the Python code we have to parse will be sent
@@ -3354,7 +3588,9 @@
 % @@\_end\_line:} must be explicit because it will be used as marker in order to
 % delimit the argument of the command \texttt{\textbackslash @@\_begin\_line:}}.
 %    \begin{macrocode}
-    Lc ( '\\@@_end_line: \\@@_newline: \\@@_begin_line:' )
+    Lc ( '\\@@_end_line:' )  
+    * Prompt
+    * Lc ( '\\@@_newline: \\@@_begin_line:' )
   ) 
   *
   SpaceIndentation ^ 0
@@ -3448,7 +3684,9 @@
 %    \begin{macrocode}
 local StringDoc = 
     K ( P "\"\"\"" , 'String.Doc' )
-      * ( K ( (1 - P "\"\"\"" - P "\r" ) ^ 0 , 'String.Doc' ) * EOL * Tab ^0 ) ^ 0
+      * ( K ( (1 - P "\"\"\"" - P "\r" ) ^ 0 , 'String.Doc' ) * EOL 
+          * Tab ^ 0 
+        ) ^ 0
       * K ( ( 1 - P "\"\"\"" - P "\r" ) ^ 0 * P "\"\"\"" , 'String.Doc' )
 %    \end{macrocode}
 %
@@ -3583,7 +3821,7 @@
 % \paragraph{The dictionaries of Python}
 %
 % We have \textsc{lpeg} dealing with dictionaries of Python because, in
-% typesettings of explicit Python dictionnaries, one may prefer to have all the
+% typesettings of explicit Python dictionaries, one may prefer to have all the
 % values formatted in black (in order to see more clearly the keys which are
 % usually Python strings). That's why we have a \pkg{piton} style |Dict.Value|.
 %
@@ -3621,12 +3859,6 @@
 local ExceptionInConsole = Exception *  K ( ( 1 - P "\r" ) ^ 0 ) * EOL  
 %    \end{macrocode}
 % 
-% \bigskip
-% \paragraph{The user commands and environments}
-%
-%    \begin{macrocode}
-UserEnvironments = P ( true ) 
-%    \end{macrocode}
 % 
 % \bigskip
 % \paragraph{The main LPEG}
@@ -3636,8 +3868,8 @@
 MainLoop = 
   (  ( space^1 * -1 ) 
      + EOL
+     + Space 
      + Tab
-     + Space
      + Escape 
      + CommentLaTeX
      + Beamer 
@@ -3657,10 +3889,10 @@
      + RaiseException 
      + DefFunction
      + DefClass 
-     + Keyword * ( Space + Punct + Delim + EOL + -1) 
+     + Keyword * ( Space + Punct + Delim + EOL + -1 ) 
      + Decorator
-     + OperatorWord * ( Space + Punct + Delim + EOL + -1) 
-     + Builtin * ( Space + Punct + Delim + EOL + -1) 
+     + OperatorWord * ( Space + Punct + Delim + EOL + -1 ) 
+     + Builtin * ( Space + Punct + Delim + EOL + -1 ) 
      + Identifier 
      + Number
      + Word
@@ -3681,7 +3913,7 @@
     Ct (
          ( ( space - P "\r" ) ^0 * P "\r" ) ^ -1 
          * BeamerBeginEnvironments 
-         * UserEnvironments 
+         * Prompt
          * Lc ( '\\@@_begin_line:' ) 
          * SpaceIndentation ^ 0 
          * MainLoop
@@ -3706,23 +3938,12 @@
 % \bigskip
 %    \begin{macrocode}
 function piton.Parse(code)
-  local t = SyntaxPython : match ( code ) -- match is a method of the LPEG
+  local t = SyntaxPython : match ( code ) 
   for _ , s in ipairs(t) do tex.tprint(s) end 
 end
 %    \end{macrocode}
 %
-% 
 % \bigskip
-% The following command will be used by the user command |\piton|.
-% For that command, we have to undo the duplication of the symbols |#|.
-%    \begin{macrocode}
-function piton.pitonParse(code)
-  local s = ( Cs ( ( P '##' / '#' + 1 ) ^ 0 ) ) : match ( code )
-  return piton.Parse(s) 
-end
-%    \end{macrocode}
-% 
-% \bigskip
 % The function |ParseFile| will be used by the LaTeX command |\PitonInputFile|.
 % That function merely reads the whole file (that is to say all its lines) and
 % then apply the function~|Parse| to the resulting Lua string.
@@ -3740,8 +3961,35 @@
   piton.Parse(s) 
 end
 %    \end{macrocode}
+% 
+% \bigskip
+% \subsubsection{Two vairants of  the function Parse with integrated preprocessors}
 %
+% The following command will be used by the user command |\piton|.
+% For that command, we have to undo the duplication of the symbols |#|.
+%    \begin{macrocode}
+function piton.ParseBis(code)
+  local s = ( Cs ( ( P '##' / '#' + 1 ) ^ 0 ) ) : match ( code )
+  return piton.Parse(s) 
+end
+%    \end{macrocode}
+%
 % \bigskip
+% The following command will be used when we have to parse some small chunks of
+% code that have yet been parsed. They are re-scanned by LaTeX because it has
+% been required by |\@@_piton:n| in the \pkg{piton} style of the syntaxic
+% element. In that case, you have to remove the potential |\@@_breakable_space:|
+% that have been inserted when the key |break-lines| is in force.
+%    \begin{macrocode}
+function piton.ParseTer(code)
+  local s = ( Cs ( ( P '\\@@_breakable_space:' / ' ' + 1 ) ^ 0 ) ) 
+            : match ( code )
+  return piton.Parse(s)
+end
+%    \end{macrocode}
+% 
+%
+% \bigskip
 % \subsubsection{The preprocessors of the function Parse}
 %
 % We deal now with preprocessors of the function |Parse| which are needed when
@@ -3920,7 +4168,6 @@
 end 
 %    \end{macrocode}
 % 
-% 
 % \bigskip
 %    \begin{macrocode}
 \end{luacode*}
@@ -3929,6 +4176,21 @@
 % 
 % \vspace{1cm}
 % \section{History}
+%
+% \subsection*{Changes between versions 1.2 and 1.3}
+%
+% When the class Beamer is used, the environment |{Piton}| and the command 
+% |\PitonInputFile| are ``overlay-aware'' (that is to say, they accept a
+% specification of overlays between angular brackets).
+%
+% New key |prompt-background-color|
+%
+% It's now possible to use the command |\label| to reference a line of code in
+% an environment |{Piton}|.
+%
+% A new command |\|␣ is available in the argument of the command |\piton{...}| to
+% insert a space (otherwise, several spaces are replaced by a single space).
+% 
 % \subsection*{Changes between versions 1.1 and 1.2}
 %
 % New keys |break-lines-in-piton| and |break-lines-in-Piton|.

Modified: trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty	2023-01-29 21:21:06 UTC (rev 65672)
+++ trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty	2023-01-29 21:21:33 UTC (rev 65673)
@@ -18,10 +18,9 @@
 %% and version 1.3 or later is part of all distributions of
 %% LaTeX version 2005/12/01 or later.
 %% 
-\def\myfileversion{1.2}
-\def\myfiledate{2023/01/16}
+\def\myfileversion{1.3}
+\def\myfiledate{2023/01/29}
 
-
 \bigskip
 
 %%
@@ -136,7 +135,8 @@
 \tl_new:N \g__piton_aux_tl
 \int_new:N \l__piton_splittable_int
 \int_set:Nn \l__piton_splittable_int { 100 }
-\str_new:N \l__piton_background_color_str
+\str_new:N \l__piton_bg_color_tl
+\str_new:N \l__piton_prompt_bg_color_tl
 \dim_new:N \g__piton_width_dim
 \dim_new:N \l__piton_width_on_aux_dim
 \int_new:N \g__piton_env_int
@@ -172,6 +172,29 @@
     \str_set:Nn \l__piton_beamer_command_str { #1 }
     \use:c { #1 }
   }
+\cs_new_protected:Npn \__piton_label:n #1
+  {
+    \bool_if:NTF \l__piton_line_numbers_bool
+      {
+        \@bsphack
+        \protected at write \@auxout { }
+          {
+            \string \newlabel { #1 }
+            {
+              { \int_eval:n { \g__piton_visual_line_int + 1 } }
+              { \thepage }
+            }
+          }
+        \@esphack
+     }
+     { \msg_error:nn { piton } { label~with~lines~numbers } }
+  }
+\tl_new:N \g__piton_begin_line_hook_tl
+\cs_new_protected:Npn \__piton_prompt:
+  {
+    \tl_gset:Nn \g__piton_begin_line_hook_tl
+      { \tl_set:NV \l__piton_bg_color_tl \l__piton_prompt_bg_color_tl }
+  }
 \cs_new_protected:Npn \__piton_replace_spaces:n #1
   {
     \tl_set:Nn \l_tmpa_tl { #1 }
@@ -191,11 +214,13 @@
 \cs_generate_variant:Nn \__piton_replace_spaces:n { x }
 \cs_set_protected:Npn \__piton_begin_line: #1 \__piton_end_line:
   {
+    \group_begin:
+    \g__piton_begin_line_hook_tl
     \int_gzero:N \g__piton_indentation_int
     \bool_if:NTF \l__piton_slim_bool
       { \hcoffin_set:Nn \l_tmpa_coffin }
       {
-        \str_if_empty:NTF \l__piton_background_color_str
+        \str_if_empty:NTF \l__piton_bg_color_tl
           {
             \vcoffin_set:Nnn \l_tmpa_coffin
               { \dim_eval:n { \linewidth - \l__piton_left_margin_dim } }
@@ -221,7 +246,7 @@
               { \tl_if_empty:nF { #1 } }
               \__piton_print_number:
           }
-        \str_if_empty:NF \l__piton_background_color_str
+        \tl_if_empty:NF \l__piton_bg_color_tl
           { \skip_horizontal:n { 0.5 em } }
         \coffin_typeset:Nnnnn \l_tmpa_coffin T l \c_zero_dim \c_zero_dim
       }
@@ -229,7 +254,7 @@
       { \dim_gset:Nn \g__piton_width_dim { \box_wd:N \l_tmpa_box } }
     \box_set_dp:Nn \l_tmpa_box { \box_dp:N \l_tmpa_box + 1.25 pt }
     \box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + 1.25 pt }
-    \tl_if_empty:NTF \l__piton_background_color_str
+    \str_if_empty:NTF \l__piton_bg_color_tl
       { \box_use_drop:N \l_tmpa_box }
       {
         \vbox_top:n
@@ -236,7 +261,7 @@
           {
             \hbox:n
               {
-                \exp_args:NV \color \l__piton_background_color_str
+                \__piton_color:V \l__piton_bg_color_tl
                 \vrule height \box_ht:N \l_tmpa_box
                        depth \box_dp:N \l_tmpa_box
                        width \l__piton_width_on_aux_dim
@@ -247,7 +272,20 @@
           }
       }
     \vspace { - 2.5 pt }
+    \group_end:
+    \tl_gclear:N \g__piton_begin_line_hook_tl
   }
+\cs_set_protected:Npn \__piton_color:n #1
+  {
+    \tl_if_head_eq_meaning:nNTF { #1 } [
+      {
+        \tl_set:Nn \l_tmpa_tl { #1 }
+        \tl_set_rescan:Nno \l_tmpa_tl { } \l_tmpa_tl
+        \exp_last_unbraced:NV \color \l_tmpa_tl
+      }
+      { \color { #1 } }
+  }
+\cs_generate_variant:Nn \__piton_color:n { V }
 \cs_new_protected:Npn \__piton_newline:
   {
     \int_gincr:N \g__piton_line_int
@@ -276,7 +314,7 @@
               \l__piton_continuation_symbol_tl
             }
             \skip_horizontal:n { 0.3 em }
-            \str_if_empty:NF \l__piton_background_color_str
+            \tl_if_empty:NF \l__piton_bg_color_tl
               { \skip_horizontal:n { 0.5 em } }
           }
         \bool_if:NT \l__piton_indent_broken_lines_bool
@@ -313,8 +351,10 @@
     resume           .value_forbidden:n = true ,
     splittable       .int_set:N         = \l__piton_splittable_int ,
     splittable       .default:n         = 1 ,
-    background-color .str_set:N         = \l__piton_background_color_str ,
+    background-color .str_set:N         = \l__piton_bg_color_tl ,
     background-color .value_required:n  = true ,
+    prompt-background-color .str_set:N         = \l__piton_prompt_bg_color_tl ,
+    prompt-background-color .value_required:n  = true ,
     slim             .bool_set:N        = \l__piton_slim_bool ,
     slim             .default:n         = true ,
     left-margin      .code:n =
@@ -348,36 +388,6 @@
     unknown          .code:n =
       \msg_error:nn { piton } { Unknown~key~for~PitonOptions }
   }
-\msg_new:nnnn { piton } { Unknown~key~for~PitonOptions }
-  {
-    Unknown~key. \\
-    The~key~'\l_keys_key_str'~is~unknown~for~\token_to_str:N \PitonOptions.~
-    It~will~be~ignored.\\
-    For~a~list~of~the~available~keys,~type~H~<return>.
-  }
-  {
-    The~available~keys~are~(in~alphabetic~order):~
-    all-line-numbers,~
-    auto-gobble,~
-    break-lines,~
-    break-lines-in-piton,~
-    break-lines-in-Piton,~
-    continuation-symbol,~
-    continuation-symbol-on-indentation,~
-    end-of-broken-line,~
-    env-gobble,~
-    gobble,~
-    indent-broken-lines,~
-    left-margin,~
-    line-numbers,~
-    resume,~
-    show-spaces,~
-    show-spaces-in-strings,~
-    slim,~
-    splittable,~
-    tabs-auto-gobble,~
-    and~tab-size.
-  }
 \NewDocumentCommand \PitonOptions { } { \keys_set:nn { PitonOptions } }
 \int_new:N \g__piton_visual_line_int
 \cs_new_protected:Npn \__piton_print_number:
@@ -407,7 +417,7 @@
   {
     \bool_if:NT \l__piton_slim_bool
       {
-        \str_if_empty:NF \l__piton_background_color_str
+        \tl_if_empty:NF \l__piton_bg_color_tl
           {
             \tl_gput_right:Nx \g__piton_aux_tl
               {
@@ -423,15 +433,17 @@
   {
     \group_begin:
     \ttfamily
+    \automatichyphenmode = 1
     \cs_set_eq:NN \\ \c_backslash_str
     \cs_set_eq:NN \% \c_percent_str
     \cs_set_eq:NN \{ \c_left_brace_str
     \cs_set_eq:NN \} \c_right_brace_str
     \cs_set_eq:NN \$ \c_dollar_str
+    \cs_set_eq:cN { ~ } \space
     \cs_set_protected:Npn \__piton_begin_line: { }
     \cs_set_protected:Npn \__piton_end_line: { }
     \tl_set:Nx \l_tmpa_tl
-      { \lua_now:n { piton.pitonParse(token.scan_string()) } { #1 } }
+      { \lua_now:n { piton.ParseBis(token.scan_string()) } { #1 } }
     \bool_if:NTF \l__piton_show_spaces_bool
       { \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
       {
@@ -445,6 +457,7 @@
   {
     \group_begin:
     \ttfamily
+    \automatichyphenmode = 1
     \cs_set_protected:Npn \__piton_begin_line: { }
     \cs_set_protected:Npn \__piton_end_line: { }
     \tl_set:Nx \l_tmpa_tl
@@ -454,13 +467,23 @@
     \l_tmpa_tl
     \group_end:
   }
+
 \cs_new_protected:Npn \__piton_piton:n #1
   {
     \group_begin:
     \cs_set_protected:Npn \__piton_begin_line: { }
     \cs_set_protected:Npn \__piton_end_line: { }
-    \tl_set:Nx \l_tmpa_tl
-      { \lua_now:n { piton.Parse(token.scan_string()) } { #1 } }
+    \bool_lazy_or:nnTF
+      \l__piton_break_lines_in_piton_bool
+      \l__piton_break_lines_in_Piton_bool
+      {
+        \tl_set:Nx \l_tmpa_tl
+          { \lua_now:n { piton.ParseTer(token.scan_string()) } { #1 } }
+      }
+      {
+        \tl_set:Nx \l_tmpa_tl
+          { \lua_now:n { piton.Parse(token.scan_string()) } { #1 } }
+      }
     \bool_if:NT \l__piton_show_spaces_bool
       { \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
     \l_tmpa_tl
@@ -473,8 +496,17 @@
     \cs_set_protected:Npn \__piton_end_line: { }
     \cs_set_protected:Npn \__piton_newline:
       { \msg_fatal:nn { piton } { cr~not~allowed } }
-    \tl_set:Nx \l_tmpa_tl
-      { \lua_now:n { piton.Parse(token.scan_string()) } { #1 } }
+    \bool_lazy_or:nnTF
+      \l__piton_break_lines_in_piton_bool
+      \l__piton_break_lines_in_Piton_bool
+      {
+        \tl_set:Nx \l_tmpa_tl
+          { \lua_now:n { piton.ParseTer(token.scan_string()) } { #1 } }
+      }
+      {
+        \tl_set:Nx \l_tmpa_tl
+          { \lua_now:n { piton.Parse(token.scan_string()) } { #1 } }
+      }
     \bool_if:NT \l__piton_show_spaces_bool
       { \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
     \l_tmpa_tl
@@ -482,6 +514,7 @@
   }
 \cs_new:Npn \__piton_pre_env:
   {
+    \automatichyphenmode = 1
     \int_gincr:N \g__piton_env_int
     \tl_gclear:N \g__piton_aux_tl
     \cs_if_exist_use:c { c__piton _ \int_use:N \g__piton_env_int _ tl }
@@ -492,6 +525,8 @@
     \int_gzero:N \g__piton_line_int
     \dim_zero:N \parindent
     \dim_zero:N \lineskip
+    \dim_zero:N \parindent
+    \cs_set_eq:NN \label \__piton_label:n
   }
 \keys_define:nn { PitonInputFile }
   {
@@ -500,16 +535,22 @@
     last-line .int_set:N = \l__piton_last_line_int ,
     last-line .value_required:n = true ,
   }
-\NewDocumentCommand { \PitonInputFile } { O { } m }
+\NewDocumentCommand { \PitonInputFile } { d < > O { } m }
   {
+    \tl_if_novalue:nF { #1 }
+      {
+        \bool_if:NTF \c__piton_beamer_bool
+          { \begin { uncoverenv } < #1 > }
+          { \msg_error:nn { piton } { overlay~without~beamer } }
+      }
     \group_begin:
       \int_zero_new:N \l__piton_first_line_int
       \int_zero_new:N \l__piton_last_line_int
       \int_set_eq:NN \l__piton_last_line_int \c_max_int
-      \keys_set:nn { PitonInputFile } { #1 }
+      \keys_set:nn { PitonInputFile } { #2 }
       \__piton_pre_env:
       \mode_if_vertical:TF \mode_leave_vertical: \newline
-      \lua_now:n { piton.CountLinesFile(token.scan_argument()) } { #2 }
+      \lua_now:n { piton.CountLinesFile(token.scan_argument()) } { #3 }
       \bool_lazy_and:nnT \l__piton_left_margin_auto_bool \l__piton_line_numbers_bool
         {
          \hbox_set:Nn \l_tmpa_box
@@ -523,7 +564,7 @@
                {
                   \lua_now:n
                     { piton.CountNonEmptyLinesFile(token.scan_argument()) }
-                    { #2 }
+                    { #3 }
                   \int_to_arabic:n
                     { \g__piton_visual_line_int + \l__piton_nb_non_empty_lines_int }
                 }
@@ -534,20 +575,22 @@
       \bool_if:NT \c__piton_footnote_bool { \begin { savenotes } }
       \vtop \bgroup
       \lua_now:e
-        { piton.ParseFile(token.scan_argument(),
+        {
+          piton.ParseFile(token.scan_argument() ,
            \int_use:N \l__piton_first_line_int ,
            \int_use:N \l__piton_last_line_int )
         }
-        { #2 }
+        { #3 }
       \egroup
       \bool_if:NT \c__piton_footnote_bool { \end { savenotes } }
       \__piton_width_to_aux:
     \group_end:
+    \tl_if_novalue:nF { #1 }
+      { \bool_if:NT \c__piton_beamer_bool { \end { uncoverenv } } }
     \__piton_write_aux:
   }
 \NewDocumentCommand { \NewPitonEnvironment } { m m m m }
   {
-    \dim_zero:N \parindent
     \use:x
       {
         \cs_set_protected:Npn
@@ -613,7 +656,17 @@
       { #4 }
     \AddToHook { env / #1 / begin } { \char_set_catcode_other:N \^^M }
   }
-\NewPitonEnvironment { Piton } { } { } { }
+\bool_if:NTF \c__piton_beamer_bool
+  {
+    \NewPitonEnvironment { Piton } { d < > }
+      {
+        \IfValueTF { #1 }
+          { \begin { uncoverenv } < #1 > }
+          { \begin { uncoverenv } }
+      }
+      { \end { uncoverenv } }
+  }
+  { \NewPitonEnvironment { Piton } { } { } { } }
 \NewDocumentCommand { \PitonStyle } { m } { \use:c { pitonStyle #1 } }
 \NewDocumentCommand { \SetPitonStyle } { } { \keys_set:nn { piton / Styles } }
 \cs_new_protected:Npn \__piton_math_scantokens:n #1
@@ -738,6 +791,45 @@
     \token_to_str:N \piton\ but~there~is~no~environment~
     {piton}.~This~error~is~fatal.
   }
+\msg_new:nnnn { piton } { Unknown~key~for~PitonOptions }
+  {
+    Unknown~key. \\
+    The~key~'\l_keys_key_str'~is~unknown~for~\token_to_str:N \PitonOptions.~
+    It~will~be~ignored.\\
+    For~a~list~of~the~available~keys,~type~H~<return>.
+  }
+  {
+    The~available~keys~are~(in~alphabetic~order):~
+    all-line-numbers,~
+    auto-gobble,~
+    background-color,~
+    break-lines,~
+    break-lines-in-piton,~
+    break-lines-in-Piton,~
+    continuation-symbol,~
+    continuation-symbol-on-indentation,~
+    end-of-broken-line,~
+    env-gobble,~
+    gobble,~
+    indent-broken-lines,~
+    left-margin,~
+    line-numbers,~
+    prompt-background-color,~
+    resume,~
+    show-spaces,~
+    show-spaces-in-strings,~
+    slim,~
+    splittable,~
+    tabs-auto-gobble~
+    and~tab-size.
+  }
+\msg_new:nnn { piton } { label~with~lines~numbers }
+  {
+    You~can't~use~the~command~\token_to_str:N \label\
+    because~the~key~'line-numbers'~(or~'all-line-numbers')~
+    is~not~active.\\
+    If~you~go~on,~that~command~will~ignored.
+  }
 \msg_new:nnn { piton } { cr~not~allowed }
   {
     You~can't~put~any~carriage~return~in~the~argument~
@@ -747,6 +839,13 @@
     corresponding~environment.\\
     That~error~is~fatal.
   }
+\msg_new:nnn { piton } { overlay~without~beamer }
+  {
+    You~can't~use~an~argument~<...>~for~your~command~
+    \token_to_str:N \PitonInputFile\ because~you~are~not~
+    in~Beamer.\\
+    If~you~go~on,~that~argument~will~be~ignored.
+  }
 \ExplSyntaxOff
 \RequirePackage{luacode}
 \begin{luacode*}
@@ -780,7 +879,8 @@
   * L ( ( 1 - P(piton_end_escape) ) ^ 1 )
   * P(piton_end_escape)
 lpeg.locale(lpeg)
-local alpha, digit, space = lpeg.alpha, lpeg.digit, lpeg.space
+local alpha, digit = lpeg.alpha, lpeg.digit
+local space = P " "
 local letter = alpha + P "_"
   + P "â" + P "à" + P "ç" + P "é" + P "è" + P "ê" + P "ë" + P "ï" + P "î"
   + P "ô" + P "û" + P "ü" + P "Â" + P "À" + P "Ç" + P "É" + P "È" + P "Ê"
@@ -802,15 +902,14 @@
                    - S "'\"\r[()]" - digit ) ^ 1 )
 else Word = K ( ( ( 1 - space ) - S "'\"\r[()]" - digit ) ^ 1 )
 end
-local Space = K ( ( space - P "\r" ) ^ 1 )
+local Space = ( K " " ) ^ 1
 
-local SkipSpace = K ( ( space - P "\r" ) ^ 0 )
+local SkipSpace = ( K " " ) ^ 0
 
 local Punct = K ( S ".,:;!" )
+
 local Tab = P "\t" * Lc ( '\\l__piton_tab_tl' )
-local SpaceIndentation =
-   Lc ( '\\__piton_an_indentation_space:' ) * K " "
-
+local SpaceIndentation = Lc ( '\\__piton_an_indentation_space:' ) * ( K " " )
 local Delim = K ( S "[()]" )
 local Operator =
   K ( P "!=" + P "<>" + P "==" + P "<<" + P ">>" + P "<=" + P ">=" + P ":="
@@ -914,12 +1013,12 @@
   * K ( ( 1 - S "}:\r" - P "\"\"\"" ) ^ 0 , 'Interpol.Inside' )
   * K ( P ":" * (1 - S "}:\r" - P "\"\"\"" ) ^ 0 ) ^ -1
   * K ( P "}" , 'String.Interpol' )
-local VisualSpace = P " " * Lc "\\l__piton_space_tl"
+local VisualSpace = space * Lc "\\l__piton_space_tl"
 local SingleShortPureString =
-  ( K ( ( P "\\'" + P "{{" + P "}}" + 1 - S " {}'" ) ^ 1 ) + VisualSpace )  ^ 1
+  ( VisualSpace + K ( ( P "\\'" + P "{{" + P "}}" + 1 - S " {}'" ) ^ 1 ) ) ^ 1
 
 local DoubleShortPureString =
-  ( K ( ( P "\\\"" + P "{{" + P "}}" + 1 - S " {}\"" ) ^ 1 ) + VisualSpace ) ^ 1
+  ( VisualSpace + K ( ( P "\\\"" + P "{{" + P "}}" + 1 - S " {}\"" ) ^ 1 ) ) ^ 1
 
 local SingleLongPureString =
   K ( ( 1 - P "'''" - S "{}'\r" ) ^ 1 )
@@ -1039,6 +1138,7 @@
         * P "\r"
       ) ^ 0
 end
+local Prompt = ( # ( P ">>>" + P "..." )  * Lc ( '\\__piton_prompt:' ) ) ^ -1
 local EOL
 if piton_beamer
 then
@@ -1051,6 +1151,7 @@
     Lc ( '\\__piton_end_line:' )
     * BeamerEndEnvironments
     * BeamerBeginEnvironments
+    * Prompt
     * Lc ( '\\__piton_newline: \\__piton_begin_line:' )
   )
   *
@@ -1060,9 +1161,11 @@
   P "\r"
   *
   (
-    ( space^0 * -1 )
+    ( space ^ 0 * -1 )
     +
-    Lc ( '\\__piton_end_line: \\__piton_newline: \\__piton_begin_line:' )
+    Lc ( '\\__piton_end_line:' )
+    * Prompt
+    * Lc ( '\\__piton_newline: \\__piton_begin_line:' )
   )
   *
   SpaceIndentation ^ 0
@@ -1133,7 +1236,9 @@
 local LongString = SingleLongString + DoubleLongString
 local StringDoc =
     K ( P "\"\"\"" , 'String.Doc' )
-      * ( K ( (1 - P "\"\"\"" - P "\r" ) ^ 0 , 'String.Doc' ) * EOL * Tab ^0 ) ^ 0
+      * ( K ( (1 - P "\"\"\"" - P "\r" ) ^ 0 , 'String.Doc' ) * EOL
+          * Tab ^ 0
+        ) ^ 0
       * K ( ( 1 - P "\"\"\"" - P "\r" ) ^ 0 * P "\"\"\"" , 'String.Doc' )
 local CommentMath =
   P "$" * K ( ( 1 - S "$\r" ) ^ 1 , 'Comment.Math' ) * P "$"
@@ -1200,12 +1305,11 @@
   * ItemOfSet * ( K ( P "," ) * ItemOfSet )  ^ 0
   * K ( P "}" )
 local ExceptionInConsole = Exception *  K ( ( 1 - P "\r" ) ^ 0 ) * EOL
-UserEnvironments = P ( true )
 MainLoop =
   (  ( space^1 * -1 )
      + EOL
+     + Space
      + Tab
-     + Space
      + Escape
      + CommentLaTeX
      + Beamer
@@ -1222,10 +1326,10 @@
      + RaiseException
      + DefFunction
      + DefClass
-     + Keyword * ( Space + Punct + Delim + EOL + -1)
+     + Keyword * ( Space + Punct + Delim + EOL + -1 )
      + Decorator
-     + OperatorWord * ( Space + Punct + Delim + EOL + -1)
-     + Builtin * ( Space + Punct + Delim + EOL + -1)
+     + OperatorWord * ( Space + Punct + Delim + EOL + -1 )
+     + Builtin * ( Space + Punct + Delim + EOL + -1 )
      + Identifier
      + Number
      + Word
@@ -1237,7 +1341,7 @@
     Ct (
          ( ( space - P "\r" ) ^0 * P "\r" ) ^ -1
          * BeamerBeginEnvironments
-         * UserEnvironments
+         * Prompt
          * Lc ( '\\__piton_begin_line:' )
          * SpaceIndentation ^ 0
          * MainLoop
@@ -1248,13 +1352,9 @@
 
 piton.defSyntaxPython()
 function piton.Parse(code)
-  local t = SyntaxPython : match ( code ) -- match is a method of the LPEG
+  local t = SyntaxPython : match ( code )
   for _ , s in ipairs(t) do tex.tprint(s) end
 end
-function piton.pitonParse(code)
-  local s = ( Cs ( ( P '##' / '#' + 1 ) ^ 0 ) ) : match ( code )
-  return piton.Parse(s)
-end
 function piton.ParseFile(name,first_line,last_line)
   s = ''
   local i = 0
@@ -1267,6 +1367,15 @@
   end
   piton.Parse(s)
 end
+function piton.ParseBis(code)
+  local s = ( Cs ( ( P '##' / '#' + 1 ) ^ 0 ) ) : match ( code )
+  return piton.Parse(s)
+end
+function piton.ParseTer(code)
+  local s = ( Cs ( ( P '\\__piton_breakable_space:' / ' ' + 1 ) ^ 0 ) )
+            : match ( code )
+  return piton.Parse(s)
+end
 local function gobble(n,code)
   function concat(acc,new_value)
     return acc .. new_value



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