summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/piton/piton.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/latex/piton/piton.dtx')
-rw-r--r--macros/luatex/latex/piton/piton.dtx361
1 files changed, 238 insertions, 123 deletions
diff --git a/macros/luatex/latex/piton/piton.dtx b/macros/luatex/latex/piton/piton.dtx
index aa149d78e9..e308e226b9 100644
--- a/macros/luatex/latex/piton/piton.dtx
+++ b/macros/luatex/latex/piton/piton.dtx
@@ -72,12 +72,12 @@
% \iffalse
%<*STY>
% \fi
-\def\PitonFileVersion{2.6b}
-\def\PitonFileDate{2024/03/18}
+\def\PitonFileVersion{2.7}
+\def\PitonFileDate{2024/03/24}
% \iffalse
%</STY>
%<*LUA>
-piton_version = "2.6b" -- 2024/03/18
+piton_version = "2.7" -- 2024/03/24
%</LUA>
%\fi
%
@@ -146,21 +146,19 @@ piton_version = "2.6b" -- 2024/03/18
%
% \section{Use of the package}
%
+% The package \pkg{piton} must be used with LuaLaTeX exclusively: if another
+% LaTeX engine (|latex|, |pdflatex|, |xelatex|,\dots ) is used, a fatal error
+% will be raised.
+%
% \subsection{Loading the package}
%
-% The package \pkg{piton} should be loaded with the classical command
-% |\usepackage|: |\usepackage{piton}|.
+% The package \pkg{piton} should be loaded by: |\usepackage{piton}|.
%
% \smallskip
-% Nevertheless, we have two remarks:
-% \begin{itemize}
-% \item the package \pkg{piton} uses the package \pkg{xcolor} (but \pkg{piton}
-% does \emph{not} load \pkg{xcolor}: if \pkg{xcolor} is not loaded before the
-% |\begin{document}|, a fatal error will be raised).
-% \item the package \pkg{piton} must be used with LuaLaTeX exclusively: if
-% another LaTeX engine (|latex|, |pdflatex|, |xelatex|,\dots ) is used, a
-% fatal error will be raised.
-% \end{itemize}
+% If, at the end of the preamble, the package \pkg{xcolor} has not been loaded
+% (by the final user or by another package), \pkg{piton} loads \pkg{xcolor} with
+% the instruction |\usepackage{xcolor}| (that is to say without any option).
+% The package \pkg{piton} doesn't load any other package.
%
% \subsection{Choice of the computer language}
%
@@ -805,6 +803,23 @@ piton_version = "2.6b" -- 2024/03/18
% 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}.}
+%
+% \bigskip
+% \colorbox{yellow!50}{\textbf{New 6.27}}\enskip The extension \pkg{piton}
+% provides a key \Definition{split-on-empty-lines}. When that key is in force,
+% the listings are split in chunks on the empty lines\footnote{The ``empty
+% lines'' are the lines which contain only spaces} of the code and each chunk is
+% treated by \pkg{piton} as an independent listing before being sent to LaTeX.
+% Thus, \textbf{LaTeX is able to add page breaks between the chunks}. If the key
+% |splittable| is used, it's active in each chunk. Of course, the utilisation of
+% both |split-on-empty-lines| and |splittable| makes sens if the key
+% |splittable| with a value different of 1 (for instance 4), so that the pages
+% breaks are prioritised on the empty lines of the original listing.
+%
+% \smallskip
+% The key \Definition{split-separation} specifies a list of LaTeX tokens that
+% will be inserted between the chunks. For example :
+% |\PitonOptions{split-separation = \hrule\goodbreak}|.
%
% \subsubsection{Line breaks}
%
@@ -2593,31 +2608,18 @@ piton_version = "2.6b" -- 2024/03/18
%
% \bigskip
% \begin{macrocode}
-\@ifclassloaded { beamer } { \bool_gset_true:N \g_@@_beamer_bool } { }
-\@ifpackageloaded { beamerarticle } { \bool_gset_true:N \g_@@_beamer_bool } { }
+\IfClassLoadedTF { beamer } { \bool_gset_true:N \g_@@_beamer_bool } { }
+\IfPackageLoadedTF { beamerarticle } { \bool_gset_true:N \g_@@_beamer_bool } { }
\lua_now:n { piton = piton~or~{ } }
\bool_if:NT \g_@@_beamer_bool { \lua_now:n { piton.beamer = true } }
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
-\hook_gput_code:nnn { begindocument } { . }
- {
- \@ifpackageloaded { xcolor }
- { }
- { \msg_fatal:nn { piton } { xcolor~not~loaded } }
- }
+\hook_gput_code:nnn { begindocument / before } { . }
+ { \IfPackageLoadedTF { xcolor } { } { \usepackage { xcolor } } }
% \end{macrocode}
%
-% \begin{macrocode}
-\@@_msg_new:nn { xcolor~not~loaded }
- {
- xcolor~not~loaded \\
- The~package~'xcolor'~is~required~by~'piton'.\\
- This~error~is~fatal.
- }
-% \end{macrocode}
-%
%
% \begin{macrocode}
\@@_msg_new:nn { footnote~with~footnotehyper~package }
@@ -2652,10 +2654,10 @@ piton_version = "2.6b" -- 2024/03/18
% The class \cls{beamer} has its own system to extract footnotes and that's why
% we have nothing to do if \cls{beamer} is used.
% \begin{macrocode}
- \@ifclassloaded { beamer }
+ \IfClassLoadedTF { beamer }
{ \bool_gset_false:N \g_@@_footnote_bool }
{
- \@ifpackageloaded { footnotehyper }
+ \IfPackageLoadedTF { footnotehyper }
{ \@@_error:n { footnote~with~footnotehyper~package } }
{ \usepackage { footnote } }
}
@@ -2669,10 +2671,10 @@ piton_version = "2.6b" -- 2024/03/18
% The class \cls{beamer} has its own system to extract footnotes and that's why
% we have nothing to do if \cls{beamer} is used.
% \begin{macrocode}
- \@ifclassloaded { beamer }
+ \IfClassLoadedTF { beamer }
{ \bool_gset_false:N \g_@@_footnote_bool }
{
- \@ifpackageloaded { footnote }
+ \IfPackageLoadedTF { footnote }
{ \@@_error:n { footnotehyper~with~footnote~package } }
{ \usepackage { footnotehyper } }
\bool_gset_true:N \g_@@_footnote_bool
@@ -2769,12 +2771,21 @@ piton_version = "2.6b" -- 2024/03/18
% \end{macrocode}
%
% \medskip
+% When the key |split-on-empty-lines| will be in force, then the following token
+% list will be inserted between the chunks of code (the informatic code provided
+% by the final user is split in chunks on the empty lines in the code).
+% \begin{macrocode}
+\tl_new:N \l_@@_split_separation_tl
+% \end{macrocode}
+%
+% \medskip
% An initial value of |splittable| equal to 100 is equivalent to say that the
% environments |{Piton}| are unbreakable.
% \begin{macrocode}
\int_set:Nn \l_@@_splittable_int { 100 }
% \end{macrocode}
%
+%
% \medskip
% The following string corresponds to the key |background-color| of |\PitonOptions|.
% \begin{macrocode}
@@ -3361,6 +3372,7 @@ piton_version = "2.6b" -- 2024/03/18
\bool_set_true:N \l_@@_label_empty_lines_bool
\int_new:N \l_@@_number_lines_start_int
\bool_new:N \l_@@_resume_bool
+\bool_new:N \l_@@_split_on_empty_lines_bool
% \end{macrocode}
%
%
@@ -3445,12 +3457,14 @@ piton_version = "2.6b" -- 2024/03/18
% \begin{macrocode}
\keys_define:nn { PitonOptions }
{
+% \end{macrocode}
+% First, we put keys that should be avalaible only in the preamble.
+% \begin{macrocode}
detected-commands .code:n =
\lua_now:n { piton.addListCommands('#1') } ,
detected-commands .value_required:n = true ,
detected-commands .usage:n = preamble ,
% \end{macrocode}
-% First, we put keys that should be avalaible only in the preamble.
%
% Remark that the command |\lua_escape:n| is fully expandable. That's why we use
% |\lua_now:e|.
@@ -3502,6 +3516,12 @@ piton_version = "2.6b" -- 2024/03/18
env-gobble .value_forbidden:n = true ,
tabs-auto-gobble .code:n = \int_set:Nn \l_@@_gobble_int { -3 } ,
tabs-auto-gobble .value_forbidden:n = true ,
+
+ split-on-empty-lines .bool_set:N = \l_@@_split_on_empty_lines_bool ,
+ split-on-empty-lines .default:n = true ,
+
+ split-separation .tl_set:N = \l_@@_split_separation_tl ,
+ split-separation .value_required:n = true ,
marker .code:n =
\bool_lazy_or:nnTF
@@ -4016,7 +4036,8 @@ piton_version = "2.6b" -- 2024/03/18
% \end{macrocode}
% We count with Lua the number of lines of the argument. The result will be
% stored by Lua in |\l_@@_nb_lines_int|. That information will be used to allow
-% or disallow page breaks. We use the technic of |token.scan_argument| for optimisation.
+% or disallow page breaks. The use of |token.scan_argument| avoids problems with
+% the delimiters of the Lua string.
% \begin{macrocode}
\lua_now:n { piton.CountLines(token.scan_argument()) } { ##1 }
% \end{macrocode}
@@ -4028,11 +4049,6 @@ piton_version = "2.6b" -- 2024/03/18
\ttfamily
\dim_zero:N \parskip
% \end{macrocode}
-% |\g_@@_footnote_bool| is raised when the package \pkg{piton} has been loaded
-% with the key |footnote| \emph{or} the key |footnotehyper|.
-% \begin{macrocode}
- \bool_if:NT \g_@@_footnote_bool { \savenotes }
-% \end{macrocode}
%
% Now, the key |write|.
% \begin{macrocode}
@@ -4051,24 +4067,16 @@ piton_version = "2.6b" -- 2024/03/18
\seq_gput_left:NV \g_@@_write_seq \l_@@_write_str
}
}
- \vtop \bgroup % modified 2024/03/02
% \end{macrocode}
-% Now, the main job. We use |token.scan_argument()| for optimisation.
+% \bigskip
+% Now, the main job.
% \begin{macrocode}
- \lua_now:e
- {
- piton.GobbleParse
- (
- '\l_piton_language_str' ,
- \int_use:N \l_@@_gobble_int ,
- token.scan_argument ( )
- )
- }
+ \bool_if:NTF \l_@@_split_on_empty_lines_bool
+ \@@_gobble_split_parse:n
+ \@@_gobble_parse:n
{ ##1 }
- \vspace { 2.5 pt }
- \egroup
- \bool_if:NT \g_@@_footnote_bool { \endsavenotes }
% \end{macrocode}
+%
% If the user has used the key |width| with the special value~|min|, we write on
% the |aux| file the value of |\l_@@_line_width_dim| (largest width of the lines
% of code of the environment).
@@ -4118,6 +4126,45 @@ piton_version = "2.6b" -- 2024/03/18
% This is the end of the definition of the command |\NewPitonEnvironment|.
%
% \bigskip
+% The following function will be used when the key |split-on-empty-lines| is not
+% in force. It will gobble the spaces at the beginning of the lines and parse
+% the code. The argument is provided by curryfication.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_gobble_parse:n
+ {
+ \lua_now:e
+ {
+ piton.GobbleParse
+ (
+ '\l_piton_language_str' ,
+ \int_use:N \l_@@_gobble_int ,
+ token.scan_argument ( )
+ )
+ }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% The following function will be used when the key |split-on-empty-lines| is in
+% force. It will gobble the spaces at the beginning of the lines (if the key
+% |gobble| is in force), then split the code at the empty lines and, eventually,
+% parse the code. The argument is provided by curryfication.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_gobble_split_parse:n
+ {
+ \lua_now:e
+ {
+ piton.GobbleSplitParse
+ (
+ '\l_piton_language_str' ,
+ \int_use:N \l_@@_gobble_int ,
+ token.scan_argument ( )
+ )
+ }
+ }
+% \end{macrocode}
+%
+% \bigskip
% Now, we define the environment |{Piton}|, which is the main environment
% provided by the package \pkg{piton}. Of course, you use
% |\NewPitonEnvironment|.
@@ -4827,6 +4874,8 @@ piton_version = "2.6b" -- 2024/03/18
show-spaces,~
show-spaces-in-strings,~
splittable,~
+ split-on-empty-lines,~
+ split-separation,~
tabs-auto-gobble,~
tab-size,~
width~and~write.
@@ -4889,7 +4938,8 @@ piton_version = "2.6b" -- 2024/03/18
{
require ( "piton" )
tex.sprint ( luatexbase.catcodetables.CatcodeTableExpl ,
- "\\@@_test_version:n {" .. piton_version .. "}" )
+ "\\@@_test_version:n {" .. piton_version .. "}" )
+
}
}
% \end{macrocode}
@@ -4997,7 +5047,7 @@ end
% that string. The elements captured will be formatted as L3 code. It will be
% used to send to LaTeX all the formatting LaTeX instructions we have to insert
% in order to do the syntactic highlighting (that's the main job of
-% \pkg{piton}). That function will be widely used.
+% \pkg{piton}). That function, unlike the previous one, will be widely used.
% \begin{macrocode}
local function Lc ( string )
return Cc ( { luatexbase.catcodetables.expl , string } )
@@ -5258,7 +5308,8 @@ local BeamerEndEnvironments = P ( true )
% \bigskip
% \begin{macrocode}
local list_beamer_env =
- { "uncoverenv" , "onlyenv" , "visibleenv" , "invisibleenv" , "alertenv" , "actionenv" }
+ { "uncoverenv" , "onlyenv" , "visibleenv" ,
+ "invisibleenv" , "alertenv" , "actionenv" }
% \end{macrocode}
%
% \bigskip
@@ -5393,7 +5444,7 @@ local CommentMath =
% |\@@_begin_line:|, it's too late to change de background).
% \begin{macrocode}
local PromptHastyDetection =
- ( # ( P ">>>" + "..." ) * Lc ( '\\@@_prompt:' ) ) ^ -1
+ ( # ( P ">>>" + "..." ) * Lc '\\@@_prompt:' ) ^ -1
% \end{macrocode}
% We remind that the marker |#| of \textsc{lpeg} specifies that the pattern will be
% detected but won't consume any character.
@@ -5857,7 +5908,7 @@ local Params =
F = SkipSpace * ( Identifier + Q "*args" + Q "**kwargs" ) * SkipSpace
* (
K ( 'InitialValues' , "=" * expression )
- + Q ":" * SkipSpace * K ( 'Name.Type' , letter ^ 1 )
+ + Q ":" * SkipSpace * K ( 'Name.Type' , identifier )
) ^ -1
}
% \end{macrocode}
@@ -6030,7 +6081,9 @@ local OneFieldDefinition =
local OneField =
K ( 'Name.Field' , identifier ) * SkipSpace
* Q "=" * SkipSpace
- * ( expression_for_fields / ( function ( s ) return LPEG1['ocaml'] : match ( s ) end ) )
+ * ( expression_for_fields
+ / ( function ( s ) return LPEG1['ocaml'] : match ( s ) end )
+ )
* SkipSpace
local Record =
@@ -6782,11 +6835,11 @@ LPEG2['sql'] =
Ct (
( space ^ 0 * "\r" ) ^ -1
* BeamerBeginEnvironments
- * Lc '\\@@_begin_line:'
+ * Lc [[ \@@_begin_line: ]]
* SpaceIndentation ^ 0
* LPEG1['sql']
* -1
- * Lc '\\@@_end_line:'
+ * Lc [[ \@@_end_line: ]]
)
% \end{macrocode}
%
@@ -6848,11 +6901,11 @@ LPEG2['minimal'] =
Ct (
( space ^ 0 * "\r" ) ^ -1
* BeamerBeginEnvironments
- * Lc '\\@@_begin_line:'
+ * Lc [[ \@@_begin_line: ]]
* SpaceIndentation ^ 0
* LPEG1['minimal']
* -1
- * Lc '\\@@_end_line:'
+ * Lc [[ \@@_end_line: ]]
)
% \bigskip
@@ -6871,8 +6924,8 @@ function piton.Parse ( language , code )
local t = LPEG2[language] : match ( code )
if t == nil
then
- tex.sprint(luatexbase.catcodetables.CatcodeTableExpl,
- "\\@@_error:n { syntax~error }")
+ tex.sprint( luatexbase.catcodetables.CatcodeTableExpl,
+ [[ \@@_error:n { syntax~error } ]] )
return -- to exit in force the function
end
local left_stack = {}
@@ -6977,7 +7030,7 @@ end
% that have been inserted when the key |break-lines| is in force.
% \begin{macrocode}
function piton.ParseTer ( language , code )
- local s = ( Cs ( ( P '\\@@_breakable_space:' / ' ' + 1 ) ^ 0 ) )
+ local s = ( Cs ( ( P [[ \@@_breakable_space: ]] / ' ' + 1 ) ^ 0 ) )
: match ( code )
return piton.Parse ( language , s )
end
@@ -6990,26 +7043,6 @@ end
% We deal now with preprocessors of the function |Parse| which are needed when
% the ``gobble mechanism'' is used.
%
-%
-% \bigskip
-% The function |gobble| gobbles $n$ characters on the left of the code. It uses
-% a \textsc{lpeg} that we have to compute dynamically because if depends on the
-% value of~$n$.
-% \begin{macrocode}
-local function gobble ( n , code )
- if n == 0
- then return code
- else return
- ( Ct (
- ( 1 - P "\r" ) ^ (-n) * C ( ( 1 - P "\r" ) ^ 0 )
- * ( C "\r" * ( 1 - P "\r" ) ^ (-n) * C ( ( 1 - P "\r" ) ^ 0 )
- ) ^ 0 )
- / table.concat
- ) : match ( code )
- end
-end
-% \end{macrocode}
-%
%
% \bigskip
% The following \textsc{lpeg} returns as capture the minimal number of spaces at
@@ -7053,8 +7086,7 @@ local EnvGobbleLPEG =
( ( 1 - P "\r" ) ^ 0 * "\r" ) ^ 0
* Ct ( C " " ^ 0 * -1 ) / table.getn
% \end{macrocode}
-%
-% \bigskip
+%
% \begin{macrocode}
local function remove_before_cr ( input_string )
local match_result = ( P "\r" ) : match ( input_string )
@@ -7068,23 +7100,58 @@ end
% \end{macrocode}
%
% \bigskip
+% The function |gobble| gobbles $n$ characters on the left of the code. The
+% negative values of $n$ have special significations.
+% \begin{macrocode}
+local function gobble ( n , code )
+ code = remove_before_cr ( code )
+ if n == 0 then
+ return code
+ else
+ if n == -1 then
+ n = AutoGobbleLPEG : match ( code )
+ else
+ if n == -2 then
+ n = EnvGobbleLPEG : match ( code )
+ else
+ if n == -3 then
+ n = TabsAutoGobbleLPEG : match ( code )
+ end
+ end
+ end
+% \end{macrocode}
+% We will now use a \textsc{lpeg} that we have to compute dynamically because it
+% depends on the value of~$n$.
+% \begin{macrocode}
+ return
+ ( Ct (
+ ( 1 - P "\r" ) ^ (-n) * C ( ( 1 - P "\r" ) ^ 0 )
+ * ( C "\r" * ( 1 - P "\r" ) ^ (-n) * C ( ( 1 - P "\r" ) ^ 0 )
+ ) ^ 0 )
+ / table.concat
+ ) : match ( code )
+ end
+end
+% \end{macrocode}
+%
+%
+% \bigskip
+%
+% \bigskip
% In the following code, |n| is the value of |\l_@@_gobble_int|.
% \begin{macrocode}
function piton.GobbleParse ( language , n , code )
- code = remove_before_cr ( code )
- if n == -1
- then n = AutoGobbleLPEG : match ( code )
- else if n == -2
- then n = EnvGobbleLPEG : match ( code )
- else if n == -3
- then n = TabsAutoGobbleLPEG : match ( code )
- end
- end
- end
piton.last_code = gobble ( n , code )
- piton.Parse ( language , piton.last_code )
piton.last_language = language
% \end{macrocode}
+% \begin{macrocode}
+ tex.sprint(luatexbase.catcodetables.CatcodeTableExpl ,
+ [[ \bool_if:NT \g_@@_footnote_bool \savenotes \vtop \bgroup ]] )
+ piton.Parse ( language , piton.last_code )
+ tex.sprint(luatexbase.catcodetables.CatcodeTableExpl ,
+ [[ \vspace { 2.5 pt } \egroup \bool_if:NT \g_@@_footnote_bool \endsavenotes \par ]] )
+% \end{macrocode}
+%
% Now, if the final user has used the key |write| to write the code of the
% environment on an external file.
% \begin{macrocode}
@@ -7097,6 +7164,50 @@ end
% \end{macrocode}
%
% \bigskip
+% The function |GobbleParsePar| is merely the function |GobbleParse| with the
+% insertion of a |\par| in the TeX flow after.
+% \begin{macrocode}
+local function GobbleParsePar ( language , n , code )
+ piton.GobbleParse ( language , n , code )
+ tex.sprint [[ \par ]]
+end
+% \end{macrocode}
+%
+% \bigskip
+% The following function will be used when the key |split-on-empty-lines| is in
+% force. With that key, the informatic code is split in chunks at the empty
+% lines (usually between the informatic functions defined in the informatic
+% code). LaTeX will be able to change the page between the chunks.
+% \begin{macrocode}
+function piton.GobbleSplitParse ( language , n , code )
+ P { "E" ,
+ E = ( V "F"
+ * ( P " " ^ 0 * "\r" ) ^ 1
+ / ( function ( x )
+ tex.sprint ( luatexbase.catcodetables.expl ,
+ [[ \l_@@_split_separation_tl ]] )
+ end )
+ ) ^ 0 * V "F" ,
+% \end{macrocode}
+% The non-terminal |F| corresponds to a chunk of the informatic code.
+% \begin{macrocode}
+ F = C ( V "G" ^ 0 )
+% \end{macrocode}
+% The second argument of |GobbleParsePar| is the argument |gobble|: we put that
+% argument to~$0$ because we will have gobbled previously the whole argument
+% |code| (see below).
+% \begin{macrocode}
+ / ( function ( x ) GobbleParsePar ( language , 0 , x ) end ) ,
+% \end{macrocode}
+% The non-terminal |G| corresponds to a non-empty line of code.
+% \begin{macrocode}
+ G = ( 1 - P "\r" ) ^ 0 * "\r" - ( P " " ^ 0 * "\r" )
+ } : match ( gobble ( n , code ) )
+end
+% \end{macrocode}
+%
+%
+% \bigskip
% The following public Lua function is provided to the developper.
% \begin{macrocode}
function piton.get_last_code ( )
@@ -7115,7 +7226,7 @@ function piton.CountLines ( code )
for i in code : gmatch ( "\r" ) do count = count + 1 end
tex.sprint (
luatexbase.catcodetables.expl ,
- '\\int_set:Nn \\l_@@_nb_lines_int {' .. count .. '}' )
+ [[ \int_set:Nn \l_@@_nb_lines_int { ]] .. count .. '}' )
end
% \end{macrocode}
%
@@ -7131,7 +7242,7 @@ function piton.CountNonEmptyLines ( code )
) : match ( code )
tex.sprint(
luatexbase.catcodetables.expl ,
- '\\int_set:Nn \\l_@@_nb_non_empty_lines_int {' .. count .. '}' )
+ [[ \int_set:Nn \l_@@_nb_non_empty_lines_int { ]] .. count .. '}' )
end
% \end{macrocode}
%
@@ -7143,7 +7254,7 @@ function piton.CountLinesFile ( name )
for line in io.lines ( name ) do count = count + 1 end
tex.sprint (
luatexbase.catcodetables.expl ,
- '\\int_set:Nn \\l_@@_nb_lines_int {' .. count .. '}' )
+ [[ \int_set:Nn \l_@@_nb_lines_int { ]] .. count .. '}' )
end
% \end{macrocode}
%
@@ -7159,7 +7270,7 @@ function piton.CountNonEmptyLinesFile ( name )
end
tex.sprint (
luatexbase.catcodetables.expl ,
- '\\int_set:Nn \\l_@@_nb_non_empty_lines_int {' .. count .. '}' )
+ [[ \int_set:Nn \l_@@_nb_non_empty_lines_int { ]] .. count .. '}' )
end
% \end{macrocode}
%
@@ -7189,16 +7300,16 @@ function piton.ComputeRange(marker_beginning,marker_end,file_name)
end
if first_line == -1
then tex.sprint ( luatexbase.catcodetables.expl ,
- "\\@@_error:n { begin~marker~not~found }" )
+ [[ \@@_error:n { begin~marker~not~found } ]] )
else if last_found == false
then tex.sprint ( luatexbase.catcodetables.expl ,
- "\\@@_error:n { end~marker~not~found }" )
+ [[ \@@_error:n { end~marker~not~found } ]] )
end
end
tex.sprint (
luatexbase.catcodetables.expl ,
- '\\int_set:Nn \\l_@@_first_line_int {' .. first_line .. ' + 2 }'
- .. '\\int_set:Nn \\l_@@_last_line_int {' .. count .. ' }' )
+ [[ \int_set:Nn \l_@@_first_line_int { ]] .. first_line .. ' + 2 }'
+ .. [[ \int_set:Nn \l_@@_last_line_int { ]] .. count .. ' }' )
end
% \end{macrocode}
%
@@ -7236,7 +7347,7 @@ function piton.new_language ( lang , definition )
% \bigskip
% Of course, the \textsc{lpeg} |b_braces| is for balanced braces (without the
% question of strings of an informatic language). In fact, it \emph{won't} be
-% used for an informic language (as dealt by \pkg{piton}) but for LaTeX
+% used for an informatic language (as dealt by \pkg{piton}) but for LaTeX
% instructions;
% \begin{macrocode}
local strict_braces =
@@ -7391,18 +7502,18 @@ function piton.new_language ( lang , definition )
local keywords = P ( false )
% \end{macrocode}
% \begin{macrocode}
- local style = "\\PitonStyle{Keyword}"
- if x[1] == "moredirectives" then style = "\\PitonStyle{directive}" end
+ local style = [[ \PitonStyle{Keyword} ]]
+ if x[1] == "moredirectives" then style = [[ \PitonStyle{directive} ]] end
style = tex_option_arg : match ( x[2] ) or style
local n = tonumber (style )
if n then
- if n > 1 then style = "\\PitonStyle{Keyword" .. style .. "}" end
+ if n > 1 then style = [[ \PitonStyle{Keyword ]] .. style .. "}" end
end
% \end{macrocode}
% \begin{macrocode}
for _ , word in ipairs ( split_clist : match ( x[2] ) ) do
if x[1] == "moretexcs" then
- keywords = Q ( "\\" .. word ) + keywords
+ keywords = Q ( [[ \ ]] .. word ) + keywords
else
if sensitive
% \end{macrocode}
@@ -7437,7 +7548,7 @@ function piton.new_language ( lang , definition )
for _ , x in ipairs ( def_table ) do
if x[1] == "morestring" then
arg1 , arg2 , arg3 , arg4 = args_for_morekeywords : match ( x[2] )
- arg2 = arg2 or "\\PitonStyle{String.Long}"
+ arg2 = arg2 or [[ \PitonStyle{String.Long} ]]
if arg1 == "s" then
long_string =
Q ( arg3 )
@@ -7448,7 +7559,7 @@ function piton.new_language ( lang , definition )
else
central_pattern = 1 - S ( " \r" .. arg3 )
if arg1 : match "b" then
- central_pattern = P ( "\\" .. arg3 ) + central_pattern
+ central_pattern = P ( [[ \ ]] .. arg3 ) + central_pattern
end
% \end{macrocode}
% In fact, the specifier |d| is point-less: when it is not in force, it's still
@@ -7495,12 +7606,12 @@ function piton.new_language ( lang , definition )
for _ , x in ipairs ( def_table ) do
if x[1] == "morecomment" then
local arg1 , arg2 , other_args = args_for_morecomment : match ( x[2] )
- arg2 = arg2 or "\\PitonStyle{Comment}"
+ arg2 = arg2 or [[ \PitonStyle{Comment} ]]
% \end{macrocode}
% If the letter |i| is present in the first argument (eg:
% |morecomment = [si]{(*}{*)}|, then the corresponding comments are discarded.
% \begin{macrocode}
- if arg1 : match "i" then arg2 = "\\PitonStyle{Discard}" end
+ if arg1 : match "i" then arg2 = [[ \PitonStyle{Discard} ]] end
if arg1 : match "l" then
local arg3 = ( tex_braced_arg + C ( P ( 1 ) ^ 0 * -1 ) )
: match ( other_args )
@@ -7642,11 +7753,11 @@ function piton.new_language ( lang , definition )
Ct (
( space ^ 0 * P "\r" ) ^ -1
* BeamerBeginEnvironments
- * Lc '\\@@_begin_line:'
+ * Lc [[ \@@_begin_line: ]]
* SpaceIndentation ^ 0
* LPEG1[lang]
* -1
- * Lc '\\@@_end_line:'
+ * Lc [[ \@@_end_line: ]]
)
% \end{macrocode}
%
@@ -7695,11 +7806,11 @@ function piton.new_language ( lang , definition )
Ct (
( space ^ 0 * P "\r" ) ^ -1
* BeamerBeginEnvironments
- * Lc '\\@@_begin_line:'
+ * Lc [[ \@@_begin_line: ]]
* SpaceIndentation ^ 0
* LPEG1[lang]
* -1
- * Lc '\\@@_end_line:'
+ * Lc [[ \@@_end_line: ]]
)
end
end
@@ -7726,6 +7837,10 @@ end
%
% \verb|https://github.com/fpantigny/piton|
%
+% \subsection*{Changes between versions 2.6 and 2.7}
+%
+% New keys |split-on-empty-lines| and |split-separation|
+%
% \subsection*{Changes between versions 2.5 and 2.6}
%
% API: |piton.last_code| and |\g_piton_last_code_tl| are provided.