texlive[65557] Master/texmf-dist: piton (16jan23)

commits+karl at tug.org commits+karl at tug.org
Mon Jan 16 22:10:15 CET 2023


Revision: 65557
          http://tug.org/svn/texlive?view=revision&revision=65557
Author:   karl
Date:     2023-01-16 22:10:15 +0100 (Mon, 16 Jan 2023)
Log Message:
-----------
piton (16jan23)

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-16 21:10:00 UTC (rev 65556)
+++ trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex	2023-01-16 21:10:15 UTC (rev 65557)
@@ -20,6 +20,7 @@
 \usepackage{amsmath}
 \usepackage{tabularx}
 \usepackage{booktabs}
+\usepackage{tcolorbox}
 
 \usepackage{caption}
 
@@ -57,8 +58,8 @@
   } 
 
 
-\NewDocumentEnvironment {scope} {} {} {}
 
+
 \NewDocumentCommand {\pkg} {m} {\textsf{#1}}
 \NewDocumentCommand {\cls} {m} {\textsf{#1}}
 
@@ -243,55 +244,63 @@
 
 \subsection{La commande \textbackslash PitonOptions}
 
+\NewDocumentCommand{\Definition}{m}
+  {{\setlength{\fboxsep}{1pt}\colorbox{gray!20}{\ttfamily \vphantom{gl}#1}}}
 
+
 La commande |\PitonOptions| prend en argument une liste de couples \textsl{clé=valeur}. La portée des réglages
 effectués par cette commande est le groupe TeX courant.\footnote{On rappelle que tout environnement LaTeX est, en particulier, un groupe.}
 
 \begin{itemize}
-\item La clé |gobble| prend comme valeur un entier positif $n$ : les $n$ premiers caractères de chaque ligne sont 
-alors retirés (avant formatage du code) dans les environnements |{Piton}|. Ces $n$ caractères ne sont pas
-nécessairement des espaces.
+\item La clé \Definition{gobble} prend comme valeur un entier positif $n$ : les $n$ premiers caractères de chaque
+ligne sont alors retirés (avant formatage du code) dans les environnements |{Piton}|. Ces $n$ caractères ne sont
+pas nécessairement des espaces.
 
-\item Quand la clé |auto-gobble| est activée, l'extension \pkg{piton} détermine la valeur minimale $n$ du nombre
-d'espaces successifs débutant chaque ligne (non vide) de l'environnement |{Piton}| et applique |gobble| avec cette
-valeur de~$n$.
+\item Quand la clé \Definition{auto-gobble} est activée, l'extension \pkg{piton} détermine la valeur minimale $n$
+du nombre d'espaces successifs débutant chaque ligne (non vide) de l'environnement |{Piton}| et applique |gobble|
+avec cette valeur de~$n$.
 
-\item Quand la clé |env-gobble| est activée, \pkg{piton} analyse la dernière ligne de l'environnement, c'est-à-dire
-celle qui contient le |\end{Piton}| et détermine si cette ligne ne comporte que des espaces suivis par
+\item Quand la clé \Definition{env-gobble} est activée, \pkg{piton} analyse la dernière ligne de l'environnement,
+c'est-à-dire celle qui contient le |\end{Piton}| et détermine si cette ligne ne comporte que des espaces suivis par
 |\end{Piton}|. Si c'est le cas, \pkg{piton} calcule le nombre $n$ de ces espaces et applique |gobble| avec cette
 valeur de~$n$. Le nom de cette clé vient de \emph{environment gobble}: le nombre d'espaces à retirer ne dépend que
 de la position des délimiteurs |\begin{Piton}| et |\end{Piton}| de l'environnement.
 
-\item Avec la clé |line-numbers|, les lignes \emph{non vides} (et toutes les lignes des \emph{docstrings}, y
-compris celles qui sont vides) sont numérotées dans les environnements \verb|{Piton}| et dans les listings produits
-par la commande |\PitonInputFile|.
+\item Avec la clé \Definition{line-numbers}, les lignes \emph{non vides} (et toutes les lignes des
+\emph{docstrings}, y compris celles qui sont vides) sont numérotées dans les environnements \verb|{Piton}| et dans
+les listings produits par la commande |\PitonInputFile|.
 
-\item Avec la clé |all-line-numbers|, \emph{toutes} les lignes sont numérotées, y compris les lignes vides.
+\item Avec la clé \Definition{all-line-numbers}, \emph{toutes} les lignes sont numérotées, y compris les lignes vides.
 
-\item La clé |left-margin| fixe une marge sur la gauche. Cette clé peut être utile, en particulier, en conjonction
-avec l'une des clés |line-numbers| et |all-line-numbers| si on ne souhaite pas que les numéros de ligne soient dans
-une position en débordement sur la gauche. 
+\item La clé \Definition{left-margin} fixe une marge sur la gauche. Cette clé peut être utile, en particulier, en
+conjonction avec l'une des clés |line-numbers| et |all-line-numbers| si on ne souhaite pas que les numéros de ligne
+soient dans une position en débordement sur la gauche.
 
 Il est possible de donner à la clé |left-margin| la valeur spéciale~|auto|. Avec cette valeur, une marge est
 insérée automatiquement pour les numéros de ligne quand l'une des clés |line-numbers| ou |all-line-numbers| est
 utilisée. Voir un exemple à la partie \ref{example-numbering} p.~\pageref{example-numbering}.
 
-\item Avec la clé |resume|, le compteur de lignes n'est pas remis à zéro comme il l'est normalement au début d'un
-environnement |{Piton}| ou bien au début d'un listing produit par |\PitonInputFile|. Cela permet de poursuivre la
-numérotation d'un environnement à l'autre.
+\item Avec la clé \Definition{resume}, le compteur de lignes n'est pas remis à zéro comme il l'est normalement au
+début d'un environnement |{Piton}| ou bien au début d'un listing produit par |\PitonInputFile|. Cela permet de
+poursuivre la numérotation d'un environnement à l'autre.
 
-\item La clé |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|). 
+\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|).
 
-\item En activant la clé |show-spaces|, 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 utilisée.\footnote{L'extension \pkg{piton} utilise simplement la fonte
-  mono-chasse courante. Pour la changer, le mieux est d'utiliser |\setmonofont| de \pkg{fontspec}.}\par\nobreak
+\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
+utilisée.\footnote{L'extension \pkg{piton} utilise simplement la fonte mono-chasse courante. Pour la changer, le
+  mieux est d'utiliser |\setmonofont| de \pkg{fontspec}.}\par\nobreak
 %
 \begingroup
-\PitonOptions{show-spaces}
+\PitonOptions{show-spaces-in-strings}
 Exemple : \piton{my_string = 'Très bonne réponse'}
 \endgroup
+
+\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).
 \end{itemize}
 
 \bigskip
@@ -472,7 +481,28 @@
   {\end{tcolorbox}}
 \end{verbatim}
 
+\bigskip
+Avec ce nouvel environnement |{Python}|, on écrire : 
 
+\begin{Verbatim}
+~emphase#\begin{Python}@
+def carré(x):
+    """Calcule le carré d'un nombre"""
+    return x*x
+~emphase#\end{Python}@
+\end{Verbatim}
+
+\NewPitonEnvironment{Python}{}
+  {\begin{tcolorbox}}
+  {\end{tcolorbox}}
+
+\begin{Python}
+def carré(x):
+    """Calcule le carré d'un nombre"""
+    return x*x
+\end{Python}
+
+
 \section{Fonctionnalités avancées}
 
 \subsection{Les échappements vers LaTeX}
@@ -530,7 +560,7 @@
 
 \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
+Il est possible de demander que, dans les commentaires Python normaux, c'est-à-dire débutant par~|#| (et non par
 |#>|), les éléments placés entre symboles \texttt{\$} soient composés en mode mathématique de LaTeX (le reste du
 commentaire restant composé en verbatim).
 
@@ -603,40 +633,92 @@
 \colorbox{yellow!50}{\textbf{Nouveau 1.1}}
 
 \smallskip
-Quand \pkg{piton} est utilisé dans la classe \cls{beamer}, les commandes suivantes de \cls{beamer} sont détectées
-directement dans les environnements |{Piton}| (sans avoir à utiliser aucun mécanisme d'échappement) : |\action|,
-|\alert|, |\invisible|, |\only|, |\uncover| et |\visible|.\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}|}
+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}| : 
+%
+\begin{itemize}
+\item aucun argument obligatoire : |\pause| ;
+\item un argument obligatoire : |\action|, |\alert|, |\invisible|, |\only|, |\uncover| et |\visible| ;
+\item deux arguments obligatoire : |\alt| ; 
+\item trois arguments obligatoires : |\temporal|.
+\end{itemize}
 
 \medskip
-Néanmoins, \textbf{il ne doit pas y avoir de retours à la ligne} dans les arguments de ces commandes.
+Néanmoins, il y a deux restrictions pour le contenu des arguments obligatoires de ces commandes.
+\begin{itemize}
+\item les accolades dans les arguments obligatoires de ces commandes doivent être équilibrées (cependant, les
+accolades présentes dans des chaînes courtes\footnote{Les chaînes courtes de Python sont les chaînes (string)
+  délimitées par les caractères \texttt{'} ou \texttt{"} non triplés. En Python, les chaînes de caractères courtes
+  ne peuvent pas s'étendre sur plusieurs lignes de code.} de Python ne sont pas prises en compte) ;
+\item l'argument obligatoire ne doit pas contenir \textbf{aucun retour à la ligne} (s'il y en a, une erreur
+fatale est levée). 
+\end{itemize}
 
 \medskip
 Remarquons que, comme l'environnement |{Piton}| prend son argument selon un mode verbatim, il convient, ce qui
-n'est pas surprenant, de l'utiliser dans des |{frame}| protégés par la clé |fragile|.
+n'est pas surprenant, de l'utiliser dans des environnements |{frame}| de Beamer protégés par la clé |fragile|.\footnote{On
+  rappelle que pour un environnement |{frame}| de Beamer qui utilise la clé |fragile|, l'instruction |\end{frame}|
+  doit être seule sur une ligne (à l'exception d'éventuels espaces en début de ligne).}
 
 \medskip
 Voici un exemple complet de fichier :
 
-\begin{Verbatim}
+\begin{Verbatim}[formatcom = \small\color{gray}]
 \documentclass{beamer}
-\usepackage{xcolor}
 \usepackage{piton}
+\begin{document}
+\begin{frame}[fragile]
+\begin{Piton}
+def string_of_list(l):
+    """Convertit une liste de nombres en chaîne"""
+~emphase#    \only<2->{s = "{" + str(l[0])}@
+~emphase#    \only<3->{for x in l[1:]: s = s + "," + str(x)}@
+~emphase#    \only<4->{s = s + "}"}@
+    return s
+\end{Piton}
+\end{frame}
+\end{document}
+\end{Verbatim}
 
+Dans l'exemple précédent, les accolades des deux chaînes de caractères Python |"{"| et |"}"| sont correctement interprétées (sans aucun
+caractère d'échappement).
+
+
+\bigskip
+\colorbox{yellow!50}{\textbf{Nouveau 1.2}}
+
+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}|.
+
+\medskip
+Il y a néanmoins une restriction : ces environnements doivent englober des \emph{lignes entières de code Python}.
+
+\medskip
+On peut par exemple écrire :
+
+\begin{Verbatim}[formatcom = \small\color{gray}]
+\documentclass{beamer}
+\usepackage{piton}
 \begin{document}
-
 \begin{frame}[fragile]
 \begin{Piton}
 def carré(x):
-~emphase#\only<2>{    return x*x}@
+    """Calcule le carré de l'argument"""
+    ~emphase#\begin{uncoverenv}<2>@
+    return x*x
+    ~emphase#\end{uncoverenv}@
 \end{Piton}
 \end{frame}
-
 \end{document}
 \end{Verbatim}
 
 
+
+
+
 \bigskip
 \subsection{Coupure des pages et des lignes}
 
@@ -668,16 +750,27 @@
 
 \subsubsection{Coupure des lignes}
 
-Par défaut les lignes dans les listings produits par |{Piton}| et commande |\PitonInputFile| ne
-sont pas sécables.
+Par défaut, les éléments produits par \pkg{piton} ne peuvent pas être coupés par une fin de ligne. Il existe
+néanmoins des clés pour autoriser de telles coupures (les points de coupure possibles sont les espaces, y compris
+les espaces dans les chaînes Python).
+\begin{itemize}
+\item Avec la clé |break-lines-in-piton|, les coupures de ligne sont autorisées dans la commande |\piton{...}|
+(mais pas dans la commande \verb+|...|+, c'est-à-dire avec la syntaxe verbatim). 
 
+\item Avec la clé |break-lines-in-Piton|, les coupures de ligne sont autorisées dans l'environnement |{Piton}|
+(d'où la lettre |P| capitale dans le nom) et dans les listings produits par |\PitonInputFile|.
+
+\item La clé |break-lines| est la conjonction des deux clés précédentes.
+\end{itemize}
+
 \medskip
-Il existe néanmoins des clés (disponibles dans |\PitonOptions|) pour autoriser ces coupures.
+\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}
-\item La clé |break-lines| active la coupure des lignes. Les seuls points de coupure possibles sont les espaces (y compris
-dans les chaînes de caractères).
-
 \item Avec la clé |indent-broken-lines|, l'indentation de la ligne coupée est respectée à chaque retour à la ligne.
 
 \item La clé |end-of-broken-line| correspond au symbole placé à la fin d'une ligne coupée. Sa valeur initiale est : 
@@ -719,6 +812,7 @@
 \end{center}
 
 
+
 \bigskip
 \subsection{Notes de pied de page dans les environnements de piton}
 

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-16 21:10:00 UTC (rev 65556)
+++ trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx	2023-01-16 21:10:15 UTC (rev 65557)
@@ -15,8 +15,8 @@
 %
 % \fi
 % \iffalse
-\def\myfileversion{1.1}
-\def\myfiledate{2023/01/07}
+\def\myfileversion{1.2}
+\def\myfiledate{2023/01/16}
 %
 %
 %<*batchfile> 
@@ -51,7 +51,7 @@
 \geometry{left=2.8cm,right=2.8cm,top=2.5cm,bottom=2.5cm,papersize={21cm,29.7cm}}
 \usepackage{fontspec}
 \usepackage[dvipsnames]{xcolor}
-\usepackage{caption,tabularx}
+\usepackage{caption,tabularx,tcolorbox}
 \def\emphase{\bgroup\color{RoyalPurple}\let\next=}
 \fvset{commandchars=\~\#\@,formatcom=\color{gray}}
 \captionsetup{labelfont = bf}
@@ -256,6 +256,10 @@
 %
 % \subsection{The command \textbackslash PitonOptions}
 %
+%
+% \NewDocumentCommand{\Definition}{m}
+%   {{\setlength{\fboxsep}{1pt}\colorbox{gray!20}{\ttfamily \vphantom{gl}#1}}}
+% 
 % The command |\PitonOptions| takes in as argument a comma-separated list of
 % \textsl{key=value} pairs. The scope of the settings done by that command is
 % the current TeX group.\footnote{We remind that a LaTeX environment is, in
@@ -262,17 +266,17 @@
 % particular, a TeX group.}
 %
 % \begin{itemize}
-% \item The key |gobble| takes in as value a positive integer~$n$: the first $n$
-% characters are discarded (before the process of highlightning of the code) for
-% each line of the environment |{Piton}|. These characters are not necessarily
-% spaces. 
+% \item The key \Definition{gobble} takes in as value a
+% positive integer~$n$: the first $n$ characters are discarded (before the
+% process of highlightning of the code) for each line of the environment
+% |{Piton}|. These characters are not necessarily spaces.
 %
-% \item When the key |auto-gobble| is in force, the extension \pkg{piton} computes
-% the minimal value $n$ of the number of consecutive spaces beginning each (non
-% empty) line of the environment |{Piton}| and applies |gobble| with that value
-% of~$n$.
+% \item When the key \Definition{auto-gobble} is in force, the
+% extension \pkg{piton} computes the minimal value $n$ of the number of
+% consecutive spaces beginning each (non empty) line of the environment
+% |{Piton}| and applies |gobble| with that value of~$n$.
 %
-% \item When the key |env-gobble| is in force, \pkg{piton} analyzes the last
+% \item When the key \Definition{env-gobble} is in force, \pkg{piton} analyzes the last
 % line of the environment |{Piton}|, that is to say the line which contains
 % |\end{Piton}| and determines whether that line contains only spaces followed
 % by the |\end{Piton}|. If we are in that situation, \pkg{piton} computes the
@@ -281,23 +285,23 @@
 % gobble is set by the position of the commands |\begin{Piton}| and
 % |\end{Piton}| which delimit the current environment.
 %
-% \item With the key |line-numbers|, the \emph{non empty} lines (and all the
-% lines of the \emph{docstrings}, even the empty ones) are numbered in the
-% environments |{Piton}| and in the listings resulting from the use of
+% \item With the key \Definition{line-numbers}, the \emph{non empty} lines (and
+% all the lines of the \emph{docstrings}, even the empty ones) are numbered in
+% the environments |{Piton}| and in the listings resulting from the use of
 % |\PitonInputFile|.
 % 
-% \item With the key |all-line-numbers|, \emph{all} the lines are numbered,
+% \item With the key \Definition{all-line-numbers}, \emph{all} the lines are numbered,
 % including the empty ones.
 %
-% \item With the key |resume| the counter of lines is not set to zero at the
-% beginning of each environment |{Piton}| or use of |\PitonInputFile| as it is
-% otherwise. That allows a numbering of the lines across several
-% environments. 
+% \item With the key \Definition{resume} the counter of lines is not set to zero
+% at the beginning of each environment |{Piton}| or use of |\PitonInputFile| as
+% it is otherwise. That allows a numbering of the lines across several
+% environments.
 %
-% \item The key |left-margin| corresponds to a margin on the left. That key may
-% be useful in conjonction with the key |line-numbers| or the key
+% \item The key \Definition{left-margin} corresponds to a margin on the left.
+% That key may be useful in conjonction with the key |line-numbers| or the key
 % |line-all-numbers| if one does not want the numbers in an overlapping position
-% on the left. 
+% on the left.
 %
 % It's possible to use the key |left-margin| with the value |auto|. With that
 % value, if the key |line-numbers| or the key |all-line-numbers| is used, a
@@ -304,18 +308,23 @@
 % margin will be automatically inserted to fit the numbers of lines. See an
 % example part \ref{example-numbering} on page~\pageref{example-numbering}.
 %
-% \item The key |background-color| sets the background color of the environments
-% |{Piton}| and the listings produced by |\PitonInputFile| (that background has
-% a width of |\linewidth|). 
+% \item The key \Definition{background-color} sets the background color of the
+% environments |{Piton}| and the listings produced by |\PitonInputFile| (that
+% background has a width of |\linewidth|).
 %
-% \item When the key |show-spaces| is activated, the spaces in the short strings
-% (that is to say those delimited by |'| or |"|) are replaced by the character~␣
+% \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~␣
 % (U+2423 : \textsc{open box}). Of course, that character~U+2423 must be present
 % in the monospaced font which is used.\footnote{The package \pkg{piton} simply
 % uses the current monospaced font. The best way to change that font is to use
 % the command \texttt{\textbackslash setmonofont} of
-% \pkg{fontspec}.}\par\nobreak \begingroup \PitonOptions{show-spaces} Example :
-% \piton|my_string = 'Very good answer'| \endgroup
+% \pkg{fontspec}.}\par\nobreak \begingroup \PitonOptions{show-spaces-in-strings}
+% Example : \piton|my_string = 'Very good answer'| \endgroup
+%
+% With the key \Definition{show-spaces}, all the spaces are replaced by U+2423 (and no line
+% break can occur on those ``visible spaces'', even when the key |break-lines|
+% is in force).
 % \end{itemize}
 %
 % \bigskip
@@ -506,7 +515,28 @@
 %   {\end{tcolorbox}}
 % \end{verbatim}
 %
+\bigskip
+% With this new environment |{Python}|, it's possible to write:
 %
+% \begin{Verbatim}
+% ~emphase#\begin{Python}@
+% def square(x):
+%     """Compute the square of a number"""
+%     return x*x
+% ~emphase#\end{Python}@
+% \end{Verbatim}
+%
+% \NewPitonEnvironment{Python}{}
+%   {\begin{tcolorbox}}
+%   {\end{tcolorbox}}
+%
+% \begin{Python}
+% def square(x):
+%     """Compute the square of a number"""
+%     return x*x
+% \end{Python}
+%
+%
 % \section{Advanced features}
 %
 % \subsection{Mechanisms to escape to LaTeX}
@@ -593,7 +623,7 @@
 %
 % In order to use this mechanism, it's necessary to specify two characters which
 % will delimit the escape (one for the beginning and one for the end) by using
-% the key |escape-inside| at load-time (that is to say a the
+% the key |escape-inside| at load-time (that is to say at the
 % |\begin{docuemnt}|). 
 %
 % \medskip
@@ -640,38 +670,88 @@
 % \colorbox{yellow!50}{\textbf{New 1.1}}
 %
 % \smallskip
-% When \pkg{piton} is used in the class \cls{beamer}, the following commands of
-% \cls{beamer} are automatically detected in the environments |{Piton}|
-% (without any escaping mechanism) : |\action|,
-% |\alert|, |\invisible|, |\only|, |\uncover| and |\visible|.\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}|}
-%
+% 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}| :
+% \begin{itemize}
+% \item no mandatory argument : |\pause| ;
+% \item one mandatory argument : |\action|, |\alert|, |\invisible|, |\only|, |\uncover| and |\visible| ;
+% \item two mandatory arguments : |\alt| ; 
+% \item three mandatory arguments  : |\temporal|.
+% \end{itemize}
+
 % \medskip
-% However, there must be \textbf{no end-of-line} in the arguments of those commands.
+% However, there is two restrictions for the content of the mandatory arguments
+% of these commands.
+% \begin{itemize}
+% \item In the mandatory arguments of these commands, the braces must be
+% balanced. However, the braces includes in short strings\footnote{The
+% short strings of Python are the strings delimited by characters \texttt{'} or
+% the characters \texttt{"} and not \texttt{'''} nor \texttt{"""}. In Python,
+% the short strings can't extend on several lines.} of Python are not considered.
+% \item The must be \textbf{no carriage return} in the mandatory arguments of the
+% command (if there is, a fatal error will be raised).
+% \end{itemize}
 % 
 % \medskip
-% Remark that, since the environment |{Piton}| takes in its body with a verbatim
+% Remark that, since the environment |{Piton}| catches its body with a verbatim
 % mode, it's necessary to use the environments |{Piton}| within environments
-% |{frame}| protected by the key |fragile|.
+% |{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:
 %
-% \begin{Verbatim}
+% \begin{Verbatim}[formatcom = \small\color{gray}]
 % \documentclass{beamer}
-% \usepackage{xcolor}
 % \usepackage{piton}
+% \begin{document}
+% \begin{frame}[fragile]
+% \begin{Piton}
+% def string_of_list(l):
+%     """Convert a list of numbers in string"""
+% ~emphase#    \only<2->{s = "{" + str(l[0])}@
+% ~emphase#    \only<3->{for x in l[1:]: s = s + "," + str(x)}@
+% ~emphase#    \only<4->{s = s + "}"}@
+%     return s
+% \end{Piton}
+% \end{frame}
+% \end{document}
+% \end{Verbatim}
 %
+% In the previous example, the braces in the Python strings |"{"| and |"}"| are
+% correctly interpreted (without any escape character).
+% 
+% \bigskip
+% \colorbox{yellow!50}{\textbf{New 1.2}}
+%
+% 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}|.
+%
+% However, there is a restriction: these environments must contain only \emph{whole
+% lines of Python code} in their body.
+%%
+%\medskip
+% Here is an example:
+%
+% \begin{Verbatim}[formatcom = \small\color{gray}]
+% \documentclass{beamer}
+% \usepackage{piton}
 % \begin{document}
-%
 % \begin{frame}[fragile]
 % \begin{Piton}
 % def square(x):
-% ~emphase#\only<2>{    return x*x}@
+%     """Compure the square of its argument"""
+%     ~emphase#\begin{uncoverenv}<2>@
+%     return x*x
+%     ~emphase#\end{uncoverenv}@
 % \end{Piton}
 % \end{frame}
-%
 % \end{document}
 % \end{Verbatim}
 %
@@ -698,27 +778,39 @@
 % \end{itemize}
 %
 % \medskip
-% Even with a background color (set by |background-color|), the pages breaks are
-% allowed, as soon as the key |splittable| is in force.\footnote{With the key
-% |splittable|, the environments \texttt{\{Piton\}} are breakable, even within a
-% (breakable) environment of \pkg{tcolorbox}. Remind that an environment of
-% \pkg{tcolorbox} included in another environment of \pkg{tcolorbox} is
-% \emph{not} breakable, even when both environments use the key |breakable| of
-% \pkg{tcolorbox}.}
+% Even with a background color (set by the key |background-color|), the pages
+% breaks are allowed, as soon as the key |splittable| is in force.\footnote{With
+% the key |splittable|, the environments \texttt{\{Piton\}} are breakable, even
+% within a (breakable) environment of \pkg{tcolorbox}. Remind that an
+% environment of \pkg{tcolorbox} included in another environment of
+% \pkg{tcolorbox} is \emph{not} breakable, even when both environments use the
+% key |breakable| of \pkg{tcolorbox}.}
 % 
 % \subsubsection{Line breaks}
 % 
-% By default, the lines of the listings produced by |{Piton}| and
-% |\PitonInputFile| are not breakable.
+% By default, the elements produced by \pkg{piton} can't be broken by an end on
+% line. However, there are keys to allow such breaks (the possible breaking
+% points are the spaces, even the spaces in the Python strings).
+% \begin{itemize}
+% \item With the key |break-lines-in-piton|, the line breaks are allowed in the
+% command |\piton{...}| (but not in the command \verb+\piton|...|+, that is to say
+% the command |\piton| in verbatim mode). 
+% \item With the key |break-lines-in-Piton|, the line breaks are allowed in the
+% environment |{Piton}| (hence the capital letter |P| in the name) and in the
+% listings produced by |\PitonInputFile|.
+% \item The key |break-lines| is a conjonction of the two previous keys.
+% \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}|. 
+
+% \bigskip 
+% The package \pkg{piton} provides also several keys to control the appearance
+% on the line breaks allowed by |break-lines-in-Piton|.
 %
-% \smallskip
-% There exist several keys (available in |\PitonOptions|) to allow and control
-% such line breaks.
-%
 % \begin{itemize}
-% \item The key |break-lines| actives the lines breaks. Only the spaces (even in
-% the strings) are allowed break points.
-% 
 % \item With the key |indent-broken-lines|, the indentation of a broken line is
 % respected at carriage return.
 %
@@ -1628,12 +1720,18 @@
 %    \begin{macrocode}
 \int_new:N \g_@@_env_int 
 %    \end{macrocode}
-% 
+%
 % \medskip
+% The following boolean corresponds to the key |show-spaces|.
+%    \begin{macrocode}
+\bool_new:N \l_@@_show_spaces_bool
+%    \end{macrocode}
+%
+% \medskip
 % The following booleans correspond to the keys |break-lines| and
 % |indent-broken-lines|.
 %    \begin{macrocode}
-\bool_new:N \l_@@_break_lines_bool
+\bool_new:N \l_@@_break_lines_in_Piton_bool
 \bool_new:N \l_@@_indent_broken_lines_bool
 %    \end{macrocode}
 %
@@ -1658,6 +1756,12 @@
 \tl_new:N \l_@@_end_of_broken_line_tl 
 \tl_set:Nn \l_@@_end_of_broken_line_tl { \hspace*{0.5em} \textbackslash }
 %    \end{macrocode}
+%
+% \medskip
+% The following boolean corresponds to the key |break-lines-in-piton|.
+%    \begin{macrocode}
+\bool_new:N \l_@@_break_lines_in_piton_bool
+%    \end{macrocode}
 % 
 % \medskip
 % The following boolean corresponds to the key |slim| of |\PitonOptions|.
@@ -1720,10 +1824,49 @@
 \cs_new_protected:Npn \@@_an_indentation_space:
   { \int_gincr:N \g_@@_indentation_int }
 %    \end{macrocode}
+%
+% \medskip
+% The following command |\@@_beamer_command:n| executes the argument
+% corresponding to its argument but also stores it in |\l_@@_beamer_command_str|.
+% That string is used only in the error message ``|cr~not~allowed|'' raised when
+% there is a carriage return in the mandatory argument of that command.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_beamer_command:n #1 
+  { 
+    \str_set:Nn \l_@@_beamer_command_str { #1 } 
+    \use:c { #1 } 
+  }
+%    \end{macrocode}
 % 
 % \bigskip
 % \subsubsection{Treatment of a line of code}
 % 
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_replace_spaces:n #1 
+  {
+    \tl_set:Nn \l_tmpa_tl { #1 } 
+    \bool_if:NTF \l_@@_show_spaces_bool
+      { \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
+      {
+%    \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,
+% 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.
+%    \begin{macrocode}
+        \bool_if:NT \l_@@_break_lines_in_Piton_bool
+          { 
+            \regex_replace_all:nnN 
+              { \x20 } 
+              { \c { @@_breakable_space: } }
+              \l_tmpa_tl 
+          } 
+      }
+    \l_tmpa_tl 
+  }
+\cs_generate_variant:Nn \@@_replace_spaces:n { x } 
+%    \end{macrocode}
 % 
 % \bigskip
 % In the contents provided by Lua, each line of the Python code will be
@@ -1755,21 +1898,8 @@
         \language = -1
         \raggedright 
         \strut 
-        \tl_set:Nn \l_tmpa_tl { #1 } 
-%    \end{macrocode}
-% If the key |break-lines| is in force, we replace all the characters U+0032
-% (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.
-%    \begin{macrocode}
-        \bool_if:NT \l_@@_break_lines_bool
-          { 
-            \regex_replace_all:nnN 
-              { \x20 } 
-              { \c { @@_breakable_space: } }
-              \l_tmpa_tl 
-          } 
-        \l_tmpa_tl \strut \hfil 
+        \@@_replace_spaces:n { #1 }
+        \strut \hfil 
       } 
     \hbox_set:Nn \l_tmpa_box 
       { 
@@ -1919,10 +2049,16 @@
     left-margin      .value_required:n  = true ,
     tab-size         .code:n            = \@@_set_tab_tl:n { #1 } ,
     tab-size         .value_required:n  = true , 
-    show-spaces      .code:n            = \tl_set:Nn \l_@@_space_tl { ␣ } , % U+2423
-    show-spaces      .value_forbidden:n = true ,
-    break-lines      .bool_set:N        = \l_@@_break_lines_bool ,
-    break-lines      .default:n         = true ,
+    show-spaces      .bool_set:N        = \l_@@_show_spaces_bool , 
+    show-spaces      .default:n         = true , 
+    show-spaces-in-strings .code:n      = \tl_set:Nn \l_@@_space_tl { ␣ } , % U+2423
+    show-spaces-in-strings .value_forbidden:n = true ,
+    break-lines-in-Piton .bool_set:N    = \l_@@_break_lines_in_Piton_bool ,
+    break-lines-in-Piton .default:n     = true ,
+    break-lines-in-piton .bool_set:N    = \l_@@_break_lines_in_piton_bool ,
+    break-lines-in-piton .default:n     = true ,
+    break-lines .meta:n = { break-lines-in-piton , break-lines-in-Piton } , 
+    break-lines .value_forbidden:n      = true ,
     indent-broken-lines .bool_set:N     = \l_@@_indent_broken_lines_bool ,
     indent-broken-lines .default:n      = true ,
     end-of-broken-line  .tl_set:N       = \l_@@_end_of_broken_line_tl ,
@@ -1951,6 +2087,8 @@
     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,~
@@ -1961,6 +2099,7 @@
     line-numbers,~
     resume,~
     show-spaces,~
+    show-spaces-in-strings,~
     slim,~
     splittable,~
     tabs-auto-gobble,~
@@ -2058,7 +2197,19 @@
     \cs_set_eq:NN \$ \c_dollar_str
     \cs_set_protected:Npn \@@_begin_line: { }
     \cs_set_protected:Npn \@@_end_line: { }
-    \lua_now:n { piton.pitonParse(token.scan_string()) } { #1 }
+    \tl_set:Nx \l_tmpa_tl 
+      { \lua_now:n { piton.pitonParse(token.scan_string()) } { #1 } }
+    \bool_if:NTF \l_@@_show_spaces_bool
+      { \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
+%    \end{macrocode}
+% The following code replaces the characters U+0020 (spaces) by characters
+% U+0020 of catcode~10: thus, they become breakable by an end of line.
+%    \begin{macrocode}
+      {
+        \bool_if:NT \l_@@_break_lines_in_piton_bool
+          { \regex_replace_all:nnN { \x20 } { \x20 } \l_tmpa_tl }
+      }
+    \l_tmpa_tl 
     \group_end:
   }
 %    \end{macrocode}
@@ -2068,10 +2219,14 @@
 \NewDocumentCommand { \@@_piton_verbatim } { v }
   {
     \group_begin:
-      \ttfamily
-      \cs_set_protected:Npn \@@_begin_line: { }
-      \cs_set_protected:Npn \@@_end_line: { }
-      \lua_now:n { piton.Parse(token.scan_string()) } { #1 }
+    \ttfamily
+    \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_if:NT \l_@@_show_spaces_bool
+      { \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
+    \l_tmpa_tl 
     \group_end:
   }
 %    \end{macrocode}
@@ -2078,7 +2233,7 @@
 %
 %  \bigskip
 % The following command is not a user command. It will be used when you will
-% have to ``rescan'' some chunks of Python code. For example, if will be the
+% 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).
 %    \begin{macrocode}
@@ -2087,10 +2242,34 @@
     \group_begin:
     \cs_set_protected:Npn \@@_begin_line: { }
     \cs_set_protected:Npn \@@_end_line: { }
-    \lua_now:n { piton.Parse(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 
     \group_end:
   }
 %    \end{macrocode}
+%
+% \bigskip
+% The following command is similar to the previous one but raise a fatal error if
+% its argument contains a carriage return.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_piton_no_cr:n #1
+  { 
+    \group_begin:
+    \cs_set_protected:Npn \@@_begin_line: { }
+    \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_if:NT \l_@@_show_spaces_bool
+      { \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
+    \l_tmpa_tl 
+    \group_end:
+  }
+%    \end{macrocode}
 % 
 % \bigskip
 % Despite its name, |\@@_pre_env:| will be used both in |\PitonInputFile| dans
@@ -2139,7 +2318,7 @@
 % or disallow page breaks.
 %    \begin{macrocode}
       \lua_now:n { piton.CountLinesFile(token.scan_argument()) } { #2 }  
-%    \end{document}     
+%    \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
 % lines at the end of the composition of the listing to fix the correct value to
@@ -2261,8 +2440,8 @@
             \bool_if:NT \c_@@_footnote_bool { \end { savenotes } } 
             \@@_width_to_aux:
 %    \end{macrocode}
-% The following |\end{#1}| is only for the groups and the stack of
-% environments of LaTeX.
+% The following |\end{#1}| is only for the groups and the stack of environments
+% of LaTeX.
 %    \begin{macrocode}
             \end { #1 }
             \@@_write_aux:
@@ -2306,6 +2485,8 @@
 \NewPitonEnvironment { Piton } { } { } { }
 %    \end{macrocode}
 %
+%
+%
 % \bigskip
 % \subsubsection{The styles}
 % 
@@ -2448,12 +2629,12 @@
     InitialValues    = \@@_piton:n ,
     Dict.Value       = \@@_piton:n ,
     Interpol.Inside  = \color{black}\@@_piton:n ,
-    Beamer           = \@@_piton:n , 
+    Beamer           = \@@_piton_no_cr:n , 
     Post.Function    = \@@_piton:n ,
   }
 %    \end{macrocode}
-% The last style |Post.Function| should be considered as an ``internal style''
-% (not available for the final user).
+% The last styles |Beamer| and |Post.Function| should be considered as 
+% ``internal style'' (not available for the final user).
 %
 % \medskip
 % If the key |math-comments| has been used at load-time, we change the style
@@ -2481,7 +2662,21 @@
   }
 %    \end{macrocode}
 % 
+% \bigskip
+% \subsubsection{The errors messages of the package}
 %
+%    \begin{macrocode}
+\msg_new:nnn { piton } { cr~not~allowed }
+  {
+    You~can't~put~any~carriage~return~in~the~argument~
+    of~a~command~\c_backslash_str
+    \l_@@_beamer_command_str\ within~an~
+    environment~of~'piton'.~You~should~consider~using~the~
+    corresponding~environment.\\
+    That~error~is~fatal.
+  }
+%    \end{macrocode}
+% 
 % \bigskip
 % \subsection{The Lua part of the implementation}
 %
@@ -2615,10 +2810,17 @@
 % \bigskip
 % \subsubsection{The LPEG SyntaxPython}
 %
+% 
+% \bigskip
+% 
+%
+% \bigskip
+% \paragraph{The basic syntactic LPEG}
+%
 %    \begin{macrocode}
 local alpha, digit, space = lpeg.alpha, lpeg.digit, lpeg.space
 %    \end{macrocode}
-% 
+%
 % Remember that, for \textsc{lpeg}, the Unicode characters such as |à|, |â|,
 % |ç|, etc. are in fact strings of length 2 (2 bytes) because \pkg{lpeg} is not
 % Unicode-aware. 
@@ -2703,27 +2905,7 @@
    Lc ( '\\@@_an_indentation_space:' ) * K " " 
 %    \end{macrocode}
 %
-% \bigskip
-% The following \textsc{lpeg} |EOL| is for the end of lines.
-%    \begin{macrocode}
-local EOL = 
-  P "\r" 
-  *
-  (
-    ( space^0 * -1 )
-    + 
-%    \end{macrocode}
-% We recall that each line in the Python code we have to parse will be sent
-% back to LaTeX between a pair |\@@_begin_line:| --
-% |\@@_end_line:|\footnote{Remember that the \texttt{\textbackslash
-% @@\_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:' )
-  ) 
-  *
-  SpaceIndentation ^ 0
-%    \end{macrocode}
+
 %
 % \bigskip
 %    \begin{macrocode}
@@ -2793,7 +2975,6 @@
 
 local RaiseException = K ( P "raise" , 'Keyword' ) * SkipSpace * Exception * K ( P "(" ) 
 
-local ExceptionInConsole = Exception *  K ( ( 1 - P "\r" ) ^ 0 ) * EOL  
 %    \end{macrocode}
 %
 % \bigskip
@@ -2935,7 +3116,7 @@
 % The following \textsc{lpeg} catches a space (U+0032) 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| is in force, |\\l_@@_space_tl| will
+% 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" 
@@ -3023,11 +3204,169 @@
      )
    * Lc ( "}}" ) 
 
-
 local ShortString = SingleShortString + DoubleShortString
 %    \end{macrocode}
+%
+% \bigskip
+% \paragraph{Beamer}
+%
+% The following \textsc{lpeg} |BalancedBraces| will be used for the (mandatory)
+% argument of the commands |\only| and \emph{al.} of Beamer. It's necessary to
+% use a \emph{grammar} because that pattern mainly checks the correct nesting of
+% the delimiters (and it's known in the theory of formal languages that this
+% can't be done with regular expressions \emph{stricto sensu} only).
+%    \begin{macrocode}
+local BalancedBraces =
+  P { "E" ,
+       E = ( ShortString + ( 1 - S "{}" ) ) ^ 0
+           *  
+           ( 
+              P "{" * V "E" * P "}" 
+              * ( ShortString + ( 1 - S "{}" ) ) ^ 0 
+           ) ^ 0 
+    }
+%    \end{macrocode}
+%
+% \bigskip 
+% If Beamer is used (or if the key |beamer| is used at load-time), the following
+% LPEG will be redefined.
+%    \begin{macrocode}
+local Beamer = P ( false ) 
+local BeamerBeginEnvironments = P ( true ) 
+local BeamerEndEnvironments = P ( true ) 
+local BeamerNamesEnvironments =
+  P "uncoverenv" + P "onlyenv" + P "visibleenv" + P "invisibleenv" 
+
+%    \end{macrocode}
 % 
 % \bigskip
+%    \begin{macrocode}
+if piton_beamer 
+then
+  Beamer =
+      L  ( P "\\pause" * ( P "[" * (1 - P "]") ^ 0 * P "]" ) ^ -1 ) 
+    + 
+%    \end{macrocode}
+% We recall that the command |\@@_beamer_command:n| executes the argument
+% corresponding to its argument but also stores it in |\l_@@_beamer_command_str|.
+% That string is used only in the error message ``|cr~not~allowed|'' raised when
+% there is a carriage return in the mandatory argument of that command.
+%    \begin{macrocode}
+      (   P "\\uncover"   * Lc ( '\\@@_beamer_command:n{uncover}' ) 
+        + P "\\only"      * Lc ( '\\@@_beamer_command:n{only}' ) 
+        + P "\\alert"     * Lc ( '\\@@_beamer_command:n{alert}' ) 
+        + P "\\visible"   * Lc ( '\\@@_beamer_command:n{visible}' ) 
+        + P "\\invisible" * Lc ( '\\@@_beamer_command:n{invisible}' ) 
+        + P "\\action"    * Lc ( '\\@@_beamer_command:n{action}' ) 
+      ) 
+      *
+      L ( ( P "<" * (1 - P ">") ^ 0 * P ">" ) ^ -1 * P "{" )
+      * K ( BalancedBraces , 'Beamer' ) 
+      * L ( P "}" )
+    +  
+      L ( 
+%    \end{macrocode}
+% For |\\alt|, the specification of the overlays (between angular brackets) is mandatory.
+%    \begin{macrocode}
+          ( P "\\alt" )
+          * P "<" * (1 - P ">") ^ 0 * P ">" 
+          * P "{" 
+        )
+      * K ( BalancedBraces , 'Beamer' ) 
+      * L ( P "}{" )
+      * K ( BalancedBraces , 'Beamer' ) 
+      * L ( P "}" )
+    +  
+      L ( 
+%    \end{macrocode}
+% For |\\alt|, the specification of the overlays (between angular brackets) is mandatory.
+%    \begin{macrocode}
+          ( P "\\temporal" )
+          * P "<" * (1 - P ">") ^ 0 * P ">" 
+          * P "{" 
+        )
+      * K ( BalancedBraces , 'Beamer' ) 
+      * L ( P "}{" )
+      * K ( BalancedBraces , 'Beamer' ) 
+      * L ( P "}{" )
+      * K ( BalancedBraces , 'Beamer' ) 
+      * L ( P "}" )
+%    \end{macrocode}
+% Now for the environemnts.
+%    \begin{macrocode}
+  BeamerBeginEnvironments = 
+      ( space ^ 0 * 
+        L 
+          ( 
+            P "\\begin{" * BeamerNamesEnvironments * "}"
+            * ( P "<" * ( 1 - P ">") ^ 0 * P ">" ) ^ -1
+          )
+        * P "\r" 
+      ) ^ 0 
+  BeamerEndEnvironments = 
+      ( space ^ 0 * 
+        L ( P "\\end{" * BeamerNamesEnvironments * P "}" ) 
+        * P "\r" 
+      ) ^ 0 
+end
+%    \end{macrocode}
+%
+% \bigskip
+% \paragraph{EOL}
+%
+% \bigskip
+% The following \textsc{lpeg} |EOL| is for the end of lines.
+%    \begin{macrocode}
+local EOL
+if piton_beamer 
+then
+EOL = 
+  P "\r" 
+  *
+  (
+    ( space^0 * -1 )
+    + 
+%    \end{macrocode}
+% We recall that each line in the Python code we have to parse will be sent
+% back to LaTeX between a pair |\@@_begin_line:| --
+% |\@@_end_line:|\footnote{Remember that the \texttt{\textbackslash
+% @@\_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:' ) 
+    * BeamerEndEnvironments 
+    * BeamerBeginEnvironments 
+    * Lc ( '\\@@_newline: \\@@_begin_line:' )
+  ) 
+  *
+  SpaceIndentation ^ 0
+else
+EOL = 
+  P "\r" 
+  *
+  (
+    ( space^0 * -1 )
+    + 
+%    \end{macrocode}
+% We recall that each line in the Python code we have to parse will be sent
+% back to LaTeX between a pair |\@@_begin_line:| --
+% |\@@_end_line:|\footnote{Remember that the \texttt{\textbackslash
+% @@\_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:' )
+  ) 
+  *
+  SpaceIndentation ^ 0
+end 
+%    \end{macrocode}
+%
+% 
+% \bigskip
+% \paragraph{The long strings}
+% 
+% 
+% \bigskip
 % Of course, it's more complicated for ``longs strings'' because, by definition,
 % in Python, those strings may be broken by an end on line (which is catched by
 % the \textsc{lpeg} |EOL|).
@@ -3274,47 +3613,61 @@
   * K ( P "}" )
 %    \end{macrocode}
 %
+%
 % \bigskip
-% \paragraph{Commands of Beamer}
+% \paragraph{Miscellaneous}
+% 
+%    \begin{macrocode}
+local ExceptionInConsole = Exception *  K ( ( 1 - P "\r" ) ^ 0 ) * EOL  
+%    \end{macrocode}
+% 
+% \bigskip
+% \paragraph{The user commands and environments}
 %
-%
 %    \begin{macrocode}
-local Beamer = P ( "blablabla" ) 
-
-if piton_beamer then
-  Beamer =
-      L ( 
-          ( P "\\uncover" + P "\\only" + P "\\alert" + P "\\visible" 
-            + P "\\invisible" + P "\\action" 
-          ) 
-          * P "<" 
-          * (1 - P ">") ^ 0 
-          * P ">{" 
-        )
-      * K ( Expression , 'Beamer' ) 
-      * L ( P "}" )
-    +  
-      L ( 
-          ( P "\\alt" )
-          * P "<" 
-          * (1 - P ">") ^ 0 
-          * P ">{" 
-        )
-      * K ( Expression , 'Beamer' ) 
-      * L ( P "}{" )
-      * K ( Expression , 'Beamer' ) 
-      * L ( P "}" )
-end
+UserEnvironments = P ( true ) 
 %    \end{macrocode}
 % 
 % \bigskip
 % \paragraph{The main LPEG}
 %
-% |SyntaxPython| is the main \textsc{lpeg} of the package \pkg{piton}. We have
-% written an auxiliary \textsc{lpeg} |SyntaxPythonAux| only for legibility.
+% First, the main loop :
 %    \begin{macrocode}
-local SyntaxPythonAux =
+MainLoop = 
+  (  ( space^1 * -1 ) 
+     + EOL
+     + Tab
+     + Space
+     + Escape 
+     + CommentLaTeX
+     + Beamer 
+     + LongString 
+     + Comment
+     + ExceptionInConsole
+     + Set 
+     + Delim
 %    \end{macrocode}
+% |Operator| must be before |Punct|.
+%    \begin{macrocode}
+     + Operator
+     + ShortString
+     + Punct
+     + FromImport
+     + ImportAs
+     + RaiseException 
+     + DefFunction
+     + DefClass 
+     + Keyword * ( Space + Punct + Delim + EOL + -1) 
+     + Decorator
+     + OperatorWord * ( Space + Punct + Delim + EOL + -1) 
+     + Builtin * ( Space + Punct + Delim + EOL + -1) 
+     + Identifier 
+     + Number
+     + Word
+  ) ^ 0 
+%    \end{macrocode}
+%
+% \bigskip
 % We recall that each line in the Python code to parse will be sent back to
 % LaTeX between a pair |\@@_begin_line:| -- |\@@_end_line:|\footnote{Remember
 % that the \texttt{\textbackslash @@\_end\_line:} must be explicit because it
@@ -3321,46 +3674,25 @@
 % will be used as marker in order to delimit the argument of the command
 % \texttt{\textbackslash @@\_begin\_line:}}.
 %    \begin{macrocode}
-      Lc ( '\\@@_begin_line:' ) *
-      ( ( space - P "\r" ) ^0 * P "\r" ) ^ -1 * 
-      SpaceIndentation ^ 0 *
-      (  ( space^1 * -1 ) 
-         + EOL
-         + Tab
-         + Space
-         + Escape 
-         + CommentLaTeX
-         + Beamer 
-         + LongString 
-         + Comment
-         + ExceptionInConsole
-         + Set 
-         + Delim
+local SyntaxPython = P ( true ) 
+
+function piton.defSyntaxPython()
+  SyntaxPython =
+    Ct (
+         ( ( space - P "\r" ) ^0 * P "\r" ) ^ -1 
+         * BeamerBeginEnvironments 
+         * UserEnvironments 
+         * Lc ( '\\@@_begin_line:' ) 
+         * SpaceIndentation ^ 0 
+         * MainLoop
+         * -1 
+         * Lc ( '\\@@_end_line:' )
+       )
+end
+
+piton.defSyntaxPython()
 %    \end{macrocode}
-% |Operator| must be before |Punct|.
-%    \begin{macrocode}
-         + Operator
-         + ShortString
-         + Punct
-         + FromImport
-         + ImportAs
-         + RaiseException 
-         + DefFunction
-         + DefClass 
-         + Keyword * ( Space + Punct + Delim + EOL + -1) 
-         + Decorator
-         + OperatorWord * ( Space + Punct + Delim + EOL + -1) 
-         + Builtin * ( Space + Punct + Delim + EOL + -1) 
-         + Identifier 
-         + Number
-         + Word
-      ) ^0 * -1 * Lc ( '\\@@_end_line:' )
-%    \end{macrocode}
 %
-% We have written an auxiliary \textsc{lpeg} |SyntaxPythonAux| for legibility only.
-%    \begin{macrocode}
-local SyntaxPython = Ct ( SyntaxPythonAux ) 
-%    \end{macrocode}
 % 
 % \bigskip
 % \subsubsection{The function Parse}
@@ -3381,7 +3713,7 @@
 %
 % 
 % \bigskip
-% The following command will be used by the user commands |\piton|.
+% 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)
@@ -3594,10 +3926,21 @@
 \end{luacode*}
 %    \end{macrocode}
 %
+% 
 % \vspace{1cm}
 % \section{History}
-% \subsection*{Changes between versions 0.99 and 1.0}
+% \subsection*{Changes between versions 1.1 and 1.2}
 %
+% New keys |break-lines-in-piton| and |break-lines-in-Piton|.
+%
+% New key |show-spaces-in-string| and modification of the key |show-spaces|.
+%
+% When the class \cls{beamer} is used, the environements |{uncoverenv}|,
+% |{onlyenv}|, |{visibleenv}| and |{invisibleenv}|
+%
+%
+% \subsection*{Changes between versions 1.0 and 1.1}
+%
 % The extension \pkg{piton} detects the class \cls{beamer} and activates the
 % commands |\action|, |\alert|, |\invisible|, |\only|, |\uncover| and |\visible|
 % in the environments |{Piton}| when the class \cls{beamer} is used.

Modified: trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty	2023-01-16 21:10:00 UTC (rev 65556)
+++ trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty	2023-01-16 21:10:15 UTC (rev 65557)
@@ -18,11 +18,15 @@
 %% and version 1.3 or later is part of all distributions of
 %% LaTeX version 2005/12/01 or later.
 %% 
-\def\myfileversion{1.1}
-\def\myfiledate{2023/01/07}
+\def\myfileversion{1.2}
+\def\myfiledate{2023/01/16}
 
 
+\bigskip
 
+%%
+
+
 \NeedsTeXFormat{LaTeX2e}
 \RequirePackage{l3keys2e}
 \ProvidesExplPackage
@@ -136,7 +140,8 @@
 \dim_new:N \g__piton_width_dim
 \dim_new:N \l__piton_width_on_aux_dim
 \int_new:N \g__piton_env_int
-\bool_new:N \l__piton_break_lines_bool
+\bool_new:N \l__piton_show_spaces_bool
+\bool_new:N \l__piton_break_lines_in_Piton_bool
 \bool_new:N \l__piton_indent_broken_lines_bool
 \tl_new:N \l__piton_continuation_symbol_tl
 \tl_set:Nn \l__piton_continuation_symbol_tl { + }
@@ -144,6 +149,7 @@
 \tl_set:Nn \l__piton_csoi_tl { $ \hookrightarrow \; $  }
 \tl_new:N \l__piton_end_of_broken_line_tl
 \tl_set:Nn \l__piton_end_of_broken_line_tl { \hspace*{0.5em} \textbackslash }
+\bool_new:N \l__piton_break_lines_in_piton_bool
 \bool_new:N \l__piton_slim_bool
 \dim_new:N \l__piton_left_margin_dim
 \bool_new:N \l__piton_left_margin_auto_bool
@@ -161,6 +167,28 @@
 \int_new:N \g__piton_indentation_int
 \cs_new_protected:Npn \__piton_an_indentation_space:
   { \int_gincr:N \g__piton_indentation_int }
+\cs_new_protected:Npn \__piton_beamer_command:n #1
+  {
+    \str_set:Nn \l__piton_beamer_command_str { #1 }
+    \use:c { #1 }
+  }
+\cs_new_protected:Npn \__piton_replace_spaces:n #1
+  {
+    \tl_set:Nn \l_tmpa_tl { #1 }
+    \bool_if:NTF \l__piton_show_spaces_bool
+      { \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
+      {
+        \bool_if:NT \l__piton_break_lines_in_Piton_bool
+          {
+            \regex_replace_all:nnN
+              { \x20 }
+              { \c { __piton_breakable_space: } }
+              \l_tmpa_tl
+          }
+      }
+    \l_tmpa_tl
+  }
+\cs_generate_variant:Nn \__piton_replace_spaces:n { x }
 \cs_set_protected:Npn \__piton_begin_line: #1 \__piton_end_line:
   {
     \int_gzero:N \g__piton_indentation_int
@@ -181,15 +209,8 @@
         \language = -1
         \raggedright
         \strut
-        \tl_set:Nn \l_tmpa_tl { #1 }
-        \bool_if:NT \l__piton_break_lines_bool
-          {
-            \regex_replace_all:nnN
-              { \x20 }
-              { \c { __piton_breakable_space: } }
-              \l_tmpa_tl
-          }
-        \l_tmpa_tl \strut \hfil
+        \__piton_replace_spaces:n { #1 }
+        \strut \hfil
       }
     \hbox_set:Nn \l_tmpa_box
       {
@@ -306,10 +327,16 @@
     left-margin      .value_required:n  = true ,
     tab-size         .code:n            = \__piton_set_tab_tl:n { #1 } ,
     tab-size         .value_required:n  = true ,
-    show-spaces      .code:n            = \tl_set:Nn \l__piton_space_tl { ␣ } , % U+2423
-    show-spaces      .value_forbidden:n = true ,
-    break-lines      .bool_set:N        = \l__piton_break_lines_bool ,
-    break-lines      .default:n         = true ,
+    show-spaces      .bool_set:N        = \l__piton_show_spaces_bool ,
+    show-spaces      .default:n         = true ,
+    show-spaces-in-strings .code:n      = \tl_set:Nn \l__piton_space_tl { ␣ } , % U+2423
+    show-spaces-in-strings .value_forbidden:n = true ,
+    break-lines-in-Piton .bool_set:N    = \l__piton_break_lines_in_Piton_bool ,
+    break-lines-in-Piton .default:n     = true ,
+    break-lines-in-piton .bool_set:N    = \l__piton_break_lines_in_piton_bool ,
+    break-lines-in-piton .default:n     = true ,
+    break-lines .meta:n = { break-lines-in-piton , break-lines-in-Piton } ,
+    break-lines .value_forbidden:n      = true ,
     indent-broken-lines .bool_set:N     = \l__piton_indent_broken_lines_bool ,
     indent-broken-lines .default:n      = true ,
     end-of-broken-line  .tl_set:N       = \l__piton_end_of_broken_line_tl ,
@@ -333,6 +360,8 @@
     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,~
@@ -343,6 +372,7 @@
     line-numbers,~
     resume,~
     show-spaces,~
+    show-spaces-in-strings,~
     slim,~
     splittable,~
     tabs-auto-gobble,~
@@ -400,16 +430,28 @@
     \cs_set_eq:NN \$ \c_dollar_str
     \cs_set_protected:Npn \__piton_begin_line: { }
     \cs_set_protected:Npn \__piton_end_line: { }
-    \lua_now:n { piton.pitonParse(token.scan_string()) } { #1 }
+    \tl_set:Nx \l_tmpa_tl
+      { \lua_now:n { piton.pitonParse(token.scan_string()) } { #1 } }
+    \bool_if:NTF \l__piton_show_spaces_bool
+      { \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
+      {
+        \bool_if:NT \l__piton_break_lines_in_piton_bool
+          { \regex_replace_all:nnN { \x20 } { \x20 } \l_tmpa_tl }
+      }
+    \l_tmpa_tl
     \group_end:
   }
 \NewDocumentCommand { \__piton_piton_verbatim } { v }
   {
     \group_begin:
-      \ttfamily
-      \cs_set_protected:Npn \__piton_begin_line: { }
-      \cs_set_protected:Npn \__piton_end_line: { }
-      \lua_now:n { piton.Parse(token.scan_string()) } { #1 }
+    \ttfamily
+    \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_if:NT \l__piton_show_spaces_bool
+      { \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
+    \l_tmpa_tl
     \group_end:
   }
 \cs_new_protected:Npn \__piton_piton:n #1
@@ -417,9 +459,27 @@
     \group_begin:
     \cs_set_protected:Npn \__piton_begin_line: { }
     \cs_set_protected:Npn \__piton_end_line: { }
-    \lua_now:n { piton.Parse(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
     \group_end:
   }
+\cs_new_protected:Npn \__piton_piton_no_cr:n #1
+  {
+    \group_begin:
+    \cs_set_protected:Npn \__piton_begin_line: { }
+    \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_if:NT \l__piton_show_spaces_bool
+      { \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
+    \l_tmpa_tl
+    \group_end:
+  }
 \cs_new:Npn \__piton_pre_env:
   {
     \int_gincr:N \g__piton_env_int
@@ -663,7 +723,7 @@
     InitialValues    = \__piton_piton:n ,
     Dict.Value       = \__piton_piton:n ,
     Interpol.Inside  = \color{black}\__piton_piton:n ,
-    Beamer           = \__piton_piton:n ,
+    Beamer           = \__piton_piton_no_cr:n ,
     Post.Function    = \__piton_piton:n ,
   }
 \bool_if:NT \c__piton_math_comments_bool
@@ -678,6 +738,15 @@
     \token_to_str:N \piton\ but~there~is~no~environment~
     {piton}.~This~error~is~fatal.
   }
+\msg_new:nnn { piton } { cr~not~allowed }
+  {
+    You~can't~put~any~carriage~return~in~the~argument~
+    of~a~command~\c_backslash_str
+    \l__piton_beamer_command_str\ within~an~
+    environment~of~'piton'.~You~should~consider~using~the~
+    corresponding~environment.\\
+    That~error~is~fatal.
+  }
 \ExplSyntaxOff
 \RequirePackage{luacode}
 \begin{luacode*}
@@ -741,16 +810,7 @@
 local Tab = P "\t" * Lc ( '\\l__piton_tab_tl' )
 local SpaceIndentation =
    Lc ( '\\__piton_an_indentation_space:' ) * K " "
-local EOL =
-  P "\r"
-  *
-  (
-    ( space^0 * -1 )
-    +
-    Lc ( '\\__piton_end_line: \\__piton_newline: \\__piton_begin_line:' )
-  )
-  *
-  SpaceIndentation ^ 0
+
 local Delim = K ( S "[()]" )
 local Operator =
   K ( P "!=" + P "<>" + P "==" + P "<<" + P ">>" + P "<=" + P ">=" + P ":="
@@ -811,7 +871,6 @@
 
 local RaiseException = K ( P "raise" , 'Keyword' ) * SkipSpace * Exception * K ( P "(" )
 
-local ExceptionInConsole = Exception *  K ( ( 1 - P "\r" ) ^ 0 ) * EOL
 local Decorator = K ( P "@" * letter^1 , 'Name.Decorator' )
 local DefClass =
   K ( P "class" , 'Keyword' ) * Space * K ( identifier , 'Name.Class' )
@@ -912,6 +971,102 @@
    * Lc ( "}}" )
 
 local ShortString = SingleShortString + DoubleShortString
+local BalancedBraces =
+  P { "E" ,
+       E = ( ShortString + ( 1 - S "{}" ) ) ^ 0
+           *
+           (
+              P "{" * V "E" * P "}"
+              * ( ShortString + ( 1 - S "{}" ) ) ^ 0
+           ) ^ 0
+    }
+local Beamer = P ( false )
+local BeamerBeginEnvironments = P ( true )
+local BeamerEndEnvironments = P ( true )
+local BeamerNamesEnvironments =
+  P "uncoverenv" + P "onlyenv" + P "visibleenv" + P "invisibleenv"
+
+if piton_beamer
+then
+  Beamer =
+      L  ( P "\\pause" * ( P "[" * (1 - P "]") ^ 0 * P "]" ) ^ -1 )
+    +
+      (   P "\\uncover"   * Lc ( '\\__piton_beamer_command:n{uncover}' )
+        + P "\\only"      * Lc ( '\\__piton_beamer_command:n{only}' )
+        + P "\\alert"     * Lc ( '\\__piton_beamer_command:n{alert}' )
+        + P "\\visible"   * Lc ( '\\__piton_beamer_command:n{visible}' )
+        + P "\\invisible" * Lc ( '\\__piton_beamer_command:n{invisible}' )
+        + P "\\action"    * Lc ( '\\__piton_beamer_command:n{action}' )
+      )
+      *
+      L ( ( P "<" * (1 - P ">") ^ 0 * P ">" ) ^ -1 * P "{" )
+      * K ( BalancedBraces , 'Beamer' )
+      * L ( P "}" )
+    +
+      L (
+          ( P "\\alt" )
+          * P "<" * (1 - P ">") ^ 0 * P ">"
+          * P "{"
+        )
+      * K ( BalancedBraces , 'Beamer' )
+      * L ( P "}{" )
+      * K ( BalancedBraces , 'Beamer' )
+      * L ( P "}" )
+    +
+      L (
+          ( P "\\temporal" )
+          * P "<" * (1 - P ">") ^ 0 * P ">"
+          * P "{"
+        )
+      * K ( BalancedBraces , 'Beamer' )
+      * L ( P "}{" )
+      * K ( BalancedBraces , 'Beamer' )
+      * L ( P "}{" )
+      * K ( BalancedBraces , 'Beamer' )
+      * L ( P "}" )
+  BeamerBeginEnvironments =
+      ( space ^ 0 *
+        L
+          (
+            P "\\begin{" * BeamerNamesEnvironments * "}"
+            * ( P "<" * ( 1 - P ">") ^ 0 * P ">" ) ^ -1
+          )
+        * P "\r"
+      ) ^ 0
+  BeamerEndEnvironments =
+      ( space ^ 0 *
+        L ( P "\\end{" * BeamerNamesEnvironments * P "}" )
+        * P "\r"
+      ) ^ 0
+end
+local EOL
+if piton_beamer
+then
+EOL =
+  P "\r"
+  *
+  (
+    ( space^0 * -1 )
+    +
+    Lc ( '\\__piton_end_line:' )
+    * BeamerEndEnvironments
+    * BeamerBeginEnvironments
+    * Lc ( '\\__piton_newline: \\__piton_begin_line:' )
+  )
+  *
+  SpaceIndentation ^ 0
+else
+EOL =
+  P "\r"
+  *
+  (
+    ( space^0 * -1 )
+    +
+    Lc ( '\\__piton_end_line: \\__piton_newline: \\__piton_begin_line:' )
+  )
+  *
+  SpaceIndentation ^ 0
+end
 local SingleLongString =
   Lc "{\\PitonStyle{String.Long}{"
    * (
@@ -1044,65 +1199,54 @@
   K ( P "{" )
   * ItemOfSet * ( K ( P "," ) * ItemOfSet )  ^ 0
   * K ( P "}" )
-local Beamer = P ( "blablabla" )
+local ExceptionInConsole = Exception *  K ( ( 1 - P "\r" ) ^ 0 ) * EOL
+UserEnvironments = P ( true )
+MainLoop =
+  (  ( space^1 * -1 )
+     + EOL
+     + Tab
+     + Space
+     + Escape
+     + CommentLaTeX
+     + Beamer
+     + LongString
+     + Comment
+     + ExceptionInConsole
+     + Set
+     + Delim
+     + Operator
+     + ShortString
+     + Punct
+     + FromImport
+     + ImportAs
+     + RaiseException
+     + DefFunction
+     + DefClass
+     + Keyword * ( Space + Punct + Delim + EOL + -1)
+     + Decorator
+     + OperatorWord * ( Space + Punct + Delim + EOL + -1)
+     + Builtin * ( Space + Punct + Delim + EOL + -1)
+     + Identifier
+     + Number
+     + Word
+  ) ^ 0
+local SyntaxPython = P ( true )
 
-if piton_beamer then
-  Beamer =
-      L (
-          ( P "\\uncover" + P "\\only" + P "\\alert" + P "\\visible"
-            + P "\\invisible" + P "\\action"
-          )
-          * P "<"
-          * (1 - P ">") ^ 0
-          * P ">{"
-        )
-      * K ( Expression , 'Beamer' )
-      * L ( P "}" )
-    +
-      L (
-          ( P "\\alt" )
-          * P "<"
-          * (1 - P ">") ^ 0
-          * P ">{"
-        )
-      * K ( Expression , 'Beamer' )
-      * L ( P "}{" )
-      * K ( Expression , 'Beamer' )
-      * L ( P "}" )
+function piton.defSyntaxPython()
+  SyntaxPython =
+    Ct (
+         ( ( space - P "\r" ) ^0 * P "\r" ) ^ -1
+         * BeamerBeginEnvironments
+         * UserEnvironments
+         * Lc ( '\\__piton_begin_line:' )
+         * SpaceIndentation ^ 0
+         * MainLoop
+         * -1
+         * Lc ( '\\__piton_end_line:' )
+       )
 end
-local SyntaxPythonAux =
-      Lc ( '\\__piton_begin_line:' ) *
-      ( ( space - P "\r" ) ^0 * P "\r" ) ^ -1 *
-      SpaceIndentation ^ 0 *
-      (  ( space^1 * -1 )
-         + EOL
-         + Tab
-         + Space
-         + Escape
-         + CommentLaTeX
-         + Beamer
-         + LongString
-         + Comment
-         + ExceptionInConsole
-         + Set
-         + Delim
-         + Operator
-         + ShortString
-         + Punct
-         + FromImport
-         + ImportAs
-         + RaiseException
-         + DefFunction
-         + DefClass
-         + Keyword * ( Space + Punct + Delim + EOL + -1)
-         + Decorator
-         + OperatorWord * ( Space + Punct + Delim + EOL + -1)
-         + Builtin * ( Space + Punct + Delim + EOL + -1)
-         + Identifier
-         + Number
-         + Word
-      ) ^0 * -1 * Lc ( '\\__piton_end_line:' )
-local SyntaxPython = Ct ( SyntaxPythonAux )
+
+piton.defSyntaxPython()
 function piton.Parse(code)
   local t = SyntaxPython : match ( code ) -- match is a method of the LPEG
   for _ , s in ipairs(t) do tex.tprint(s) end



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