diff options
Diffstat (limited to 'Master/texmf-dist/tex/lualatex')
-rw-r--r-- | Master/texmf-dist/tex/lualatex/piton/piton.lua | 427 | ||||
-rw-r--r-- | Master/texmf-dist/tex/lualatex/piton/piton.sty | 52 |
2 files changed, 321 insertions, 158 deletions
diff --git a/Master/texmf-dist/tex/lualatex/piton/piton.lua b/Master/texmf-dist/tex/lualatex/piton/piton.lua index e0f9d7b41ea..d83e7404b16 100644 --- a/Master/texmf-dist/tex/lualatex/piton/piton.lua +++ b/Master/texmf-dist/tex/lualatex/piton/piton.lua @@ -20,7 +20,7 @@ -- ------------------------------------------- -- -- This file is part of the LuaLaTeX package 'piton'. --- Version 2.6a of 2024/03/06 +piton_version = "2.6b" -- 2024/03/18 if piton.comment_latex == nil then piton.comment_latex = ">" end @@ -97,10 +97,11 @@ local Number = + digit ^ 1 ) local Word -if piton.begin_escape ~= nil -then Word = Q ( ( ( 1 - space - P ( piton.begin_escape ) - P ( piton.end_escape ) ) +if piton.begin_escape then + Word = Q ( ( 1 - space - piton.begin_escape - piton.end_escape - S "'\"\r[({})]" - digit ) ^ 1 ) -else Word = Q ( ( ( 1 - space ) - S "'\"\r[({})]" - digit ) ^ 1 ) +else + Word = Q ( ( 1 - space - S "'\"\r[({})]" - digit ) ^ 1 ) end local Space = Q " " ^ 1 @@ -112,6 +113,7 @@ local Tab = "\t" * Lc "\\l__piton_tab_tl" local SpaceIndentation = Lc "\\__piton_an_indentation_space:" * Q " " local Delim = Q ( S "[({})]" ) local VisualSpace = space * Lc "\\l__piton_space_tl" +local LPEG0 = { } local LPEG1 = { } local LPEG2 = { } local LPEG_cleaner = { } @@ -119,7 +121,7 @@ local function Compute_braces ( lpeg_string ) return P { "E" , E = ( - P "{" * V "E" * P "}" + "{" * V "E" * "}" + lpeg_string + @@ -137,10 +139,10 @@ local function Compute_DetectedCommands ( lang , braces ) return * Ct ( Cc "Close" ) end local function Compute_LPEG_cleaner ( lang , braces ) return - Ct ( ( piton.ListCommands * P "{" + Ct ( ( piton.ListCommands * "{" * ( braces / ( function ( s ) return LPEG_cleaner[lang] : match ( s ) end ) ) - * P "}" + * "}" + EscapeClean + C ( P ( 1 ) ) ) ^ 0 ) / table.concat @@ -159,37 +161,37 @@ BeamerBeginEnvironments = L ( P "\\begin{" * BeamerNamesEnvironments * "}" - * ( P "<" * ( 1 - P ">" ) ^ 0 * P ">" ) ^ -1 + * ( "<" * ( 1 - P ">" ) ^ 0 * ">" ) ^ -1 ) - * P "\r" + * "\r" ) ^ 0 BeamerEndEnvironments = ( space ^ 0 * - L ( P "\\end{" * BeamerNamesEnvironments * P "}" ) - * P "\r" + L ( P "\\end{" * BeamerNamesEnvironments * "}" ) + * "\r" ) ^ 0 local function Compute_Beamer ( lang , braces ) - local lpeg = L ( P "\\pause" * ( P "[" * ( 1 - P "]" ) ^ 0 * P "]" ) ^ -1 ) + local lpeg = L ( P "\\pause" * ( "[" * ( 1 - P "]" ) ^ 0 * "]" ) ^ -1 ) lpeg = lpeg + Ct ( Cc "Open" * C ( ( P "\\uncover" + "\\only" + "\\alert" + "\\visible" + "\\invisible" + "\\action" ) - * ( P "<" * ( 1 - P ">" ) ^ 0 * P ">" ) ^ -1 + * ( "<" * ( 1 - P ">" ) ^ 0 * ">" ) ^ -1 * P "{" ) * Cc "}" ) * ( braces / ( function ( s ) return LPEG1[lang] : match ( s ) end ) ) - * P "}" + * "}" * Ct ( Cc "Close" ) lpeg = lpeg + - L ( P "\\alt" * P "<" * ( 1 - P ">" ) ^ 0 * P ">" * P "{" ) + L ( P "\\alt" * "<" * ( 1 - P ">" ) ^ 0 * ">" * "{" ) * K ( 'ParseAgain.noCR' , braces ) * L ( P "}{" ) * K ( 'ParseAgain.noCR' , braces ) * L ( P "}" ) lpeg = lpeg + - L ( ( P "\\temporal" ) * P "<" * ( 1 - P ">" ) ^ 0 * P ">" * P "{" ) + L ( ( P "\\temporal" ) * "<" * ( 1 - P ">" ) ^ 0 * ">" * "{" ) * K ( 'ParseAgain.noCR' , braces ) * L ( P "}{" ) * K ( 'ParseAgain.noCR' , braces ) @@ -201,7 +203,7 @@ local function Compute_Beamer ( lang , braces ) Ct ( Cc "Open" * C ( P ( "\\begin{" .. x .. "}" ) - * ( P "<" * ( 1 - P ">") ^ 0 * P ">" ) ^ -1 + * ( "<" * ( 1 - P ">") ^ 0 * ">" ) ^ -1 ) * Cc ( "\\end{" .. x .. "}" ) ) @@ -320,9 +322,9 @@ local FromImport = local PercentInterpol = K ( 'String.Interpol' , P "%" - * ( P "(" * alphanum ^ 1 * P ")" ) ^ -1 + * ( "(" * alphanum ^ 1 * ")" ) ^ -1 * ( S "-#0 +" ) ^ 0 - * ( digit ^ 1 + P "*" ) ^ -1 + * ( digit ^ 1 + "*" ) ^ -1 * ( "." * ( digit ^ 1 + "*" ) ) ^ -1 * ( S "HlL" ) ^ -1 * S "sdfFeExXorgiGauc%" @@ -457,13 +459,15 @@ local expression = + "[" * V "F" * "]" + ( 1 - S "{}()[]\r\"'" ) ) ^ 0 } -local Param = - SkipSpace * ( Identifier + Q "*args" + Q "**kwargs" ) * SkipSpace - * ( - K ( 'InitialValues' , "=" * expression ) - + Q ":" * SkipSpace * K ( 'Name.Type' , letter ^ 1 ) - ) ^ -1 -local Params = ( Param * ( Q "," * Param ) ^ 0 ) ^ -1 +local Params = + P { "E" , + E = ( V "F" * ( Q "," * V "F" ) ^ 0 ) ^ -1 , + F = SkipSpace * ( Identifier + Q "*args" + Q "**kwargs" ) * SkipSpace + * ( + K ( 'InitialValues' , "=" * expression ) + + Q ":" * SkipSpace * K ( 'Name.Type' , letter ^ 1 ) + ) ^ -1 + } local DefFunction = K ( 'Keyword' , "def" ) * Space @@ -472,7 +476,7 @@ local DefFunction = * Q "(" * Params * Q ")" * SkipSpace * ( Q "->" * SkipSpace * K ( 'Name.Type' , identifier ) ) ^ -1 - * K ( 'ParseAgain' , ( 1 - S ":\r" ) ^ 0 ) + * K ( 'ParseAgain.noCR' , ( 1 - S ":\r" ) ^ 0 ) * Q ":" * ( SkipSpace * ( EOL + CommentLaTeX + Comment ) -- in all cases, that contains an EOL @@ -1138,16 +1142,15 @@ function piton.ParseTer ( language , code ) return piton.Parse ( language , s ) end local function gobble ( n , code ) - if n==0 + 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 ) + 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 local AutoGobbleLPEG = @@ -1299,16 +1302,49 @@ function piton.new_language ( lang , definition ) * ( "=" * space ^ 0 * C ( strict_braces ) ) ^ -1 ) } local def_table = cut_definition : match ( definition ) + local tex_braced_arg = "{" * C ( ( 1 - P "}" ) ^ 0 ) * "}" + local tex_arg = tex_braced_arg + C ( 1 ) + local tex_option_arg = "[" * C ( ( 1 - P "]" ) ^ 0 ) * "]" + Cc ( nil ) + local args_for_morekeywords + = "[" * C ( ( 1 - P "]" ) ^ 0 ) * "]" + * space ^ 0 + * tex_option_arg + * space ^ 0 + * tex_arg + * space ^ 0 + * ( tex_braced_arg + Cc ( nil ) ) + local args_for_moredelims + = ( C ( P "*" ^ -2 ) + Cc ( nil ) ) * space ^ 0 + * args_for_morekeywords + local args_for_morecomment + = "[" * C ( ( 1 - P "]" ) ^ 0 ) * "]" + * space ^ 0 + * tex_option_arg + * space ^ 0 + * C ( P ( 1 ) ^ 0 * -1 ) + local args_for_tag + = ( P "*" ^ -2 ) + * space ^ 0 + * ( "[" * ( 1 - P "]" ) ^ 0 * "]" ) ^ 0 + * space ^ 0 + * tex_arg + * space ^ 0 + * tex_arg local sensitive = true - for _ , x in ipairs ( def_table ) - do if x[1] == "sensitive" - then if x[2] == nil or ( P "true" ) : match ( x[2] ) - then sensitive = true - else if ( P "false" ) : match ( x[2] ) then sensitive = false end - end - end - if x[1] == "alsodigit" then x[2] : gsub ( "." , add_to_digit ) end - if x[1] == "alsoletter" then x[2] : gsub ( "." , add_to_letter ) end + local left_tag , right_tag + for _ , x in ipairs ( def_table ) do + if x[1] == "sensitive" then + if x[2] == nil or ( P "true" ) : match ( x[2] ) then + sensitive = true + else + if ( P "false" + P "f" ) : match ( x[2] ) then sensitive = false end + end + end + if x[1] == "alsodigit" then x[2] : gsub ( "." , add_to_digit ) end + if x[1] == "alsoletter" then x[2] : gsub ( "." , add_to_letter ) end + if x[1] == "tag" then + left_tag , right_tag = args_for_tag : match ( x[2] ) + end end local Number = K ( 'Number' , @@ -1321,7 +1357,6 @@ function piton.new_language ( lang , definition ) local alphanum = letter + digit local identifier = letter * alphanum ^ 0 local Identifier = K ( 'Identifier' , identifier ) - local option = "[" * C ( ( 1 - P "]" ) ^ 0 ) * "]" local split_clist = P { "E" , E = ( "[" * ( 1 - P "]" ) ^ 0 * "]" ) ^ -1 @@ -1340,19 +1375,31 @@ function piton.new_language ( lang , definition ) end local Keyword = P ( false ) for _ , x in ipairs ( def_table ) - do if x[1] == "morekeywords" or x[1] == "otherkeywords" then + do if x[1] == "morekeywords" + or x[1] == "otherkeywords" + or x[1] == "moredirectives" + or x[1] == "moretexcs" + then local keywords = P ( false ) - for _ , word in ipairs ( split_clist : match ( x[2] ) ) - do if sensitive - then keywords = Q ( word ) + keywords - else keywords = keyword_to_lpeg ( word ) + keywords - 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 + end + for _ , word in ipairs ( split_clist : match ( x[2] ) ) do + if x[1] == "moretexcs" then + keywords = Q ( "\\" .. word ) + keywords + else + if sensitive + then keywords = Q ( word ) + keywords + else keywords = keyword_to_lpeg ( word ) + keywords + end + end end Keyword = Keyword + - Lc ( "{" - .. ( option : match ( x[2] ) or "\\PitonStyle{Keyword}" ) - .. "{" ) - * keywords * Lc "}}" + Lc ( "{" .. style .. "{" ) * keywords * Lc "}}" end if x[1] == "keywordsprefix" then local prefix = ( ( C ( 1 - P " " ) ^ 1 ) * P " " ^ 0 ) : match ( x[2] ) @@ -1361,40 +1408,41 @@ function piton.new_language ( lang , definition ) end local long_string = P ( false ) local LongString = P (false ) - local args = "[" * C ( ( 1 - P "]" ) ^ 0 ) * "]" - * space ^ 0 - * ( "[" * C ( ( 1 - P "]" ) ^ 0 ) * "]" + Cc ( nil ) ) - * space ^ 0 - * ( "{" * C ( ( 1 - P "}" ) ^ 0 ) * "}" + C ( 1 ) ) local central_pattern = P ( false ) - for _ , x in ipairs ( def_table ) - do if x[1] == "morestring" then - arg1 , arg2 , arg3 = args : match ( x[2] ) - arg2 = arg2 or "\\PitonStyle{String.Long}" - if arg1 == "b" then - central_pattern = Q ( ( P ( "\\" .. arg3 ) + 1 - S ( " \r" .. arg3 ) ) ^ 1 ) - end - if arg1 == "d" then - central_pattern = Q ( ( P ( arg3 .. arg3 ) + 1 - S ( " \r" .. arg3 ) ) ^ 1 ) - end - if arg1 == "bd" then - central_pattern = - Q ( ( P ( arg3 .. arg3 ) + P ( "\\" .. arg3 ) + 1 - S ( " \r" .. arg3 ) ) ^ 1 ) - end - if arg1 == "m" then - central_pattern = Q ( ( P ( arg3 .. arg3 ) + 1 - S ( " \r" .. arg3 ) ) ^ 1 ) - end - if arg1 == "m" - then prefix = P ( false ) - else prefix = lpeg.B ( 1 - letter - ")" - "]" ) - end - long_string = long_string + - prefix * ( Q ( arg3 ) * ( VisualSpace + central_pattern + EOL ) ^ 0 * Q ( arg3 ) ) - LongString = LongString + - Ct ( Cc "Open" * Cc ( "{" .. arg2 .. "{" ) * Cc "}}" ) - * long_string - * Ct ( Cc "Close" ) - end + 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}" + if arg1 == "s" then + long_string = + Q ( arg3 ) + * ( Q ( ( 1 - P ( arg4 ) - S "$\r" ) ^ 1 ) -- $ + + EOL + ) ^ 0 + * Q ( arg4 ) + else + central_pattern = 1 - S ( " \r" .. arg3 ) + if arg1 : match "b" then + central_pattern = P ( "\\" .. arg3 ) + central_pattern + end + if arg1 : match "d" or arg1 == "m" then + central_pattern = P ( arg3 .. arg3 ) + central_pattern + end + if arg1 == "m" + then prefix = P ( false ) + else prefix = lpeg.B ( 1 - letter - ")" - "]" ) + end + long_string = long_string + + prefix + * Q ( arg3 ) + * ( VisualSpace + Q ( central_pattern ^ 1 ) + EOL ) ^ 0 + * Q ( arg3 ) + end + LongString = LongString + + Ct ( Cc "Open" * Cc ( "{" .. arg2 .. "{" ) * Cc "}}" ) + * long_string + * Ct ( Cc "Close" ) + end end local braces = Compute_braces ( String ) @@ -1403,66 +1451,99 @@ function piton.new_language ( lang , definition ) DetectedCommands = Compute_DetectedCommands ( lang , braces ) LPEG_cleaner[lang] = Compute_LPEG_cleaner ( lang , braces ) - local Comment = P ( false ) + local CommentDelim = P ( false ) - local args = "[" * C ( ( 1 - P "]" ) ^ 0 ) * "]" - * space ^ 0 - * ( "[" * C ( ( 1 - P "]" ) ^ 0 ) * "]" + Cc ( nil ) ) - * space ^ 0 - * ( "{" * C ( ( 1 - P "}" ) ^ 0 ) * "}" + C ( 1 ) ) - * space ^ 0 - * ( "{" * C ( ( 1 - P "}" ) ^ 0 ) * "}" + Cc ( nil ) ) - - for _ , x in ipairs ( def_table ) - do if x[1] == "morecomment" - then local arg1 , arg2 , arg3 , arg4 = args : match ( x[2] ) - arg2 = arg2 or "\\PitonStyle{Comment}" - if arg1 == "l" then - if arg3 == [[\#]] then arg3 = "#" end -- mandatory - Comment = Comment + - Ct ( Cc "Open" - * Cc ( "{" .. arg2 .. "{" ) * Cc "}}" ) - * Q ( arg3 ) - * ( CommentMath + Q ( ( 1 - S "$\r" ) ^ 1 ) ) ^ 0 -- $ - * Ct ( Cc "Close" ) - * ( EOL + -1 ) - end - if arg1 == "s" then - Comment = Comment + - Ct ( Cc "Open" * Cc ( "{" .. arg2 .. "{" ) * Cc "}}" ) - * Q ( arg3 ) - * ( - CommentMath - + Q ( ( 1 - P ( arg4 ) - S "$\r" ) ^ 1 ) -- $ - + EOL - ) ^ 0 - * Q ( arg4 ) - * Ct ( Cc "Close" ) - end - if arg1 == "n" then - Comment = Comment + - Ct ( Cc "Open" * Cc ( "{" .. arg2 .. "{" ) * Cc "}}" ) - * P { "A" , - A = Q ( arg3 ) - * ( V "A" - + Q ( ( 1 - P ( arg3 ) - P ( arg4 ) - - S "\r$\"" ) ^ 1 ) -- $ - + long_string - + "$" -- $ - * K ( 'Comment.Math' , ( 1 - S "$\r" ) ^ 1 ) --$ - * "$" -- $ - + EOL - ) ^ 0 - * Q ( arg4 ) - } - * Ct ( Cc "Close" ) - end + 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}" + 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 ) + if arg3 == [[\#]] then arg3 = "#" end -- mandatory + CommentDelim = CommentDelim + + Ct ( Cc "Open" + * Cc ( "{" .. arg2 .. "{" ) * Cc "}}" ) + * Q ( arg3 ) + * ( CommentMath + Q ( ( 1 - S "$\r" ) ^ 1 ) ) ^ 0 -- $ + * Ct ( Cc "Close" ) + * ( EOL + -1 ) + else + local arg3 , arg4 = + ( tex_arg * space ^ 0 * tex_arg ) : match ( other_args ) + if arg1 : match "s" then + CommentDelim = CommentDelim + + Ct ( Cc "Open" * Cc ( "{" .. arg2 .. "{" ) * Cc "}}" ) + * Q ( arg3 ) + * ( + CommentMath + + Q ( ( 1 - P ( arg4 ) - S "$\r" ) ^ 1 ) -- $ + + EOL + ) ^ 0 + * Q ( arg4 ) + * Ct ( Cc "Close" ) + end + if arg1 : match "n" then + CommentDelim = CommentDelim + + Ct ( Cc "Open" * Cc ( "{" .. arg2 .. "{" ) * Cc "}}" ) + * P { "A" , + A = Q ( arg3 ) + * ( V "A" + + Q ( ( 1 - P ( arg3 ) - P ( arg4 ) + - S "\r$\"" ) ^ 1 ) -- $ + + long_string + + "$" -- $ + * K ( 'Comment.Math' , ( 1 - S "$\r" ) ^ 1 ) --$ + * "$" -- $ + + EOL + ) ^ 0 + * Q ( arg4 ) + } + * Ct ( Cc "Close" ) + end + end + end + if x[1] == "moredelim" then + local arg1 , arg2 , arg3 , arg4 , arg5 + = args_for_moredelims : match ( x[2] ) + local MyFun = Q + if arg1 == "*" or arg1 == "**" then + MyFun = function ( x ) return K ( 'ParseAgain.noCR' , x ) end + end + local left_delim + if arg2 : match "i" then + left_delim = P ( arg4 ) + else + left_delim = Q ( arg4 ) end + if arg2 : match "l" then + CommentDelim = CommentDelim + + Ct ( Cc "Open" * Cc ( "{" .. arg3 .. "{" ) * Cc "}}" ) + * left_delim + * ( MyFun ( ( 1 - P "\r" ) ^ 1 ) ) ^ 0 + * Ct ( Cc "Close" ) + * ( EOL + -1 ) + end + if arg2 : match "s" then + local right_delim + if arg2 : match "i" then + right_delim = P ( arg5 ) + else + right_delim = Q ( arg5 ) + end + CommentDelim = CommentDelim + + Ct ( Cc "Open" * Cc ( "{" .. arg3 .. "{" ) * Cc "}}" ) + * left_delim + * ( MyFun ( ( 1 - P ( arg5 ) - "\r" ) ^ 1 ) + EOL ) ^ 0 + * right_delim + * Ct ( Cc "Close" ) + end + end end local Delim = Q ( S "{[()]}" ) - local Punct = Q ( S ",:;!\\'\"" ) - + local Punct = Q ( S "=,:;!\\'\"" ) local Main = space ^ 1 * -1 + space ^ 0 * EOL @@ -1472,18 +1553,17 @@ function piton.new_language ( lang , definition ) + CommentLaTeX + Beamer + DetectedCommands - + Comment + + CommentDelim + Delim + LongString - -- should maybe be after the following line! + Keyword * ( Space + Punct + Delim + EOL + -1 ) + Punct + K ( 'Identifier' , letter * alphanum ^ 0 ) + Number + Word - LPEG1[lang] = Main ^ 0 - + if left_tag then + end LPEG2[lang] = Ct ( ( space ^ 0 * P "\r" ) ^ -1 @@ -1494,6 +1574,55 @@ function piton.new_language ( lang , definition ) * -1 * Lc '\\__piton_end_line:' ) - + if left_tag then + local Tag = Q ( left_tag * other ^ 0 ) + * ( ( ( 1 - P ( right_tag ) ) ^ 0 ) + / ( function ( x ) return LPEG0[lang] : match ( x ) end ) ) + * Q ( right_tag ) + MainWithoutTag + = space ^ 1 * -1 + + space ^ 0 * EOL + + Space + + Tab + + Escape + EscapeMath + + CommentLaTeX + + Beamer + + DetectedCommands + + CommentDelim + + Delim + + LongString + + Keyword * ( Space + Punct + Delim + EOL + -1 ) + + Punct + + K ( 'Identifier' , letter * alphanum ^ 0 ) + + Number + + Word + LPEG0[lang] = MainWithoutTag ^ 0 + MainWithTag + = space ^ 1 * -1 + + space ^ 0 * EOL + + Space + + Tab + + Escape + EscapeMath + + CommentLaTeX + + Beamer + + DetectedCommands + + CommentDelim + + Tag + + Delim + + Punct + + K ( 'Identifier' , letter * alphanum ^ 0 ) + + Word + LPEG1[lang] = MainWithTag ^ 0 + LPEG2[lang] = + Ct ( + ( space ^ 0 * P "\r" ) ^ -1 + * BeamerBeginEnvironments + * Lc '\\__piton_begin_line:' + * SpaceIndentation ^ 0 + * LPEG1[lang] + * -1 + * Lc '\\__piton_end_line:' + ) + end end diff --git a/Master/texmf-dist/tex/lualatex/piton/piton.sty b/Master/texmf-dist/tex/lualatex/piton/piton.sty index 8af3a95c6d8..0ba3e7b109c 100644 --- a/Master/texmf-dist/tex/lualatex/piton/piton.sty +++ b/Master/texmf-dist/tex/lualatex/piton/piton.sty @@ -19,8 +19,8 @@ %% LaTeX version 2005/12/01 or later. %% ------------------------------------------- %% -\def\PitonFileVersion{2.6a} -\def\PitonFileDate{2024/03/06} +\def\PitonFileVersion{2.6b} +\def\PitonFileDate{2024/03/18} \NeedsTeXFormat{LaTeX2e} @@ -298,7 +298,6 @@ \__piton_replace_spaces:n { #1 } \strut \hfil } - \tl_log:n { Contenu : #1.} \hbox_set:Nn \l_tmpa_box { \skip_horizontal:N \l__piton_left_margin_dim @@ -758,6 +757,8 @@ \group_begin: \cs_set_protected:Npn \__piton_begin_line: { } \cs_set_protected:Npn \__piton_end_line: { } + \cs_set:cpn { pitonStyle _ \l_piton_language_str _ Prompt } { } + \cs_set:cpn { pitonStyle _ Prompt } { } \bool_lazy_or:nnTF \l__piton_break_lines_in_piton_bool \l__piton_break_lines_in_Piton_bool @@ -787,6 +788,8 @@ \group_begin: \cs_set_protected:Npn \__piton_begin_line: { } \cs_set_protected:Npn \__piton_end_line: { } + \cs_set:cpn { pitonStyle _ \l_piton_language_str _ Prompt } { } + \cs_set:cpn { pitonStyle _ Prompt } { } \cs_set_protected:Npn \__piton_newline: { \msg_fatal:nn { piton } { cr~not~allowed } } \bool_lazy_or:nnTF @@ -1083,6 +1086,7 @@ { Comment , Comment.LaTeX , + Discard , Exception , FormattingType , Identifier , @@ -1090,6 +1094,14 @@ Interpol.Inside , Keyword , Keyword.Constant , + Keyword2 , + Keyword3 , + Keyword4 , + Keyword5 , + Keyword6 , + Keyword7 , + Keyword8 , + Keyword9 , Name.Builtin , Name.Class , Name.Constructor , @@ -1110,7 +1122,8 @@ String.Long , String.Short , TypeParameter , - UserFunction + UserFunction , + directive } \clist_map_inline:Nn \g__piton_styles_clist @@ -1176,10 +1189,12 @@ TypeParameter = \color[HTML]{336666} \itshape , Preproc = \color[HTML]{AA6600} \slshape , Identifier = \__piton_identifier:n , + directive = \color[HTML]{AA6600} , UserFunction = , Prompt = , ParseAgain.noCR = \__piton_piton_no_cr:n , ParseAgain = \__piton_piton:n , + Discard = \use_none:n } \AtBeginDocument { @@ -1192,20 +1207,20 @@ \tl_if_novalue:nTF { #1 } { \clist_map_inline:Nn \l_tmpa_clist - { \cs_set:cpn { pitonIdentifier _ ##1 } { #3 } } + { \cs_set:cpn { PitonIdentifier _ ##1 } { #3 } } } { \str_set:Nx \l_tmpa_str { \str_lowercase:n { #1 } } \str_if_eq:onT \l_tmpa_str { current-language } { \str_set_eq:NN \l_tmpa_str \l_piton_language_str } \clist_map_inline:Nn \l_tmpa_clist - { \cs_set:cpn { pitonIdentifier _ \l_tmpa_str _ ##1 } { #3 } } + { \cs_set:cpn { PitonIdentifier _ \l_tmpa_str _ ##1 } { #3 } } } } \cs_new_protected:Npn \__piton_identifier:n #1 { - \cs_if_exist_use:cF { pitonIdentifier _ \l_piton_language_str _ #1 } - { \cs_if_exist_use:c { pitonIdentifier_ #1 } } + \cs_if_exist_use:cF { PitonIdentifier _ \l_piton_language_str _ #1 } + { \cs_if_exist_use:c { PitonIdentifier _ #1 } } { #1 } } \keys_define:nn { PitonOptions } @@ -1284,6 +1299,13 @@ \token_to_str:N \piton\ but~there~is~no~environment~ {piton}.~This~error~is~fatal. } +\__piton_msg_new:nn { bad~version~of~piton.lua } + { + Bad~number~version~of~'piton.lua'\\ + The~file~'piton.lua'~loaded~has~not~the~same~number~of~ + version~as~the~file~'piton.sty'.~You~can~go~on~but~you~should~ + address~that~issue. + } \__piton_msg_new:nn { key~identifiers~deprecated } { The~key~'identifiers'~in~the~command~\token_to_str:N PitonOptions\ @@ -1416,8 +1438,20 @@ in~Beamer.\\ If~you~go~on,~that~argument~will~be~ignored. } +\cs_new_protected:Npn \__piton_test_version:n #1 + { + \str_if_eq:VnF \PitonFileVersion { #1 } + { \__piton_error:n { bad~version~of~piton.lua } } + } \hook_gput_code:nnn { begindocument } { . } - { \lua_now:e { require("piton.lua") } } + { + \lua_now:n + { + require ( "piton" ) + tex.sprint ( luatexbase.catcodetables.CatcodeTableExpl , + "\\__piton_test_version:n {" .. piton_version .. "}" ) + } + } \ExplSyntaxOff \begin{luacode*} lpeg.locale(lpeg) |