texlive[72889] Master/texmf-dist: piton (18nov24)
commits+karl at tug.org
commits+karl at tug.org
Mon Nov 18 22:06:13 CET 2024
Revision: 72889
https://tug.org/svn/texlive?view=revision&revision=72889
Author: karl
Date: 2024-11-18 22:06:13 +0100 (Mon, 18 Nov 2024)
Log Message:
-----------
piton (18nov24)
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/source/lualatex/piton/piton.ins
trunk/Master/texmf-dist/tex/lualatex/piton/piton.lua
trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty
Modified: trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex 2024-11-18 21:06:02 UTC (rev 72888)
+++ trunk/Master/texmf-dist/doc/lualatex/piton/piton-french.tex 2024-11-18 21:06:13 UTC (rev 72889)
@@ -324,7 +324,7 @@
\bigskip
La commande |\piton| avec son argument entre accolades peut être utilisée dans les
arguments des autres commandes LaTeX.\footnote{La commande |\piton| peut par exemple être
- utilisée dans une note de bas de page. Exemple : \piton{s = 'Une chaîne'}.}
+utilisée dans une note de bas de page. Exemple : \piton{x = 123}.}
En revanche, comme son argument subit un développement (au sens de TeX), il faut prendre
soin à ne pas utiliser dans son argument de commandes fragiles (c'est-à-dire des commandes
@@ -333,9 +333,11 @@
\bigskip
\item {\color{blue} \textsf{Syntaxe} \verb!\piton|...|!}\par\nobreak
-Quand la commande |\piton| prend son argument entre deux caractères identiques, cet
-argument est pris \emph{en mode verbatim}. De ce fait, avec cette syntaxe, la commande
-|\piton| ne peut \emph{pas} être utilisée dans l'argument d'une autre fonction.
+Quand la commande |\piton| prend son argument entre deux caractères identiques (tous les
+caractères sont autorisés sauf |%|,
+|\|, |#|, |{|, |}| et l'espace), cet argument est pris \emph{en mode verbatim}. De ce
+fait, avec cette syntaxe, la commande |\piton| ne peut \emph{pas} être utilisée dans
+l'argument d'une autre fonction.
\medskip
\begin{tabular}{>{\color{gray}}w{l}{75mm}@{\hspace*{1cm}}l}
@@ -1269,6 +1271,13 @@
coupées n'importe où (et pas seulement sur les espaces).
+\bigskip
+\colorbox{yellow!50}{\bfseries{Nouveau 4.2}}\par\nobreak
+
+\smallskip
+Avec la clé \Definition{break-numbers-anywhere}, les nombres peuvent être coupés n'importe où.
+
+
\subsubsection{Coupure des pages}
\label{coupure-de-pages}
@@ -2824,13 +2833,27 @@
Comment.LaTeX & les commentaires commençant par \texttt{-->} qui sont composés par
\pkg{piton} comme du code LaTeX (et appelés simplement «commentaires
LaTeX» dans ce document) \\
-Keyword & les mots-clés suivants (leur nom n'est \emph{pas} sensible à la casse) : |add|,
- |after|, |all|, |alter|, |and|, |as|, |asc|, |between|, |by|, |change|,
- |column|, |create|, |cross join|, |delete|, |desc|, |distinct|, |drop|, |from|,
- |group|, |having|, |in|, |inner|, |insert|, |into|, |is|, |join|, |left|,
- |like|, |limit|, |merge|, |not|, |null|, |on|, |or|, |order|, |over|, |right|,
- |select|, |set|, |table|, |then|, |truncate|, |union|, |update|, |values|,
- |when|, |where| et |with|. \\
+Keyword & les mots-clés suivants (leur nom n'est \emph{pas} sensible à la casse) :
+ |abort|, |action|, |add|, |after|, |all|, |alter|, |always|, |analyze|,
+ |and|, |as|, |asc|, |attach|, |autoincrement|, |before|, |begin|, |between|,
+ |by|, |cascade|, |case|, |cast|, |check|, |collate|, |column|, |commit|,
+ |conflict|, |constraint|, |create|, |cross|, |current|, |current_date|,
+ |current_time|, |current_timestamp|, |database|, |default|, |deferrable|,
+ |deferred|, |delete|, |desc|, |detach|, |distinct|, |do|, |drop|, |each|,
+ |else|, |end|, |escape|, |except|, |exclude|, |exclusive|, |exists|,
+ |explain|, |fail|, |filter|, |first|, |following|, |for|, |foreign|, |from|,
+ |full|, |generated|, |glob|, |group|, |groups|, |having|, |if|, |ignore|,
+ |immediate|, |in|, |index|, |indexed|, |initially|, |inner|, |insert|,
+ |instead|, |intersect|, |into|, |is|, |isnull|, |join|, |key|, |last|,
+ |left|, |like|, |limit|, |match|, |materialized|, |natural|, |no|, |not|,
+ |nothing|, |notnull|, |null|, |nulls|, |of|, |offset|, |on|, |or|, |order|,
+ |others|, |outer|, |over|, |partition|, |plan|, |pragma|, |preceding|,
+ |primary|, |query|, |raise|, |range|, |recursive|, |references|, |regexp|,
+ |reindex|, |release|, |rename|, |replace|, |restrict|, |returning|, |right|,
+ |rollback|, |row|, |rows|, |savepoint|, |select|, |set|, |table|, |temp|,
+ |temporary|, |then|, |ties|, |to|, |transaction|, |trigger|, |unbounded|,
+ |union|, |unique|, |update|, |using|, |vacuum|, |values|, |view|, |virtual|,
+ |when|, |where|, |window|, |with|, |without| \\
\bottomrule
\end{tabularx}
\end{center}
Modified: trunk/Master/texmf-dist/doc/lualatex/piton/piton.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx
===================================================================
--- trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx 2024-11-18 21:06:02 UTC (rev 72888)
+++ trunk/Master/texmf-dist/source/lualatex/piton/piton.dtx 2024-11-18 21:06:13 UTC (rev 72889)
@@ -79,12 +79,12 @@
% \iffalse
%<*STY>
% \fi
-\def\PitonFileVersion{4.1}
-\def\PitonFileDate{2024/10/18}
+\def\PitonFileVersion{4.2}
+\def\PitonFileDate{2024/11/18}
% \iffalse
%</STY>
%<*LUA>
-piton_version = "4.1" -- 2024/10/18
+piton_version = "4.2" -- 2024/11/18
%</LUA>
%\fi
%
@@ -305,7 +305,7 @@
% It's possible to use the command |\piton| in the arguments of a
% LaTeX command.\footnote{For example, it's possible to use the command
% \texttt{\textbackslash piton} in a footnote. Example :
-% \piton{s = 'A string'}.}
+% \piton{s = 123}.}
%
% However, since the argument is expanded (in the TeX sens), one should take
% care not using in its argument \emph{fragile} commands (that is to say
@@ -315,7 +315,8 @@
% \item {\color{blue} \textsf{Syntax} \verb!\piton|...|!}\par\nobreak
%
% When the argument of the command |\piton| is provided between two identical
-% characters, that argument is taken in a \emph{verbatim mode}. Therefore, with
+% characters (all the characters are allowed except |%|, |\|, |#|, |{|, |}| and
+% the space), that argument is taken in a \emph{verbatim mode}. Therefore, with
% that syntax, the command |\piton| can't be used within the argument of another
% command.
%
@@ -1264,6 +1265,13 @@
% With the key \Definition{break-strings-anywhere}, the strings may be broken
% anywhere (and not only on the spaces).
%
+% \bigskip
+% \colorbox{yellow!50}{\bfseries{New 4.2}}\par\nobreak
+%
+% \smallskip
+% With the key \Definition{break-numbers-anywhere}, the numbers may be broken
+% anywhere.
+%
% \subsubsection{Page breaks}
% \label{page breaks}
% \index{splittable}
@@ -2601,7 +2609,7 @@
% Name.Table & the names of the tables \\
% Name.Field & the names of the fields of the tables \\
% Name.Builtin & the following built-in functions (their names are \emph{not} case-sensitive):
-% |avg|, |count|, |char_lenght|, |concat|, |curdate|, |current_date|,
+% |avg|, |count|, |char_length|, |concat|, |curdate|, |current_date|,
% |date_format|, |day|, |lower|, |ltrim|, |max|, |min|, |month|, |now|,
% |rank|, |round|, |rtrim|, |substring|, |sum|, |upper| and |year|. \\
% Comment & the comments (beginning by \texttt{--} or between |/*| and |*/|) \\
@@ -2608,12 +2616,26 @@
% Comment.LaTeX & the comments beginning by \texttt{-->} which are composed by
% \pkg{piton} as LaTeX code (merely named ``LaTeX comments'' in this document) \\
% Keyword & the following keywords (their names are \emph{not} case-sensitive):
-% |add|, |after|, |all|, |alter|, |and|, |as|, |asc|, |between|, |by|,
-% |change|, |column|, |create|, |cross join|, |delete|, |desc|, |distinct|,
-% |drop|, |from|, |group|, |having|, |in|, |inner|, |insert|, |into|, |is|,
-% |join|, |left|, |like|, |limit|, |merge|, |not|, |null|, |on|, |or|,
-% |order|, |over|, |right|, |select|, |set|, |table|, |then|, |truncate|,
-% |union|, |update|, |values|, |when|, |where| and |with|. \\
+% |abort|, |action|, |add|, |after|, |all|, |alter|, |always|, |analyze|,
+% |and|, |as|, |asc|, |attach|, |autoincrement|, |before|, |begin|, |between|,
+% |by|, |cascade|, |case|, |cast|, |check|, |collate|, |column|, |commit|,
+% |conflict|, |constraint|, |create|, |cross|, |current|, |current_date|,
+% |current_time|, |current_timestamp|, |database|, |default|, |deferrable|,
+% |deferred|, |delete|, |desc|, |detach|, |distinct|, |do|, |drop|, |each|,
+% |else|, |end|, |escape|, |except|, |exclude|, |exclusive|, |exists|,
+% |explain|, |fail|, |filter|, |first|, |following|, |for|, |foreign|, |from|,
+% |full|, |generated|, |glob|, |group|, |groups|, |having|, |if|, |ignore|,
+% |immediate|, |in|, |index|, |indexed|, |initially|, |inner|, |insert|,
+% |instead|, |intersect|, |into|, |is|, |isnull|, |join|, |key|, |last|,
+% |left|, |like|, |limit|, |match|, |materialized|, |natural|, |no|, |not|,
+% |nothing|, |notnull|, |null|, |nulls|, |of|, |offset|, |on|, |or|, |order|,
+% |others|, |outer|, |over|, |partition|, |plan|, |pragma|, |preceding|,
+% |primary|, |query|, |raise|, |range|, |recursive|, |references|, |regexp|,
+% |reindex|, |release|, |rename|, |replace|, |restrict|, |returning|, |right|,
+% |rollback|, |row|, |rows|, |savepoint|, |select|, |set|, |table|, |temp|,
+% |temporary|, |then|, |ties|, |to|, |transaction|, |trigger|, |unbounded|,
+% |union|, |unique|, |update|, |using|, |vacuum|, |values|, |view|, |virtual|,
+% |when|, |where|, |window|, |with|, |without| \\
% \bottomrule
% \end{tabularx}
% \end{center}
@@ -4002,8 +4024,10 @@
% \begin{macrocode}
\keys_define:nn { PitonOptions }
{
- break-strings-anywhere .code:n =
- \cs_set_eq:NN \@@_break_anywhere:n \@@_actually_break_anywhere:n ,
+ break-strings-anywhere .bool_set:N = \l_@@_break_strings_anywhere_bool ,
+ break-strings-anywhere .default:n = true ,
+ break-numbers-anywhere .bool_set:N = \l_@@_break_numbers_anywhere_bool ,
+ break-numbers-anywhere .default:n = true ,
% \end{macrocode}
% First, we put keys that should be available only in the preamble.
% \begin{macrocode}
@@ -4461,7 +4485,15 @@
\NewDocumentCommand { \@@_piton_standard } { m }
{
\group_begin:
- \bool_if:NT \l_@@_break_lines_in_piton_bool
+ \bool_lazy_or:nnT
+ \l_@@_break_lines_in_piton_bool
+% \end{macrocode}
+% We have to deal with the case of |break-strings-anywhere| because,
+% otherwise, the |\nobreakspace| would result in a sequence of TeX instructions
+% and we would have difficulities during the insertion of all the commands |\-|
+% (to allow breaks anywhere in the string).
+% \begin{macrocode}
+ \l_@@_break_strings_anywhere_bool
{ \tl_set_eq:NN \l_@@_space_in_string_tl \space }
% \end{macrocode}
% The following tuning of LuaTeX in order to avoid all breaks of lines on the
@@ -4522,7 +4554,6 @@
\NewDocumentCommand { \@@_piton_verbatim } { v }
{
\group_begin:
- \l_@@_font_command_tl
\automatichyphenmode = 1
\cs_set_eq:NN \@@_begin_line: \prg_do_nothing:
\tl_set:Ne \l_tmpa_tl
@@ -4533,7 +4564,11 @@
}
\bool_if:NT \l_@@_show_spaces_bool
{ \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
- \l_tmpa_tl
+ \if_mode_math:
+ \text { \l_@@_font_command_tl \l_tmpa_tl }
+ \else:
+ \l_@@_font_command_tl \l_tmpa_tl
+ \fi:
\group_end:
}
% \end{macrocode}
@@ -4715,7 +4750,7 @@
}
{
\group_end:
- \mode_if_vertical:TF { \noindent \mode_leave_vertical: } \newline
+ \mode_if_vertical:TF \noindent \newline
% \end{macrocode}
% The following line is only to compute |\l_@@_lines_int| which will be used
% only when both |left-margin=auto| and |skip-empty-lines = false| are in force.
@@ -5065,8 +5100,12 @@
% unlikely, suffixes) added to the markers by the functions
% |\@@_marker_beginning:n| and |\@@_marker_end:n|
% \begin{macrocode}
- \regex_replace_all:nnN { \\\# } \c_hash_str \l_tmpa_str
- \regex_replace_all:nnN { \\\# } \c_hash_str \l_tmpb_str
+ \regex_replace_all:nVN { \\\# } \c_hash_str \l_tmpa_str
+ \regex_replace_all:nVN { \\\# } \c_hash_str \l_tmpb_str
+% \end{macrocode}
+% However, it seems that our programmation is not good programmation because
+% our |\l_tmpa_str| is not a valid |str| value (maybe we should correct that).
+% \begin{macrocode}
\lua_now:e
{
piton.ComputeRange
@@ -5142,6 +5181,7 @@
Name.Table ,
Name.Type ,
Number ,
+ Number.Internal ,
Operator ,
Operator.Word ,
Preproc ,
@@ -5149,7 +5189,9 @@
String.Doc ,
String.Interpol ,
String.Long ,
+ String.Long.Internal ,
String.Short ,
+ String.Short.Internal ,
Tag ,
TypeParameter ,
UserFunction ,
@@ -5221,15 +5263,55 @@
%
% \bigskip
% \begin{macrocode}
-\cs_set_eq:NN \@@_break_anywhere:n \prg_do_nothing:
+% \bool_new:N \l_@@_break_strings_anywhere_bool
+\cs_set_eq:NN \@@_break_strings_anywhere:n \prg_do_nothing:
+
+\cs_set_eq:NN \@@_break_numbers_anywhere:n \prg_do_nothing:
+
\cs_new_protected:Npn \@@_actually_break_anywhere:n #1
{
- \seq_clear:N \l_tmpa_seq
- \tl_map_inline:nn { #1 }
+ \tl_set:Nn \l_tmpa_tl { #1 }
+% \end{macrocode}
+% We have to begin by a substitution for the spaces. Otherwise, they would be
+% gobbled in the |\tl_map_inline:Nn|.
+% \begin{macrocode}
+ \regex_replace_all:nnN { \x20 } { \c { space } } \l_tmpa_tl
+ \tl_map_inline:Nn \l_tmpa_tl
{ \seq_put_right:Nn \l_tmpa_seq { ##1 } }
\seq_use:Nn \l_tmpa_seq { \- }
}
% \end{macrocode}
+%
+% \bigskip
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_string_long:n #1
+ {
+ \PitonStyle { String.Long }
+ {
+ \bool_if:NT \l_@@_break_strings_anywhere_bool
+ { \@@_actually_break_anywhere:n }
+ { #1 }
+ }
+ }
+\cs_new_protected:Npn \@@_string_short:n #1
+ {
+ \PitonStyle { String.Short }
+ {
+ \bool_if:NT \l_@@_break_strings_anywhere_bool
+ { \@@_actually_break_anywhere:n }
+ { #1 }
+ }
+ }
+\cs_new_protected:Npn \@@_number:n #1
+ {
+ \PitonStyle { Number }
+ {
+ \bool_if:NT \l_@@_break_numbers_anywhere_bool
+ { \@@_actually_break_anywhere:n }
+ { #1 }
+ }
+ }
+% \end{macrocode}
%
% \bigskip
% \subsubsection{The initial styles}
@@ -5240,44 +5322,47 @@
% \begin{macrocode}
\SetPitonStyle
{
- Comment = \color[HTML]{0099FF} \itshape ,
- Exception = \color[HTML]{CC0000} ,
- Keyword = \color[HTML]{006699} \bfseries ,
- Keyword.Governing = \color[HTML]{006699} \bfseries ,
- Keyword.Constant = \color[HTML]{006699} \bfseries ,
- Name.Builtin = \color[HTML]{336666} ,
- Name.Decorator = \color[HTML]{9999FF},
- Name.Class = \color[HTML]{00AA88} \bfseries ,
- Name.Function = \color[HTML]{CC00FF} ,
- Name.Namespace = \color[HTML]{00CCFF} ,
- Name.Constructor = \color[HTML]{006000} \bfseries ,
- Name.Field = \color[HTML]{AA6600} ,
- Name.Module = \color[HTML]{0060A0} \bfseries ,
- Name.Table = \color[HTML]{309030} ,
- Number = \color[HTML]{FF6600} ,
- Operator = \color[HTML]{555555} ,
- Operator.Word = \bfseries ,
- String = \color[HTML]{CC3300} \@@_break_anywhere:n ,
- String.Doc = \color[HTML]{CC3300} \itshape ,
- String.Interpol = \color[HTML]{AA0000} ,
- Comment.LaTeX = \normalfont \color[rgb]{.468,.532,.6} ,
- Name.Type = \color[HTML]{336666} ,
- InitialValues = \@@_piton:n ,
- Interpol.Inside = \l_@@_font_command_tl \@@_piton:n ,
- TypeParameter = \color[HTML]{336666} \itshape ,
- Preproc = \color[HTML]{AA6600} \slshape ,
+ Comment = \color[HTML]{0099FF} \itshape ,
+ Exception = \color[HTML]{CC0000} ,
+ Keyword = \color[HTML]{006699} \bfseries ,
+ Keyword.Governing = \color[HTML]{006699} \bfseries ,
+ Keyword.Constant = \color[HTML]{006699} \bfseries ,
+ Name.Builtin = \color[HTML]{336666} ,
+ Name.Decorator = \color[HTML]{9999FF},
+ Name.Class = \color[HTML]{00AA88} \bfseries ,
+ Name.Function = \color[HTML]{CC00FF} ,
+ Name.Namespace = \color[HTML]{00CCFF} ,
+ Name.Constructor = \color[HTML]{006000} \bfseries ,
+ Name.Field = \color[HTML]{AA6600} ,
+ Name.Module = \color[HTML]{0060A0} \bfseries ,
+ Name.Table = \color[HTML]{309030} ,
+ Number = \color[HTML]{FF6600} ,
+ Number.Internal = \@@_number:n ,
+ Operator = \color[HTML]{555555} ,
+ Operator.Word = \bfseries ,
+ String = \color[HTML]{CC3300} ,
+ String.Long.Internal = \@@_string_long:n ,
+ String.Short.Internal = \@@_string_short:n ,
+ String.Doc = \color[HTML]{CC3300} \itshape ,
+ String.Interpol = \color[HTML]{AA0000} ,
+ Comment.LaTeX = \normalfont \color[rgb]{.468,.532,.6} ,
+ Name.Type = \color[HTML]{336666} ,
+ InitialValues = \@@_piton:n ,
+ Interpol.Inside = \l_@@_font_command_tl \@@_piton:n ,
+ TypeParameter = \color[HTML]{336666} \itshape ,
+ Preproc = \color[HTML]{AA6600} \slshape ,
% \end{macrocode}
% We need the command |\@@_identifier:n| because of the command
% |\SetPitonIdentifier|. The command |\@@_identifier:n| will potentially call
% the style |Identifier| (which is a user-style, not an internal style).
% \begin{macrocode}
- Identifier.Internal = \@@_identifier:n ,
- Identifier = ,
- Directive = \color[HTML]{AA6600} ,
- Tag = \colorbox{gray!10},
- UserFunction = \PitonStyle{Identifier} ,
- Prompt = ,
- Discard = \use_none:n
+ Identifier.Internal = \@@_identifier:n ,
+ Identifier = ,
+ Directive = \color[HTML]{AA6600} ,
+ Tag = \colorbox{gray!10},
+ UserFunction = \PitonStyle{Identifier} ,
+ Prompt = ,
+ Discard = \use_none:n
}
% \end{macrocode}
%
@@ -5613,6 +5698,7 @@
break-lines,~
break-lines-in-piton,~
break-lines-in-Piton,~
+ break-numbers-anywhere,~
break-strings-anywhere,~
continuation-symbol,~
continuation-symbol-on-indentation,~
@@ -5892,9 +5978,9 @@
if piton.begin_escape_math then
EscapeMath =
P ( piton.begin_escape_math )
- * Lc "\\ensuremath{"
+ * Lc "$"
* L ( ( 1 - P(piton.end_escape_math) ) ^ 1 )
- * Lc "}"
+ * Lc "$"
* P ( piton.end_escape_math )
end
% \end{macrocode}
@@ -5954,7 +6040,7 @@
% \pkg{piton} styles (but this is only a convention).
% \begin{macrocode}
local Number =
- K ( 'Number' ,
+ K ( 'Number.Internal' ,
( digit ^ 1 * P "." * # ( 1 - P "." ) * digit ^ 0
+ digit ^ 0 * P "." * digit ^ 1
+ digit ^ 1 )
@@ -6286,7 +6372,7 @@
% With the following \textsc{lpeg}, a style will actually be applied to the
% prompt (for instance, it's possible to decide to discard these prompts).
% \begin{macrocode}
-local Prompt = K ( 'Prompt' , ( ( P ">>>" + "..." ) * P " " ^ -1 ) ^ -1 )
+local Prompt = K ( 'Prompt' , ( ( P ">>>" + "..." ) * P " " ^ -1 ) ) ^ -1
% \end{macrocode}
%
%
@@ -6527,7 +6613,7 @@
% style of the encompassing string, that is to say |String.Short| or
% |String.Long|.} in that interpolation:
%
-% \piton{f'Total price: {total+1:.2f} €'}
+% |\piton{f'Total price: {total+1:.2f} €'}|
%
%
% \bigskip
@@ -6555,7 +6641,7 @@
% @@\_piton:n} which means that the interpolations are parsed once again by \pkg{piton}.}
% \begin{macrocode}
local SingleShortString =
- WithStyle ( 'String.Short' ,
+ WithStyle ( 'String.Short.Internal' ,
% \end{macrocode}
% First, we deal with the f-strings of Python, which are prefixed by |f| or |F|.
% \begin{macrocode}
@@ -6586,7 +6672,7 @@
%
% \begin{macrocode}
local DoubleShortString =
- WithStyle ( 'String.Short' ,
+ WithStyle ( 'String.Short.Internal' ,
Q ( P "f\"" + "F\"" )
* (
K ( 'String.Interpol' , "{" )
@@ -6651,7 +6737,7 @@
%
% \begin{macrocode}
local SingleLongString =
- WithStyle ( 'String.Long' ,
+ WithStyle ( 'String.Long.Internal' ,
( Q ( S "fF" * P "'''" )
* (
K ( 'String.Interpol' , "{" )
@@ -6680,7 +6766,7 @@
%
% \begin{macrocode}
local DoubleLongString =
- WithStyle ( 'String.Long' ,
+ WithStyle ( 'String.Long.Internal' ,
(
Q ( S "fF" * "\"\"\"" )
* (
@@ -6969,19 +7055,31 @@
% \paragraph{The strings of OCaml}
% \begin{macrocode}
local ocaml_string =
- Q "\""
+ P "\""
* (
- SpaceInString
+ P " "
+
- Q ( ( 1 - S " \"\r" ) ^ 1 )
+ P ( ( 1 - S " \"\r" ) ^ 1 )
+
- EOL
+ EOL -- ?
) ^ 0
- * Q "\""
+ * P "\""
% \end{macrocode}
%
% \begin{macrocode}
- local String = WithStyle ( 'String.Long' , ocaml_string )
+ local String =
+ WithStyle
+ ( 'String.Long.Internal' ,
+ Q "\""
+ * (
+ SpaceInString
+ +
+ Q ( ( 1 - S " \"\r" ) ^ 1 )
+ +
+ EOL
+ ) ^ 0
+ * Q "\""
+ )
% \end{macrocode}
%
% \bigskip
@@ -7008,7 +7106,7 @@
% The \textsc{lpeg} |QuotedStringBis| will do the second analysis.
% \begin{macrocode}
local QuotedStringBis =
- WithStyle ( 'String.Long' ,
+ WithStyle ( 'String.Long.Internal' ,
(
Space
+
@@ -7140,8 +7238,7 @@
% \bigskip
% In OCmal, \emph{character} is a type different of the type |string|.
% \begin{macrocode}
- local Char =
- K ( 'String.Short',
+ local ocaml_char =
P "'" *
(
( 1 - S "'\\" )
@@ -7153,7 +7250,9 @@
* ( digit + R "af" + R "AF" )
+ P "o" * R "03" * R "07" * R "07" )
)
- * "'" )
+ * "'"
+ local Char =
+ K ( 'String.Short.Internal', ocaml_char )
% \end{macrocode}
%
% \bigskip
@@ -7169,7 +7268,7 @@
% \begin{macrocode}
local expression_for_fields_type =
P { "E" ,
- E = ( "{" * V "F" * "}"
+ E = ( "{" * V "F" * "}"
+ "(" * V "F" * ")"
+ TypeParameter
+ ( 1 - S "{}()[]\r;" ) ) ^ 0 ,
@@ -7186,12 +7285,13 @@
E = ( "{" * V "F" * "}"
+ "(" * V "F" * ")"
+ "[" * V "F" * "]"
- + String + QuotedString + Char
- + ( 1 - S "{}()[]\r;" ) ) ^ 0 ,
+ + ocaml_string + ocaml_char
+ + ( 1 - S "{}()[];" ) ) ^ 0 ,
F = ( "{" * V "F" * "}"
+ "(" * V "F" * ")"
+ "[" * V "F" * "]"
- + ( 1 - S "{}()[]\r\"'" )) ^ 0
+ + ocaml_string + ocaml_char
+ + ( 1 - S "{}()[]\"'" )) ^ 0
}
% \end{macrocode}
%
@@ -7210,7 +7310,10 @@
local OneField =
K ( 'Name.Field' , identifier ) * SkipSpace
* Q "=" * SkipSpace
- * ( expression_for_fields_value / ParseAgain )
+% \end{macrocode}
+% Don't forget the parentheses!
+% \end{document}
+ * ( C ( expression_for_fields_value ) / ParseAgain )
* SkipSpace
% \end{macrocode}
%
@@ -7283,19 +7386,45 @@
% \end{macrocode}
%
% \bigskip
+% An argument in the definition of a OCaml function may be of the form
+% |(pattern:type)|. |pattern| may be a single identifier but it's not mandatory.
+% First instance, it's possible to write in OCaml:
+%
+% |let head (a::q) = a|
+%
+% First, we write a pattern (in the LPEG sens!) to match what will be the
+% pattern (in the OCaml sens).
% \begin{macrocode}
+ local pattern_part =
+ ( P "(" * balanced_parens * ")" + ( 1 - S ":()" ) + P "::" ) ^ 0
+% \end{macrocode}
+% For the ``type'' part, the LPEG-pattern will merely be |balanced_parens|.
+%
+% \bigskip
+% We can now write a LPEG |Argument| which catches a argument of function (in
+% the definition of the function).
+% \begin{macrocode}
local Argument =
% \end{macrocode}
-% For the labels of the labeled arguments. Maybe you will, in the future, create
-% a style for those elements.
+% The following line is for the labels of the labeled arguments. Maybe we will,
+% in the future, create a style for those elements.
% \begin{macrocode}
( Q "~" * Identifier * Q ":" * SkipSpace ) ^ -1
*
- ( K ( 'Identifier.Internal' , identifier )
- + Q "(" * SkipSpace
- * K ( 'Identifier.Internal' , identifier ) * SkipSpace
- * Q ":" * SkipSpace
- * K ( 'TypeExpression' , balanced_parens ) * SkipSpace
+% \end{macrocode}
+% Now, the argument itself, either a single identifier, or a construction
+% between parentheses
+% \begin{macrocode}
+ (
+ K ( 'Identifier.Internal' , identifier )
+ +
+ Q "(" * SkipSpace
+ * ( C ( pattern_part ) / ParseAgain )
+ * SkipSpace
+% \end{macrocode}
+% Of course, the specification of type is optional.
+% \begin{macrocode}
+ * ( Q ":" * K ( 'TypeExpression' , balanced_parens ) * SkipSpace ) ^ -1
* Q ")"
)
% \end{macrocode}
@@ -7316,8 +7445,7 @@
* (
Q "=" * SkipSpace * K ( 'Keyword' , "function" )
+
- Argument
- * ( SkipSpace * Argument ) ^ 0
+ Argument * ( SkipSpace * Argument ) ^ 0
* (
SkipSpace
* Q ":"
@@ -7451,7 +7579,7 @@
% type such as |my_type -> 'a list| (in that case, the argument of |\piton|
% \emph{must} begin by a colon).
% \begin{macrocode}
- ( P ":" + Identifier * SkipSpace * Q ":" )
+ ( P ":" + Identifier * SkipSpace * Q ":" ) * # ( 1 - P ":" )
* SkipSpace
* K ( 'TypeExpression' , ( 1 - P "\r" ) ^ 0 )
+
@@ -7557,7 +7685,7 @@
%
% \begin{macrocode}
String =
- WithStyle ( 'String.Long' ,
+ WithStyle ( 'String.Long.Internal' ,
Q "\""
* ( SpaceInString
+ K ( 'String.Interpol' ,
@@ -7740,18 +7868,32 @@
% \end{macrocode}
%
% \bigskip
-% We now use the previsou function |Set| to creates the ``sets'' |set_keywords|
-% and |set_builtin|.
+% We now use the previous function |Set| to creates the ``sets'' |set_keywords|
+% and |set_builtin|. That list of keywords comes from
+% \url{https://sqlite.org/lang_keywords.html}.
% \begin{macrocode}
local set_keywords = Set
{
- "ADD" , "AFTER" , "ALL" , "ALTER" , "AND" , "AS" , "ASC" , "BETWEEN" , "BY" ,
- "CHANGE" , "COLUMN" , "CREATE" , "CROSS JOIN" , "DELETE" , "DESC" , "DISTINCT" ,
- "DROP" , "EXCEPT" , "FROM" , "GROUP" , "HAVING" , "IN" , "INNER" ,
- "INSERT" , "INTERSECT" , "INTO" , "IS" , "JOIN" , "LEFT" , "LIKE" , "LIMIT" ,
- "MERGE" , "NOT" , "NULL" , "OFFSET" , "ON" , "OR" , "ORDER" , "OVER" ,
- "RIGHT" , "SELECT" , "SET" , "TABLE" , "THEN" , "TRUNCATE" , "UNION" ,
- "UPDATE" , "VALUES" , "WHEN" , "WHERE" , "WITH"
+ "ABORT", "ACTION", "ADD", "AFTER", "ALL", "ALTER", "ALWAYS", "ANALYZE",
+ "AND", "AS", "ASC", "ATTACH", "AUTOINCREMENT", "BEFORE", "BEGIN", "BETWEEN",
+ "BY", "CASCADE", "CASE", "CAST", "CHECK", "COLLATE", "COLUMN", "COMMIT",
+ "CONFLICT", "CONSTRAINT", "CREATE", "CROSS", "CURRENT", "CURRENT_DATE",
+ "CURRENT_TIME", "CURRENT_TIMESTAMP", "DATABASE", "DEFAULT", "DEFERRABLE",
+ "DEFERRED", "DELETE", "DESC", "DETACH", "DISTINCT", "DO", "DROP", "EACH",
+ "ELSE", "END", "ESCAPE", "EXCEPT", "EXCLUDE", "EXCLUSIVE", "EXISTS",
+ "EXPLAIN", "FAIL", "FILTER", "FIRST", "FOLLOWING", "FOR", "FOREIGN", "FROM",
+ "FULL", "GENERATED", "GLOB", "GROUP", "GROUPS", "HAVING", "IF", "IGNORE",
+ "IMMEDIATE", "IN", "INDEX", "INDEXED", "INITIALLY", "INNER", "INSERT",
+ "INSTEAD", "INTERSECT", "INTO", "IS", "ISNULL", "JOIN", "KEY", "LAST",
+ "LEFT", "LIKE", "LIMIT", "MATCH", "MATERIALIZED", "NATURAL", "NO", "NOT",
+ "NOTHING", "NOTNULL", "NULL", "NULLS", "OF", "OFFSET", "ON", "OR", "ORDER",
+ "OTHERS", "OUTER", "OVER", "PARTITION", "PLAN", "PRAGMA", "PRECEDING",
+ "PRIMARY", "QUERY", "RAISE", "RANGE", "RECURSIVE", "REFERENCES", "REGEXP",
+ "REINDEX", "RELEASE", "RENAME", "REPLACE", "RESTRICT", "RETURNING", "RIGHT",
+ "ROLLBACK", "ROW", "ROWS", "SAVEPOINT", "SELECT", "SET", "TABLE", "TEMP",
+ "TEMPORARY", "THEN", "TIES", "TO", "TRANSACTION", "TRIGGER", "UNBOUNDED",
+ "UNION", "UNIQUE", "UPDATE", "USING", "VACUUM", "VALUES", "VIEW", "VIRTUAL",
+ "WHEN", "WHERE", "WINDOW", "WITH", "WITHOUT"
}
% \end{macrocode}
%
@@ -7758,7 +7900,7 @@
% \begin{macrocode}
local set_builtins = Set
{
- "AVG" , "COUNT" , "CHAR_LENGHT" , "CONCAT" , "CURDATE" , "CURRENT_DATE" ,
+ "AVG" , "COUNT" , "CHAR_LENGTH" , "CONCAT" , "CURDATE" , "CURRENT_DATE" ,
"DATE_FORMAT" , "DAY" , "LOWER" , "LTRIM" , "MAX" , "MIN" , "MONTH" , "NOW" ,
"RANK" , "ROUND" , "RTRIM" , "SUBSTRING" , "SUM" , "UPPER" , "YEAR"
}
@@ -7798,7 +7940,7 @@
% \paragraph{The strings of SQL}
%
% \begin{macrocode}
- local String = K ( 'String.Long' , "'" * ( 1 - P "'" ) ^ 1 * "'" )
+ local String = K ( 'String.Long.Internal' , "'" * ( 1 - P "'" ) ^ 1 * "'" )
% \end{macrocode}
%
% \bigskip
@@ -7972,7 +8114,7 @@
* ( EOL + -1 )
local String =
- WithStyle ( 'String.Short' ,
+ WithStyle ( 'String.Short.Internal' ,
Q "\""
* ( SpaceInString
+ Q ( ( P "\\\"" + 1 - S " \"" ) ^ 1 )
@@ -8899,7 +9041,7 @@
% computed.
% \begin{macrocode}
local Number =
- K ( 'Number' ,
+ K ( 'Number.Internal' ,
( digit ^ 1 * "." * # ( 1 - P "." ) * digit ^ 0
+ digit ^ 0 * "." * digit ^ 1
+ digit ^ 1 )
@@ -9323,6 +9465,10 @@
%
% \verb|https://github.com/fpantigny/piton|
%
+% \subsection*{Changes between versions 4.1 and 4.2}
+%
+% New key |break-numbers-anywhere|.
+%
% \subsection*{Changes between versions 4.0 and 4.1}
%
% New language |verbatim|.
Modified: trunk/Master/texmf-dist/source/lualatex/piton/piton.ins
===================================================================
--- trunk/Master/texmf-dist/source/lualatex/piton/piton.ins 2024-11-18 21:06:02 UTC (rev 72888)
+++ trunk/Master/texmf-dist/source/lualatex/piton/piton.ins 2024-11-18 21:06:13 UTC (rev 72889)
@@ -31,6 +31,7 @@
-------------------------------------------
\endpreamble
+\askforoverwritefalse
\generate{\file{piton.sty}{\from{piton.dtx}{STY}}}
\def\MetaPrefix{--}
\preamble
Modified: trunk/Master/texmf-dist/tex/lualatex/piton/piton.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/piton/piton.lua 2024-11-18 21:06:02 UTC (rev 72888)
+++ trunk/Master/texmf-dist/tex/lualatex/piton/piton.lua 2024-11-18 21:06:13 UTC (rev 72889)
@@ -20,7 +20,7 @@
-- -------------------------------------------
--
-- This file is part of the LuaLaTeX package 'piton'.
-piton_version = "4.1" -- 2024/10/18
+piton_version = "4.2" -- 2024/11/18
@@ -75,9 +75,9 @@
if piton.begin_escape_math then
EscapeMath =
P ( piton.begin_escape_math )
- * Lc "\\ensuremath{"
+ * Lc "$"
* L ( ( 1 - P(piton.end_escape_math) ) ^ 1 )
- * Lc "}"
+ * Lc "$"
* P ( piton.end_escape_math )
end
lpeg.locale(lpeg)
@@ -91,7 +91,7 @@
local identifier = letter * alphanum ^ 0
local Identifier = K ( 'Identifier.Internal' , identifier )
local Number =
- K ( 'Number' ,
+ K ( 'Number.Internal' ,
( digit ^ 1 * P "." * # ( 1 - P "." ) * digit ^ 0
+ digit ^ 0 * P "." * digit ^ 1
+ digit ^ 1 )
@@ -255,7 +255,7 @@
P "$" * K ( 'Comment.Math' , ( 1 - S "$\r" ) ^ 1 ) * P "$" -- $
local PromptHastyDetection =
( # ( P ">>>" + "..." ) * Lc [[ \__piton_prompt: ]] ) ^ -1
-local Prompt = K ( 'Prompt' , ( ( P ">>>" + "..." ) * P " " ^ -1 ) ^ -1 )
+local Prompt = K ( 'Prompt' , ( ( P ">>>" + "..." ) * P " " ^ -1 ) ) ^ -1
local EOL =
P "\r"
*
@@ -374,7 +374,7 @@
* S "sdfFeExXorgiGauc%"
)
local SingleShortString =
- WithStyle ( 'String.Short' ,
+ WithStyle ( 'String.Short.Internal' ,
Q ( P "f'" + "F'" )
* (
K ( 'String.Interpol' , "{" )
@@ -396,7 +396,7 @@
) ^ 0
* Q "'" )
local DoubleShortString =
- WithStyle ( 'String.Short' ,
+ WithStyle ( 'String.Short.Internal' ,
Q ( P "f\"" + "F\"" )
* (
K ( 'String.Interpol' , "{" )
@@ -432,7 +432,7 @@
DetectedCommands = Compute_DetectedCommands ( 'python' , braces )
LPEG_cleaner.python = Compute_LPEG_cleaner ( 'python' , braces )
local SingleLongString =
- WithStyle ( 'String.Long' ,
+ WithStyle ( 'String.Long.Internal' ,
( Q ( S "fF" * P "'''" )
* (
K ( 'String.Interpol' , "{" )
@@ -458,7 +458,7 @@
)
* Q "'''" )
local DoubleLongString =
- WithStyle ( 'String.Long' ,
+ WithStyle ( 'String.Long.Internal' ,
(
Q ( S "fF" * "\"\"\"" )
* (
@@ -609,16 +609,28 @@
local balanced_parens =
P { "E" , E = ( "(" * V "E" * ")" + ( 1 - S "()" ) ) ^ 0 }
local ocaml_string =
- Q "\""
+ P "\""
* (
- SpaceInString
+ P " "
+
- Q ( ( 1 - S " \"\r" ) ^ 1 )
+ P ( ( 1 - S " \"\r" ) ^ 1 )
+
- EOL
+ EOL -- ?
) ^ 0
- * Q "\""
- local String = WithStyle ( 'String.Long' , ocaml_string )
+ * P "\""
+ local String =
+ WithStyle
+ ( 'String.Long.Internal' ,
+ Q "\""
+ * (
+ SpaceInString
+ +
+ Q ( ( 1 - S " \"\r" ) ^ 1 )
+ +
+ EOL
+ ) ^ 0
+ * Q "\""
+ )
local ext = ( R "az" + "_" ) ^ 0
local open = "{" * Cg ( ext , 'init' ) * "|"
local close = "|" * C ( ext ) * "}"
@@ -626,7 +638,7 @@
Cmt ( close * Cb ( 'init' ) ,
function ( s , i , a , b ) return a == b end )
local QuotedStringBis =
- WithStyle ( 'String.Long' ,
+ WithStyle ( 'String.Long.Internal' ,
(
Space
+
@@ -680,8 +692,7 @@
local identifier = ( R "az" + "_" ) * ( R "az" + R "AZ" + S "_'" + digit ) ^ 0
- ( OperatorWord + Keyword ) * EndKeyword
local Identifier = K ( 'Identifier.Internal' , identifier )
- local Char =
- K ( 'String.Short',
+ local ocaml_char =
P "'" *
(
( 1 - S "'\\" )
@@ -693,13 +704,15 @@
* ( digit + R "af" + R "AF" )
+ P "o" * R "03" * R "07" * R "07" )
)
- * "'" )
+ * "'"
+ local Char =
+ K ( 'String.Short.Internal', ocaml_char )
local TypeParameter =
K ( 'TypeParameter' ,
"'" * Q"_" ^ -1 * alpha ^ 1 * ( # ( 1 - P "'" ) + -1 ) )
local expression_for_fields_type =
P { "E" ,
- E = ( "{" * V "F" * "}"
+ E = ( "{" * V "F" * "}"
+ "(" * V "F" * ")"
+ TypeParameter
+ ( 1 - S "{}()[]\r;" ) ) ^ 0 ,
@@ -712,12 +725,13 @@
E = ( "{" * V "F" * "}"
+ "(" * V "F" * ")"
+ "[" * V "F" * "]"
- + String + QuotedString + Char
- + ( 1 - S "{}()[]\r;" ) ) ^ 0 ,
+ + ocaml_string + ocaml_char
+ + ( 1 - S "{}()[];" ) ) ^ 0 ,
F = ( "{" * V "F" * "}"
+ "(" * V "F" * ")"
+ "[" * V "F" * "]"
- + ( 1 - S "{}()[]\r\"'" )) ^ 0
+ + ocaml_string + ocaml_char
+ + ( 1 - S "{}()[]\"'" )) ^ 0
}
local OneFieldDefinition =
( K ( 'Keyword' , "mutable" ) * SkipSpace ) ^ -1
@@ -728,7 +742,7 @@
local OneField =
K ( 'Name.Field' , identifier ) * SkipSpace
* Q "=" * SkipSpace
- * ( expression_for_fields_value / ParseAgain )
+ * ( C ( expression_for_fields_value ) / ParseAgain )
* SkipSpace
local Record =
Q "{" * SkipSpace
@@ -769,14 +783,18 @@
"Match_failure" + "Not_found" + "Out_of_memory" + "Stack_overflow" +
"Sys_blocked_io" + "Sys_error" + "Undefined_recursive_module" )
LPEG_cleaner.ocaml = Compute_LPEG_cleaner ( 'ocaml' , braces )
+ local pattern_part =
+ ( P "(" * balanced_parens * ")" + ( 1 - S ":()" ) + P "::" ) ^ 0
local Argument =
( Q "~" * Identifier * Q ":" * SkipSpace ) ^ -1
*
- ( K ( 'Identifier.Internal' , identifier )
- + Q "(" * SkipSpace
- * K ( 'Identifier.Internal' , identifier ) * SkipSpace
- * Q ":" * SkipSpace
- * K ( 'TypeExpression' , balanced_parens ) * SkipSpace
+ (
+ K ( 'Identifier.Internal' , identifier )
+ +
+ Q "(" * SkipSpace
+ * ( C ( pattern_part ) / ParseAgain )
+ * SkipSpace
+ * ( Q ":" * K ( 'TypeExpression' , balanced_parens ) * SkipSpace ) ^ -1
* Q ")"
)
local DefFunction =
@@ -791,8 +809,7 @@
* (
Q "=" * SkipSpace * K ( 'Keyword' , "function" )
+
- Argument
- * ( SkipSpace * Argument ) ^ 0
+ Argument * ( SkipSpace * Argument ) ^ 0
* (
SkipSpace
* Q ":"
@@ -892,7 +909,7 @@
LPEG1.ocaml = Main ^ 0
LPEG2.ocaml =
Ct (
- ( P ":" + Identifier * SkipSpace * Q ":" )
+ ( P ":" + Identifier * SkipSpace * Q ":" ) * # ( 1 - P ":" )
* SkipSpace
* K ( 'TypeExpression' , ( 1 - P "\r" ) ^ 0 )
+
@@ -949,7 +966,7 @@
local DefClass =
K ( 'Keyword' , "class" ) * Space * K ( 'Name.Class' , identifier )
String =
- WithStyle ( 'String.Long' ,
+ WithStyle ( 'String.Long.Internal' ,
Q "\""
* ( SpaceInString
+ K ( 'String.Interpol' ,
@@ -1036,17 +1053,30 @@
end
local set_keywords = Set
{
- "ADD" , "AFTER" , "ALL" , "ALTER" , "AND" , "AS" , "ASC" , "BETWEEN" , "BY" ,
- "CHANGE" , "COLUMN" , "CREATE" , "CROSS JOIN" , "DELETE" , "DESC" , "DISTINCT" ,
- "DROP" , "EXCEPT" , "FROM" , "GROUP" , "HAVING" , "IN" , "INNER" ,
- "INSERT" , "INTERSECT" , "INTO" , "IS" , "JOIN" , "LEFT" , "LIKE" , "LIMIT" ,
- "MERGE" , "NOT" , "NULL" , "OFFSET" , "ON" , "OR" , "ORDER" , "OVER" ,
- "RIGHT" , "SELECT" , "SET" , "TABLE" , "THEN" , "TRUNCATE" , "UNION" ,
- "UPDATE" , "VALUES" , "WHEN" , "WHERE" , "WITH"
+ "ABORT", "ACTION", "ADD", "AFTER", "ALL", "ALTER", "ALWAYS", "ANALYZE",
+ "AND", "AS", "ASC", "ATTACH", "AUTOINCREMENT", "BEFORE", "BEGIN", "BETWEEN",
+ "BY", "CASCADE", "CASE", "CAST", "CHECK", "COLLATE", "COLUMN", "COMMIT",
+ "CONFLICT", "CONSTRAINT", "CREATE", "CROSS", "CURRENT", "CURRENT_DATE",
+ "CURRENT_TIME", "CURRENT_TIMESTAMP", "DATABASE", "DEFAULT", "DEFERRABLE",
+ "DEFERRED", "DELETE", "DESC", "DETACH", "DISTINCT", "DO", "DROP", "EACH",
+ "ELSE", "END", "ESCAPE", "EXCEPT", "EXCLUDE", "EXCLUSIVE", "EXISTS",
+ "EXPLAIN", "FAIL", "FILTER", "FIRST", "FOLLOWING", "FOR", "FOREIGN", "FROM",
+ "FULL", "GENERATED", "GLOB", "GROUP", "GROUPS", "HAVING", "IF", "IGNORE",
+ "IMMEDIATE", "IN", "INDEX", "INDEXED", "INITIALLY", "INNER", "INSERT",
+ "INSTEAD", "INTERSECT", "INTO", "IS", "ISNULL", "JOIN", "KEY", "LAST",
+ "LEFT", "LIKE", "LIMIT", "MATCH", "MATERIALIZED", "NATURAL", "NO", "NOT",
+ "NOTHING", "NOTNULL", "NULL", "NULLS", "OF", "OFFSET", "ON", "OR", "ORDER",
+ "OTHERS", "OUTER", "OVER", "PARTITION", "PLAN", "PRAGMA", "PRECEDING",
+ "PRIMARY", "QUERY", "RAISE", "RANGE", "RECURSIVE", "REFERENCES", "REGEXP",
+ "REINDEX", "RELEASE", "RENAME", "REPLACE", "RESTRICT", "RETURNING", "RIGHT",
+ "ROLLBACK", "ROW", "ROWS", "SAVEPOINT", "SELECT", "SET", "TABLE", "TEMP",
+ "TEMPORARY", "THEN", "TIES", "TO", "TRANSACTION", "TRIGGER", "UNBOUNDED",
+ "UNION", "UNIQUE", "UPDATE", "USING", "VACUUM", "VALUES", "VIEW", "VIRTUAL",
+ "WHEN", "WHERE", "WINDOW", "WITH", "WITHOUT"
}
local set_builtins = Set
{
- "AVG" , "COUNT" , "CHAR_LENGHT" , "CONCAT" , "CURDATE" , "CURRENT_DATE" ,
+ "AVG" , "COUNT" , "CHAR_LENGTH" , "CONCAT" , "CURDATE" , "CURRENT_DATE" ,
"DATE_FORMAT" , "DAY" , "LOWER" , "LTRIM" , "MAX" , "MIN" , "MONTH" , "NOW" ,
"RANK" , "ROUND" , "RTRIM" , "SUBSTRING" , "SUM" , "UPPER" , "YEAR"
}
@@ -1071,7 +1101,7 @@
end
end
)
- local String = K ( 'String.Long' , "'" * ( 1 - P "'" ) ^ 1 * "'" )
+ local String = K ( 'String.Long.Internal' , "'" * ( 1 - P "'" ) ^ 1 * "'" )
local braces = Compute_braces ( "'" * ( 1 - P "'" ) ^ 1 * "'" )
if piton.beamer then Beamer = Compute_Beamer ( 'sql' , braces ) end
DetectedCommands = Compute_DetectedCommands ( 'sql' , braces )
@@ -1172,7 +1202,7 @@
* ( EOL + -1 )
local String =
- WithStyle ( 'String.Short' ,
+ WithStyle ( 'String.Short.Internal' ,
Q "\""
* ( SpaceInString
+ Q ( ( P "\\\"" + 1 - S " \"" ) ^ 1 )
@@ -1688,7 +1718,7 @@
end
end
local Number =
- K ( 'Number' ,
+ K ( 'Number.Internal' ,
( digit ^ 1 * "." * # ( 1 - P "." ) * digit ^ 0
+ digit ^ 0 * "." * digit ^ 1
+ digit ^ 1 )
Modified: trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty 2024-11-18 21:06:02 UTC (rev 72888)
+++ trunk/Master/texmf-dist/tex/lualatex/piton/piton.sty 2024-11-18 21:06:13 UTC (rev 72889)
@@ -19,8 +19,8 @@
%% LaTeX version 2005/12/01 or later.
%% -------------------------------------------
%%
-\def\PitonFileVersion{4.1}
-\def\PitonFileDate{2024/10/18}
+\def\PitonFileVersion{4.2}
+\def\PitonFileDate{2024/11/18}
@@ -519,8 +519,10 @@
}
\keys_define:nn { PitonOptions }
{
- break-strings-anywhere .code:n =
- \cs_set_eq:NN \__piton_break_anywhere:n \__piton_actually_break_anywhere:n ,
+ break-strings-anywhere .bool_set:N = \l__piton_break_strings_anywhere_bool ,
+ break-strings-anywhere .default:n = true ,
+ break-numbers-anywhere .bool_set:N = \l__piton_break_numbers_anywhere_bool ,
+ break-numbers-anywhere .default:n = true ,
detected-commands .code:n =
\lua_now:n { piton.addDetectedCommands('#1') } ,
detected-commands .value_required:n = true ,
@@ -812,7 +814,9 @@
\NewDocumentCommand { \__piton_piton_standard } { m }
{
\group_begin:
- \bool_if:NT \l__piton_break_lines_in_piton_bool
+ \bool_lazy_or:nnT
+ \l__piton_break_lines_in_piton_bool
+ \l__piton_break_strings_anywhere_bool
{ \tl_set_eq:NN \l__piton_space_in_string_tl \space }
\automatichyphenmode = 1
\cs_set_eq:NN \\ \c_backslash_str
@@ -844,7 +848,6 @@
\NewDocumentCommand { \__piton_piton_verbatim } { v }
{
\group_begin:
- \l__piton_font_command_tl
\automatichyphenmode = 1
\cs_set_eq:NN \__piton_begin_line: \prg_do_nothing:
\tl_set:Ne \l_tmpa_tl
@@ -855,7 +858,11 @@
}
\bool_if:NT \l__piton_show_spaces_bool
{ \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
- \l_tmpa_tl
+ \if_mode_math:
+ \text { \l__piton_font_command_tl \l_tmpa_tl }
+ \else:
+ \l__piton_font_command_tl \l_tmpa_tl
+ \fi:
\group_end:
}
@@ -957,7 +964,7 @@
}
{
\group_end:
- \mode_if_vertical:TF { \noindent \mode_leave_vertical: } \newline
+ \mode_if_vertical:TF \noindent \newline
\lua_now:e { piton.CountLines ( '\lua_escape:n{##1}' ) }
\__piton_compute_left_margin:nn { CountNonEmptyLines } { ##1 }
\__piton_compute_width:
@@ -1168,8 +1175,8 @@
{
\str_set:Ne \l_tmpa_str { \__piton_marker_beginning:n \l__piton_begin_range_str }
\str_set:Ne \l_tmpb_str { \__piton_marker_end:n \l__piton_end_range_str }
- \regex_replace_all:nnN { \\\# } \c_hash_str \l_tmpa_str
- \regex_replace_all:nnN { \\\# } \c_hash_str \l_tmpb_str
+ \regex_replace_all:nVN { \\\# } \c_hash_str \l_tmpa_str
+ \regex_replace_all:nVN { \\\# } \c_hash_str \l_tmpb_str
\lua_now:e
{
piton.ComputeRange
@@ -1225,6 +1232,7 @@
Name.Table ,
Name.Type ,
Number ,
+ Number.Internal ,
Operator ,
Operator.Word ,
Preproc ,
@@ -1232,7 +1240,9 @@
String.Doc ,
String.Interpol ,
String.Long ,
+ String.Long.Internal ,
String.Short ,
+ String.Short.Internal ,
Tag ,
TypeParameter ,
UserFunction ,
@@ -1277,49 +1287,83 @@
\sort_return_same:
\sort_return_swapped:
}
-\cs_set_eq:NN \__piton_break_anywhere:n \prg_do_nothing:
+\cs_set_eq:NN \__piton_break_strings_anywhere:n \prg_do_nothing:
+
+\cs_set_eq:NN \__piton_break_numbers_anywhere:n \prg_do_nothing:
+
\cs_new_protected:Npn \__piton_actually_break_anywhere:n #1
{
- \seq_clear:N \l_tmpa_seq
- \tl_map_inline:nn { #1 }
+ \tl_set:Nn \l_tmpa_tl { #1 }
+ \regex_replace_all:nnN { \x20 } { \c { space } } \l_tmpa_tl
+ \tl_map_inline:Nn \l_tmpa_tl
{ \seq_put_right:Nn \l_tmpa_seq { ##1 } }
\seq_use:Nn \l_tmpa_seq { \- }
}
+\cs_new_protected:Npn \__piton_string_long:n #1
+ {
+ \PitonStyle { String.Long }
+ {
+ \bool_if:NT \l__piton_break_strings_anywhere_bool
+ { \__piton_actually_break_anywhere:n }
+ { #1 }
+ }
+ }
+\cs_new_protected:Npn \__piton_string_short:n #1
+ {
+ \PitonStyle { String.Short }
+ {
+ \bool_if:NT \l__piton_break_strings_anywhere_bool
+ { \__piton_actually_break_anywhere:n }
+ { #1 }
+ }
+ }
+\cs_new_protected:Npn \__piton_number:n #1
+ {
+ \PitonStyle { Number }
+ {
+ \bool_if:NT \l__piton_break_numbers_anywhere_bool
+ { \__piton_actually_break_anywhere:n }
+ { #1 }
+ }
+ }
\SetPitonStyle
{
- Comment = \color[HTML]{0099FF} \itshape ,
- Exception = \color[HTML]{CC0000} ,
- Keyword = \color[HTML]{006699} \bfseries ,
- Keyword.Governing = \color[HTML]{006699} \bfseries ,
- Keyword.Constant = \color[HTML]{006699} \bfseries ,
- Name.Builtin = \color[HTML]{336666} ,
- Name.Decorator = \color[HTML]{9999FF},
- Name.Class = \color[HTML]{00AA88} \bfseries ,
- Name.Function = \color[HTML]{CC00FF} ,
- Name.Namespace = \color[HTML]{00CCFF} ,
- Name.Constructor = \color[HTML]{006000} \bfseries ,
- Name.Field = \color[HTML]{AA6600} ,
- Name.Module = \color[HTML]{0060A0} \bfseries ,
- Name.Table = \color[HTML]{309030} ,
- Number = \color[HTML]{FF6600} ,
- Operator = \color[HTML]{555555} ,
- Operator.Word = \bfseries ,
- String = \color[HTML]{CC3300} \__piton_break_anywhere:n ,
- String.Doc = \color[HTML]{CC3300} \itshape ,
- String.Interpol = \color[HTML]{AA0000} ,
- Comment.LaTeX = \normalfont \color[rgb]{.468,.532,.6} ,
- Name.Type = \color[HTML]{336666} ,
- InitialValues = \__piton_piton:n ,
- Interpol.Inside = \l__piton_font_command_tl \__piton_piton:n ,
- TypeParameter = \color[HTML]{336666} \itshape ,
- Preproc = \color[HTML]{AA6600} \slshape ,
- Identifier.Internal = \__piton_identifier:n ,
- Identifier = ,
- Directive = \color[HTML]{AA6600} ,
- Tag = \colorbox{gray!10},
- UserFunction = \PitonStyle{Identifier} ,
- Prompt = ,
- Discard = \use_none:n
+ Comment = \color[HTML]{0099FF} \itshape ,
+ Exception = \color[HTML]{CC0000} ,
+ Keyword = \color[HTML]{006699} \bfseries ,
+ Keyword.Governing = \color[HTML]{006699} \bfseries ,
+ Keyword.Constant = \color[HTML]{006699} \bfseries ,
+ Name.Builtin = \color[HTML]{336666} ,
+ Name.Decorator = \color[HTML]{9999FF},
+ Name.Class = \color[HTML]{00AA88} \bfseries ,
+ Name.Function = \color[HTML]{CC00FF} ,
+ Name.Namespace = \color[HTML]{00CCFF} ,
+ Name.Constructor = \color[HTML]{006000} \bfseries ,
+ Name.Field = \color[HTML]{AA6600} ,
+ Name.Module = \color[HTML]{0060A0} \bfseries ,
+ Name.Table = \color[HTML]{309030} ,
+ Number = \color[HTML]{FF6600} ,
+ Number.Internal = \__piton_number:n ,
+ Operator = \color[HTML]{555555} ,
+ Operator.Word = \bfseries ,
+ String = \color[HTML]{CC3300} ,
+ String.Long.Internal = \__piton_string_long:n ,
+ String.Short.Internal = \__piton_string_short:n ,
+ String.Doc = \color[HTML]{CC3300} \itshape ,
+ String.Interpol = \color[HTML]{AA0000} ,
+ Comment.LaTeX = \normalfont \color[rgb]{.468,.532,.6} ,
+ Name.Type = \color[HTML]{336666} ,
+ InitialValues = \__piton_piton:n ,
+ Interpol.Inside = \l__piton_font_command_tl \__piton_piton:n ,
+ TypeParameter = \color[HTML]{336666} \itshape ,
+ Preproc = \color[HTML]{AA6600} \slshape ,
+ Identifier.Internal = \__piton_identifier:n ,
+ Identifier = ,
+ Directive = \color[HTML]{AA6600} ,
+ Tag = \colorbox{gray!10},
+ UserFunction = \PitonStyle{Identifier} ,
+ Prompt = ,
+ Discard = \use_none:n
}
\hook_gput_code:nnn { begindocument } { . }
{
@@ -1515,6 +1559,7 @@
break-lines,~
break-lines-in-piton,~
break-lines-in-Piton,~
+ break-numbers-anywhere,~
break-strings-anywhere,~
continuation-symbol,~
continuation-symbol-on-indentation,~
More information about the tex-live-commits
mailing list.