summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-01-06 21:34:11 +0000
committerKarl Berry <karl@freefriends.org>2024-01-06 21:34:11 +0000
commit8fb6c5957a111732172ce6e71d53245c95228116 (patch)
tree859b5973aebab3b5f955a4aadce58334867406f5 /Master/texmf-dist/tex/lualatex
parent35b6a28449046b4373907e89da0d6e60fffbaba3 (diff)
piton (6jan24)
git-svn-id: svn://tug.org/texlive/trunk@69320 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/lualatex')
-rw-r--r--Master/texmf-dist/tex/lualatex/piton/piton.lua33
-rw-r--r--Master/texmf-dist/tex/lualatex/piton/piton.sty76
2 files changed, 75 insertions, 34 deletions
diff --git a/Master/texmf-dist/tex/lualatex/piton/piton.lua b/Master/texmf-dist/tex/lualatex/piton/piton.lua
index aba0b0990d9..5ce6ce746d1 100644
--- a/Master/texmf-dist/tex/lualatex/piton/piton.lua
+++ b/Master/texmf-dist/tex/lualatex/piton/piton.lua
@@ -1,3 +1,26 @@
+--
+-- This is file `piton.lua',
+-- generated with the docstrip utility.
+--
+-- The original source files were:
+--
+-- piton.dtx (with options: `LUA')
+-- -------------------------------------------
+-- Copyright (C) 2022-2024 by F. Pantigny
+--
+-- This file may be distributed and/or modified under the
+-- conditions of the LaTeX Project Public License, either
+-- version 1.3 of this license or (at your option) any later
+-- version. The latest version of this license is in:
+--
+-- http://www.latex-project.org/lppl.txt
+--
+-- and version 1.3 or later is part of all distributions of
+-- LaTeX version 2005/12/01 or later.
+-- -------------------------------------------
+--
+-- This file is part of the LuaLaTeX package 'piton'.
+-- Version 2.3 of 2024/01/06
if piton.comment_latex == nil then piton.comment_latex = ">" end
@@ -684,7 +707,7 @@ local closeeq =
local QuotedStringBis =
WithStyle ( 'String.Long' ,
(
- VisualSpace
+ Space
+
Q ( ( 1 - S " \r" ) ^ 1 )
+
@@ -830,6 +853,8 @@ ocaml =
* Lc ( '\\__piton_end_line:' )
)
languages['ocaml'] = ocaml
+local Delim = Q ( S "{[()]}" )
+local Punct = Q ( S ",:;!" )
local identifier = letter * alphanum ^ 0
local Operator =
@@ -869,6 +894,7 @@ local Type =
local DefFunction =
Type
* Space
+ * Q ( "*" ) ^ -1
* K ( 'Name.Function.Internal' , identifier )
* SkipSpace
* # P "("
@@ -1385,6 +1411,11 @@ function piton.GobbleParse(language,n,code)
end
end
piton.Parse(language,gobble(n,code))
+ if piton.write ~= ''
+ then local file = assert(io.open(piton.write,piton.write_mode))
+ file:write(code)
+ file:close()
+ end
end
function piton.CountLines(code)
local count = 0
diff --git a/Master/texmf-dist/tex/lualatex/piton/piton.sty b/Master/texmf-dist/tex/lualatex/piton/piton.sty
index 50c16f04959..6f450b6405b 100644
--- a/Master/texmf-dist/tex/lualatex/piton/piton.sty
+++ b/Master/texmf-dist/tex/lualatex/piton/piton.sty
@@ -5,8 +5,8 @@
%% The original source files were:
%%
%% piton.dtx (with options: `STY')
-%%
-%% Copyright (C) 2022-2023 by F. Pantigny
+%% -------------------------------------------
+%% Copyright (C) 2022-2024 by F. Pantigny
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
@@ -17,17 +17,18 @@
%%
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
+%% -------------------------------------------
%%
-\def\myfileversion{2.2b}
-\def\myfiledate{2023/11/03}
+\def\PitonFileVersion{2.3}
+\def\PitonFileDate{2024/01/06}
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{l3keys2e}
\ProvidesExplPackage
{piton}
- {\myfiledate}
- {\myfileversion}
+ {\PitonFileDate}
+ {\PitonFileVersion}
{Highlight Python codes with LPEG on LuaLaTeX}
\cs_new_protected:Npn \__piton_error:n { \msg_error:nn { piton } }
\cs_new_protected:Npn \__piton_warning:n { \msg_warning:nn { piton } }
@@ -40,7 +41,7 @@
{
LuaLaTeX~is~mandatory.\\
The~package~'piton'~requires~the~engine~LuaLaTeX.\\
- \str_if_eq:VnT \c_sys_jobname_str { output }
+ \str_if_eq:onT \c_sys_jobname_str { output }
{ If~you~use~Overleaf,~you~can~switch~to~LuaLaTeX~in~the~"Menu". \\}
If~you~go~on,~the~package~'piton'~won't~be~loaded.
}
@@ -49,7 +50,7 @@
\__piton_msg_new:nn { piton.lua~not~found }
{
The~file~'piton.lua'~can't~be~found.\\
- The package~'piton'~won't~be~loaded.
+ The~package~'piton'~won't~be~loaded.
}
\file_if_exist:nF { piton.lua }
{ \msg_critical:nn { piton } { piton.lua~not~found } }
@@ -66,19 +67,11 @@
beamer .bool_gset:N = \g__piton_beamer_bool ,
beamer .default:n = true ,
- escape-inside .code:n = \__piton_error:n { key-escape-inside-deleted } ,
math-comments .code:n = \__piton_error:n { moved~to~preamble } ,
comment-latex .code:n = \__piton_error:n { moved~to~preamble } ,
unknown .code:n = \__piton_error:n { Unknown~key~for~package }
}
-\__piton_msg_new:nn { key-escape-inside-deleted }
- {
- The~key~'escape-inside'~has~been~deleted.~You~must~now~use~
- the~keys~'begin-escape'~and~'end-escape'~in~
- \token_to_str:N \PitonOptions.\\
- That~key~will~be~ignored.
- }
\__piton_msg_new:nn { moved~to~preamble }
{
The~key~'\l_keys_key_str'~*must*~now~be~used~with~
@@ -169,6 +162,8 @@
\str_new:N \l__piton_end_range_str
\str_new:N \l__piton_file_name_str
\int_new:N \g__piton_env_int
+\str_new:N \l__piton_write_str
+\seq_new:N \g__piton_write_seq
\bool_new:N \l__piton_show_spaces_bool
\bool_new:N \l__piton_break_lines_in_Piton_bool
\bool_new:N \l__piton_indent_broken_lines_bool
@@ -241,7 +236,10 @@
{
\tl_set:Nn \l_tmpa_tl { #1 }
\bool_if:NTF \l__piton_show_spaces_bool
- { \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl } % U+2423
+ {
+ \tl_set:Nn \l__piton_space_tl { ␣ }
+ \regex_replace_all:nnN { \x20 } { ␣ } \l_tmpa_tl % U+2423
+ }
{
\bool_if:NT \l__piton_break_lines_in_Piton_bool
{
@@ -347,11 +345,10 @@
{
\tl_set:Nn \l_tmpa_tl { #1 }
\tl_set_rescan:Nno \l_tmpa_tl { } \l_tmpa_tl
- \exp_last_unbraced:NV \color \l_tmpa_tl
+ \exp_last_unbraced:No \color \l_tmpa_tl
}
{ \color { #1 } }
}
-\cs_generate_variant:Nn \__piton_color:n { V }
\cs_new_protected:Npn \__piton_newline:
{
\int_gincr:N \g__piton_line_int
@@ -362,7 +359,7 @@
{
\egroup
\bool_if:NT \g__piton_footnote_bool { \end { savenotes } }
- \par \mode_leave_vertical: % \newline
+ \par \mode_leave_vertical:
\bool_if:NT \g__piton_footnote_bool { \begin { savenotes } }
\vtop \bgroup
}
@@ -542,6 +539,9 @@
} ,
width .value_required:n = true ,
+ write .str_set:N = \l__piton_write_str ,
+ write .value_required:n = true ,
+
left-margin .code:n =
\str_if_eq:nnTF { #1 } { auto }
{
@@ -649,7 +649,7 @@
\iow_now:Nx \@mainaux
{
\tl_gset:cn { c__piton_ \int_use:N \g__piton_env_int _ tl }
- { \exp_not:V \g__piton_aux_tl }
+ { \exp_not:o \g__piton_aux_tl }
}
\iow_now:Nn \@mainaux { \ExplSyntaxOff }
}
@@ -785,7 +785,6 @@
\int_gzero:N \g__piton_line_int
\dim_zero:N \parindent
\dim_zero:N \lineskip
- \dim_zero:N \parindent
\cs_set_eq:NN \label \__piton_label:n
}
\cs_new_protected:Npn \__piton_compute_left_margin:nn #1 #2
@@ -812,7 +811,7 @@
{ \box_wd:N \l_tmpa_box + \l__piton_numbers_sep_dim + 0.1 em }
}
}
-\cs_generate_variant:Nn \__piton_compute_left_margin:nn { n V }
+\cs_generate_variant:Nn \__piton_compute_left_margin:nn { n o }
\cs_new_protected:Npn \__piton_compute_width:
{
\dim_compare:nNnTF \l__piton_line_width_dim = \c_zero_dim
@@ -855,8 +854,18 @@
\__piton_compute_left_margin:nn { CountNonEmptyLines } { ##1 }
\__piton_compute_width:
\ttfamily
- \dim_zero:N \parskip % added 2023/07/06
+ \dim_zero:N \parskip
\bool_if:NT \g__piton_footnote_bool { \begin { savenotes } }
+ \lua_now:e { piton.write = "\l__piton_write_str" }
+ \str_if_empty:NF \l__piton_write_str
+ {
+ \seq_if_in:NVTF \g__piton_write_seq \l__piton_write_str
+ { \lua_now:n { piton.write_mode = "a" } }
+ {
+ \lua_now:n { piton.write_mode = "w" }
+ \seq_gput_left:NV \g__piton_write_seq \l__piton_write_str
+ }
+ }
\vtop \bgroup
\lua_now:e
{
@@ -880,7 +889,7 @@
\cs_set_eq:NN \PitonOptions \__piton_fake_PitonOptions
#3
\__piton_pre_env:
- \int_compare:nNnT \l__piton_number_lines_start_int > 0
+ \int_compare:nNnT \l__piton_number_lines_start_int > \c_zero_int
{ \int_gset:Nn \g__piton_visual_line_int { \l__piton_number_lines_start_int - 1 } }
\group_begin:
\tl_map_function:nN
@@ -941,7 +950,7 @@
\bool_if:nTF
{
(
- \int_compare_p:nNn \l__piton_first_line_int > 0
+ \int_compare_p:nNn \l__piton_first_line_int > \c_zero_int
|| \int_compare_p:nNn \l__piton_last_line_int < \c_max_int
)
&& ! \str_if_empty_p:N \l__piton_begin_range_str
@@ -967,16 +976,16 @@
\__piton_pre_env:
\bool_if:NT \l__piton_line_numbers_absolute_bool
{ \int_gset:Nn \g__piton_visual_line_int { \l__piton_first_line_int - 1 } }
- \int_compare:nNnT \l__piton_number_lines_start_int > 0
+ \int_compare:nNnT \l__piton_number_lines_start_int > \c_zero_int
{
\int_gset:Nn \g__piton_visual_line_int
{ \l__piton_number_lines_start_int - 1 }
}
- \int_compare:nNnT \g__piton_visual_line_int < 0
- { \int_gzero:N \g__piton_visual_line_int }
+ \int_compare:nNnT \g__piton_visual_line_int < \c_zero_int
+ { \int_gzero:N \g__piton_visual_line_int }
\mode_if_vertical:TF \mode_leave_vertical: \newline
\lua_now:e { piton.CountLinesFile('\l__piton_file_name_str') }
- \__piton_compute_left_margin:nV { CountNonEmptyLinesFile } \l__piton_file_name_str
+ \__piton_compute_left_margin:no { CountNonEmptyLinesFile } \l__piton_file_name_str
\__piton_compute_width:
\ttfamily
\bool_if:NT \g__piton_footnote_bool { \begin { savenotes } }
@@ -1017,7 +1026,7 @@
\NewDocumentCommand { \SetPitonStyle } { O { } m }
{
\str_set:Nx \l__piton_SetPitonStyle_option_str { \str_lowercase:n { #1 } }
- \str_if_eq:VnT \l__piton_SetPitonStyle_option_str { current-language }
+ \str_if_eq:onT \l__piton_SetPitonStyle_option_str { current-language }
{ \str_set_eq:NN \l__piton_SetPitonStyle_option_str \l__piton_language_str }
\keys_set:nn { piton / Styles } { #2 }
\str_clear:N \l__piton_SetPitonStyle_option_str
@@ -1246,7 +1255,7 @@
}
\__piton_msg_new:nn { syntax~error }
{
- Your~code~is~not~syntactically~correct.\\
+ Your~code~\l__piton_language_str\ is~not~syntactically~correct.\\
It~won't~be~printed~in~the~PDF~file.
}
\NewDocumentCommand \PitonSyntaxError { }
@@ -1309,7 +1318,8 @@
show-spaces-in-strings,~
splittable,~
tabs-auto-gobble,~
- tab-size~and~width.
+ tab-size,~width~
+ and~write.
}
\__piton_msg_new:nn { label~with~lines~numbers }
{