From 7d5553601ccc6f3feed4f9563a6270739bd4da54 Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Sun, 8 Jan 2023 03:01:28 +0000
Subject: CTAN sync 202301080301

---
 macros/luatex/latex/piton/piton.dtx | 143 ++++++++++++++++++++++++++++++------
 1 file changed, 119 insertions(+), 24 deletions(-)

(limited to 'macros/luatex/latex/piton/piton.dtx')

diff --git a/macros/luatex/latex/piton/piton.dtx b/macros/luatex/latex/piton/piton.dtx
index e67e091c8f..523aa38586 100644
--- a/macros/luatex/latex/piton/piton.dtx
+++ b/macros/luatex/latex/piton/piton.dtx
@@ -1,6 +1,6 @@
 % \iffalse -*- coding: utf-8 ; -*- \fi \iffalse meta-comment
 %
-% Copyright (C) 2022 by F. Pantigny
+% Copyright (C) 2023 by F. Pantigny
 % -----------------------------------
 %
 % This file may be distributed and/or modified under the
@@ -15,8 +15,8 @@
 %
 % \fi
 % \iffalse
-\def\myfileversion{1.0}
-\def\myfiledate{2022/12/29}
+\def\myfileversion{1.1}
+\def\myfiledate{2023/01/07}
 %
 %
 %<*batchfile> 
@@ -26,7 +26,7 @@
 \usedir{tex/latex/cascade}
 \preamble
 
-Copyright (C) 2022 by F. Pantigny
+Copyright (C) 2023 by F. Pantigny
 -----------------------------------
 
 This file may be distributed and/or modified under the
@@ -258,7 +258,7 @@ version 2005/12/01 or later.
 %
 % 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 an LaTeX environment is, in
+% the current TeX group.\footnote{We remind that a LaTeX environment is, in
 % particular, a TeX group.}
 %
 % \begin{itemize}
@@ -635,6 +635,47 @@ version 2005/12/01 or later.
 % this document). 
 % 
 %
+% \subsubsection{Behaviour in the class Beamer}
+%
+% \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}|}
+%
+% \medskip
+% However, there must be \textbf{no end-of-line} in the arguments of those commands.
+% 
+% \medskip
+% Remark that, since the environment |{Piton}| takes in its body with a verbatim
+% mode, it's necessary to use the environments |{Piton}| within environments
+% |{frame}| protected by the key |fragile|.
+%
+% \medskip
+% Here is a complete example of file:
+%
+% \begin{Verbatim}
+% \documentclass{beamer}
+% \usepackage{xcolor}
+% \usepackage{piton}
+%
+% \begin{document}
+%
+% \begin{frame}[fragile]
+% \begin{Piton}
+% def square(x):
+% ~emphase#\only<2>{    return x*x}@
+% \end{Piton}
+% \end{frame}
+%
+% \end{document}
+% \end{Verbatim}
+%
+%
 % \subsection{Page breaks and line breaks}
 %
 % \label{breakable}
@@ -671,8 +712,8 @@ version 2005/12/01 or later.
 % |\PitonInputFile| are not breakable.
 %
 % \smallskip
-% \colorbox{yellow!50}{\textbf{New 0.99}}\enskip There exist several keys
-% (available in |\PitonOptions|) to allow and control such line breaks.
+% 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
@@ -766,12 +807,12 @@ version 2005/12/01 or later.
 % change it with the key |tab-size| of |\PitonOptions|.
 %
 % \smallskip
-% \colorbox{yellow!50}{\textbf{New 1.0}}\enskip There exists also a key
-% |tabs-auto-gobble| which computes the minimal value $n$ of the number
-% of consecutive characters U+0009 beginning each (non empty) line of the
-% environment |{Piton}| and applies |gobble| with that value of~$n$ (before
-% replacement of the tabulations by spaces, of course). Hence, that key is
-% similar to the key |auto-gobble| but acts on U+0009 instead of U+0020 (spaces).
+% There exists also a key |tabs-auto-gobble| which computes the minimal value
+% $n$ of the number of consecutive characters U+0009 beginning each (non empty)
+% line of the environment |{Piton}| and applies |gobble| with that value of~$n$
+% (before replacement of the tabulations by spaces, of course). Hence, that key
+% is similar to the key |auto-gobble| but acts on U+0009 instead of U+0020
+% (spaces).
 %
 % \section{Examples}
 %
@@ -1369,6 +1410,12 @@ version 2005/12/01 or later.
 %    \begin{macrocode}
 \bool_new:N \c_@@_math_comments_bool
 %    \end{macrocode}
+%
+% \medskip
+% The following boolean corresponds to the key |beamer|. 
+%    \begin{macrocode}
+\bool_new:N \c_@@_beamer_bool
+%    \end{macrocode}
 % 
 % \bigskip
 % We define a set of keys for the options at load-time.
@@ -1382,7 +1429,9 @@ version 2005/12/01 or later.
     comment-latex .code:n = { \lua_now:n { comment_latex = "#1" } } ,   
     comment-latex .value_required:n = true ,
     math-comments .bool_set:N = \c_@@_math_comments_bool ,
-    math-comments .default:n  = true , 
+    math-comments .default:n  = true ,
+    beamer        .bool_set:N = \c_@@_beamer_bool ,
+    beamer        .default:n = true , 
     unknown .code:n = \msg_error:nn { piton } { unknown~key~for~package }
   }
 %    \end{macrocode}
@@ -1392,7 +1441,7 @@ version 2005/12/01 or later.
   {
     Unknown~key.\\
     You~have~used~the~key~'\l_keys_key_str'~but~the~only~keys~available~here~
-    are~'comment-latex',~'escape-inside',~'footnote',~'footnotehyper'~and~
+    are~'beamer',~'comment-latex',~'escape-inside',~'footnote',~'footnotehyper'~and~ 
     'math-comments'.~Other~keys~are~available~in~\token_to_str:N \PitonOptions.\\
     That~key~will~be~ignored.
   }
@@ -1419,6 +1468,11 @@ version 2005/12/01 or later.
 \endgroup
 %    \end{macrocode}
 % 
+% \bigskip
+%    \begin{macrocode}
+\@ifclassloaded { beamer } { \bool_set_true:N \c_@@_beamer_bool } { }
+\bool_if:NT \c_@@_beamer_bool { \lua_now:n { piton_beamer = true } }
+%    \end{macrocode}
 % 
 % \bigskip
 %    \begin{macrocode}
@@ -2085,6 +2139,7 @@ version 2005/12/01 or later.
 % or disallow page breaks.
 %    \begin{macrocode}
       \lua_now:n { piton.CountLinesFile(token.scan_argument()) } { #2 }  
+%    \end{document}     
 % 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
@@ -2326,6 +2381,8 @@ version 2005/12/01 or later.
     Exception        .value_required:n = true ,
     Comment.LaTeX    .tl_set:c = pitonStyle Comment.LaTeX ,
     Comment.LaTeX    .value_required:n = true ,
+    Beamer           .tl_set:c = pitonStyle Beamer ,
+    Beamer           .value_required:n = true ,
     unknown          .code:n = 
       \msg_error:nn { piton } { Unknown~key~for~SetPitonStyle }
   }
@@ -2391,6 +2448,7 @@ version 2005/12/01 or later.
     InitialValues    = \@@_piton:n ,
     Dict.Value       = \@@_piton:n ,
     Interpol.Inside  = \color{black}\@@_piton:n ,
+    Beamer           = \@@_piton:n , 
     Post.Function    = \@@_piton:n ,
   }
 %    \end{macrocode}
@@ -2482,8 +2540,8 @@ end
 % The function |L| takes in as argument a pattern and returns a \textsc{lpeg}
 % \emph{which does a capture} of the pattern. That capture will be sent to LaTeX
 % with standard LaTeX catcodes for all the characters: the elements captured
-% will be formatted as normal LaTeX codes. It's suitable for the ``comment
-% LateX'' in the environments |{Piton}| and the elements beetween
+% will be formatted as normal LaTeX codes. It's suitable for the ``LaTeX
+% comments'' in the environments |{Piton}| and the elements beetween 
 % ``|escape-inside|''. That function won't be much used.
 %    \begin{macrocode}
 local function L(pattern)
@@ -2510,7 +2568,7 @@ end
 % LaTeX formatting instructions corresponding to the syntactic nature of that
 % Python chunk). The first argument is a pattern (that is to say a \textsc{lpeg}
 % without capture) and the second element is a Lua string corresponding to the
-% name of a \pkg{piton} style. If the seconde argument is not present, the
+% name of a \pkg{piton} style. If the second argument is not present, the
 % function |K| behaves as the function |Q| does.
 %    \begin{macrocode}
 local function K(pattern, style)
@@ -2582,7 +2640,7 @@ local identifier = letter * alphanum ^ 0
 %    \end{macrocode}
 % 
 % \medskip
-% On the other hand, the \textsc{lpeg} |Identifier| (with a capital) also return
+% On the other hand, the \textsc{lpeg} |Identifier| (with a capital) also returns
 % a \emph{capture}.
 %    \begin{macrocode}
 local Identifier = K ( identifier )
@@ -2674,7 +2732,7 @@ local Delim = K ( S "[()]" )
 % 
 % \bigskip
 % Some strings of length 2 are explicit because we want the corresponding
-% ligatures available in some fonts as \emph{Fira Code} to be active.
+% ligatures available in some fonts such as \emph{Fira Code} to be active.
 %    \begin{macrocode}
 local Operator = 
   K ( P "!=" + P "<>" + P "==" + P "<<" + P ">>" + P "<=" + P ">=" + P ":=" 
@@ -2834,7 +2892,7 @@ local FromImport =
 % First, we define \textsc{lpeg} for the interpolations in the f-strings. Here
 % is an example of a f-string with an interpolation and a format
 % instruction\footnote{There is no special \pkg{piton} style for the formatting
-% instruction (after the comma): the style which will be applied will be the
+% instruction (after the colon): the style which will be applied will be the
 % style of the encompassing string, that is to say |String.Short| or
 % |String.Long|.} in that interpolation:
 %
@@ -3178,14 +3236,14 @@ local DefFunction =
 % \emph{parsing expression grammars} (\textsc{peg}).
 % 
 % \smallskip 
-% If the word |def| is not followed by a identifier and parenthesis, it will be
+% If the word |def| is not followed by an identifier and parenthesis, it will be
 % catched as keyword by the \textsc{lpeg} |Keyword| (useful if, for example, the
 % final user wants to speak of the keyword \piton{def}).
 %
 % \bigskip
 % \paragraph{The dictionaries of Python}
 %
-% We have \textsc{lpeg} dealings with dictionaries of Python because, in
+% We have \textsc{lpeg} dealing with dictionaries of Python because, in
 % typesettings of explicit Python dictionnaries, 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|.
@@ -3216,7 +3274,39 @@ local Set =
   * K ( P "}" )
 %    \end{macrocode}
 %
+% \bigskip
+% \paragraph{Commands of Beamer}
 %
+%
+%    \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
+%    \end{macrocode}
+% 
 % \bigskip
 % \paragraph{The main LPEG}
 %
@@ -3240,6 +3330,7 @@ local SyntaxPythonAux =
          + Space
          + Escape 
          + CommentLaTeX
+         + Beamer 
          + LongString 
          + Comment
          + ExceptionInConsole
@@ -3505,11 +3596,15 @@ end
 %
 % \vspace{1cm}
 % \section{History}
+% \subsection*{Changes between versions 0.99 and 1.0}
+%
+% 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.
 %
 % \subsection*{Changes between versions 0.99 and 1.0}
 %
 % New key |tabs-auto-gobble|.
-%
 % 
 % \subsection*{Changes between versions 0.95 and 0.99}
 %
-- 
cgit v1.2.3

