diff options
author | Karl Berry <karl@freefriends.org> | 2024-02-20 21:06:38 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-02-20 21:06:38 +0000 |
commit | 471a2887f5b80d1b2e0d57597da9deb373b3555d (patch) | |
tree | 5c4bd26d9f1f03ebf290d4a72dd0f1747c79e4e5 /Master/texmf-dist/source | |
parent | ada48533443e464235c29c5b9a4809dbdf703728 (diff) |
piton (20feb24)
git-svn-id: svn://tug.org/texlive/trunk@70024 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r-- | Master/texmf-dist/source/lualatex/piton/piton.dtx | 113 |
1 files changed, 74 insertions, 39 deletions
diff --git a/Master/texmf-dist/source/lualatex/piton/piton.dtx b/Master/texmf-dist/source/lualatex/piton/piton.dtx index 5140de4af2a..17333c50dcd 100644 --- a/Master/texmf-dist/source/lualatex/piton/piton.dtx +++ b/Master/texmf-dist/source/lualatex/piton/piton.dtx @@ -72,12 +72,12 @@ % \iffalse %<*STY> % \fi -\def\PitonFileVersion{2.4} -\def\PitonFileDate{2024/01/15} +\def\PitonFileVersion{2.5} +\def\PitonFileDate{2024/02/20} % \iffalse %</STY> %<*LUA> --- Version 2.4 of 2024/01/15 +-- Version 2.5 of 2024/02/20 %</LUA> %\fi % @@ -213,9 +213,8 @@ % It's possible to insert only a part of the file: cf. % part~\ref{part-of-a-file}, p.~\pageref{part-of-a-file}. % -% \colorbox{yellow!50}{\textbf{New 2.2}}\enskip The key |path| of the command -% |\PitonOptions| specifies a path where the files included by |\PitonInputFile| -% will be searched. +% The key |path| of the command |\PitonOptions| specifies a path where the files +% included by |\PitonInputFile| will be searched. % \end{itemize} % % \subsection{The syntax of the command \textbackslash piton} @@ -331,8 +330,8 @@ % considered (that key is case-insensitive). Five values are allowed : % |Python|, |OCaml|, |C|, |SQL| and |minimal|. The initial value is |Python|. % -% \item \index{path} The key \Definition{path} specifies a path where the files included by -% |\PitonInputFile| will be searched. +% \item \index{path} The key \Definition{path} specifies a path where the files +% included by |\PitonInputFile| will be searched. % % \item \index{gobble} The key \Definition{gobble} takes in as value a % positive integer~$n$: the first $n$ characters are discarded (before the @@ -360,6 +359,10 @@ % and write the content of the current environment in that file. At the first % use of a file by \pkg{piton}, it is erased. % +% \item \index{path-write}\colorbox{yellow!50}{\bfseries New 2.5}\enskip The key +% \Definition{path-write} specifies a path where the files written by the key +% |write| will be written. +% % \item \index{line-numbers} The key \Definition{line-numbers} activates the % line numbering in the environments |{Piton}| and in the listings resulting % from the use of |\PitonInputFile|. @@ -610,11 +613,11 @@ % informatic language they use (Python, C, OCaml, etc.). % % \bigskip -% \colorbox{yellow!50}{\textbf{New 2.2}}\enskip But it's also possible to define -% a style locally for a given informatic langage by providing the name of that -% language as optional argument (between square brackets) to the command -% |\SetPitonStyle|.\footnote{We recall, that, in the package \pkg{piton}, the -% names of the informatic languages are case-insensitive.} +% But it's also possible to define a style locally for a given informatic +% langage by providing the name of that language as optional argument (between +% square brackets) to the command |\SetPitonStyle|.\footnote{We recall, that, in +% the package \pkg{piton}, the names of the informatic languages are +% case-insensitive.} % % \bigskip % For example, with the command @@ -1009,7 +1012,7 @@ % identifiers. % % \smallskip -% That command takes in three arguments: one +% That command takes in three arguments: % % \begin{itemize} % \item The optionnal argument (within square brackets) specifies the informatic @@ -1216,7 +1219,7 @@ % \item The key |detected-commands| must be used in the preamble of the LaTeX document. % % \item The names of the LaTeX commands must appear without the leading -% backslash (eg. |detected-commands = { emph, bfseries }|). +% backslash (eg. |detected-commands = { emph, textbf }|). % % \item These commands must be LaTeX commands with only one (mandatory) argument % between braces (and these braces must be explicit). @@ -2509,7 +2512,7 @@ % \end{macrocode} % % \medskip -% The following boolean corresponds to the key |math-comments| (only at load-time). +% The following boolean corresponds to the key |math-comments| (available only at load-time). % \begin{macrocode} \bool_new:N \g_@@_math_comments_bool % \end{macrocode} @@ -2681,9 +2684,19 @@ % \end{macrocode} % % \medskip +% The following parameter corresponds to the key |path| (which is the path used +% to include files by |\PitonInputFile|). % \begin{macrocode} \str_new:N \l_@@_path_str % \end{macrocode} +% +% \medskip +% The following parameter corresponds to the key |path-write| (which is the path +% used when writing files from listings inserted in the environments of +% \pkg{piton} by use of the key |write|). +% \begin{macrocode} +\str_new:N \l_@@_path_write_str +% \end{macrocode} % % \medskip % In order to have a better control over the keys. @@ -3417,7 +3430,7 @@ comment-latex .value_required:n = true , comment-latex .usage:n = preamble , - math-comments .bool_set:N = \g_@@_math_comments_bool , + math-comments .bool_gset:N = \g_@@_math_comments_bool , math-comments .default:n = true , math-comments .usage:n = preamble , % \end{macrocode} @@ -3430,6 +3443,8 @@ language .value_required:n = true , path .str_set:N = \l_@@_path_str , path .value_required:n = true , + path-write .str_set:N = \l_@@_path_write_str , + path-write .value_required:n = true , gobble .int_set:N = \l_@@_gobble_int , gobble .value_required:n = true , auto-gobble .code:n = \int_set:Nn \l_@@_gobble_int { -1 } , @@ -3958,7 +3973,12 @@ % % Now, the key |write|. % \begin{macrocode} - \lua_now:e { piton.write = "\l_@@_write_str" } + \str_if_empty:NTF \l_@@_path_write_str + { \lua_now:e { piton.write = "\l_@@_write_str" } } + { + \lua_now:e + { piton.write = "\l_@@_path_write_str / \l_@@_write_str" } + } \str_if_empty:NF \l_@@_write_str { \seq_if_in:NVTF \g_@@_write_seq \l_@@_write_str @@ -3968,7 +3988,7 @@ \seq_gput_left:NV \g_@@_write_seq \l_@@_write_str } } - \vtop \bgroup + \vbox \bgroup \lua_now:e { piton.GobbleParse @@ -3980,7 +4000,7 @@ } { ##1 } \vspace { 2.5 pt } - \egroup + \egroup \bool_if:NT \g_@@_footnote_bool { \end { savenotes } } % \end{macrocode} % If the user has used the key |width| with the special value~|min|, we write on @@ -4234,7 +4254,7 @@ % \medskip % \begin{macrocode} \cs_new_protected:Npn \@@_math_scantokens:n #1 - { \normalfont \scantextokens { $#1$ } } + { \normalfont \scantextokens { \begin{math} #1 \end{math} } } % \end{macrocode} % % \medskip @@ -4294,12 +4314,10 @@ \keys_define:nn { piton / Styles } { String .meta:n = { String.Long = #1 , String.Short = #1 } , - Comment.Math .tl_set:c = pitonStyle Comment.Math , - Comment.Math .default:n = \@@_math_scantokens:n , - Comment.Math .initial:n = , - ParseAgain .tl_set:c = pitonStyle ParseAgain , + Comment.Math .tl_set:c = pitonStyle _ Comment.Math , + ParseAgain .tl_set:c = pitonStyle _ ParseAgain , ParseAgain .value_required:n = true , - ParseAgain.noCR .tl_set:c = pitonStyle ParseAgain.noCR , + ParseAgain.noCR .tl_set:c = pitonStyle _ ParseAgain.noCR , ParseAgain.noCR .value_required:n = true , unknown .code:n = \@@_error:n { Unknown~key~for~SetPitonStyle } @@ -4377,7 +4395,11 @@ % However, maybe we will document in a future version the possibility to write % change the style \emph{locally} in a document)]. % \begin{macrocode} -\bool_if:NT \g_@@_math_comments_bool { \SetPitonStyle { Comment.Math } } +\AtBeginDocument + { + \bool_if:NT \g_@@_math_comments_bool + { \SetPitonStyle { Comment.Math = \@@_math_scantokens:n } } + } % \end{macrocode} % % \bigskip @@ -4638,7 +4660,7 @@ % \begin{macrocode} \@@_msg_new:nn { syntax~error } { - Your~code~\l_piton_language_str\ is~not~syntactically~correct.\\ + Your~code~of~the~language~"\l_piton_language_str"~is~not~syntactically~correct.\\ It~won't~be~printed~in~the~PDF~file. } % \end{macrocode} @@ -4715,15 +4737,17 @@ left-margin,~ line-numbers/,~ marker/,~ + math-comments,~ path,~ + path-write,~ prompt-background-color,~ resume,~ show-spaces,~ show-spaces-in-strings,~ splittable,~ tabs-auto-gobble,~ - tab-size,~width~ - and~write. + tab-size,~ + width~and~write. } % \end{macrocode} % @@ -4784,10 +4808,13 @@ \directlua { lpeg.locale(lpeg) - local P , alpha , C , Cf, space = lpeg.P , lpeg.alpha , lpeg.C , lpeg.Cf , lpeg.space - local One_P = space ^ 0 - * C ( alpha ^ 1 ) / ( function (s) return P ( string.char(92) .. s ) end ) - * space ^ 0 + local P , alpha , C , Cf, space + = lpeg.P , lpeg.alpha , lpeg.C , lpeg.Cf , lpeg.space + local S = lpeg.S + local One_P + = space ^ 0 + * C ( alpha ^ 1 ) / ( function (s) return P ( string.char(92) .. s ) end ) + * space ^ 0 function piton.addListCommands( key_value ) piton.ListCommands = piton.ListCommands + @@ -5014,10 +5041,10 @@ local Number = % corresponding to the keys |begin-escape| and |end-escape|. % \begin{macrocode} local Word -if piton.begin_escape ~= nil -- before : '' +if piton.begin_escape ~= nil then Word = Q ( ( ( 1 - space - P(piton.begin_escape) - P(piton.end_escape) ) - - S "'\"\r[()]" - digit ) ^ 1 ) -else Word = Q ( ( ( 1 - space ) - S "'\"\r[()]" - digit ) ^ 1 ) + - S "'\"\r[({})]" - digit ) ^ 1 ) +else Word = Q ( ( ( 1 - space ) - S "'\"\r[({})]" - digit ) ^ 1 ) end % \end{macrocode} % @@ -5040,7 +5067,7 @@ local SpaceIndentation = Lc ( '\\@@_an_indentation_space:' ) * ( Q " " ) % % \bigskip % \begin{macrocode} -local Delim = Q ( S "[()]" ) +local Delim = Q ( S "[({})]" ) % \end{macrocode} % % \bigskip @@ -5911,7 +5938,7 @@ local OperatorWord = local Keyword = K ( 'Keyword' , - P "assert" + P "as" + P "begin" + P "class" + P "constraint" + P "done" + P "assert" + P "and" + P "as" + P "begin" + P "class" + P "constraint" + P "done" + P "downto" + P "do" + P "else" + P "end" + P "exception" + P "external" + P "for" + P "function" + P "functor" + P "fun" + P "if" + P "include" + P "inherit" + P "initializer" + P "in" + P "lazy" + P "let" @@ -7029,6 +7056,8 @@ languages['sql'] = languageSQL % \subsubsection{The LPEG language Minimal} % % \begin{macrocode} +local Punct = Q ( S ",:;!\\" ) + local CommentMath = P "$" * K ( 'Comment.Math' , ( 1 - S "$\r" ) ^ 1 ) * P "$" @@ -7155,6 +7184,8 @@ local identifier = letter * alphanum ^ 0 local Identifier = K ( 'Identifier' , identifier ) +local Delim = Q ( S "{[()]}" ) + local MainMinimal = EOL + Space @@ -7559,6 +7590,10 @@ end % % \verb|https://github.com/fpantigny/piton| % +% \subsection*{Changes between versions 2.4 and 2.5} +% +% New key |path-write| +% % \subsection*{Changes between versions 2.3 and 2.4} % % The key |identifiers| of the command |\PitonOptions| is now deprecated and |