diff options
author | Norbert Preining <norbert@preining.info> | 2022-09-20 03:01:38 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2022-09-20 03:01:38 +0000 |
commit | 7907f67d07d36a7e20421a1ec3a0eceecac4aacd (patch) | |
tree | 7aae41d00037cc944480cecfa75b88048a672970 /macros/luatex/latex/piton/piton.dtx | |
parent | fe872ca5d5d1bb989da6b31802b8e0bfb0342e45 (diff) |
CTAN sync 202209200301
Diffstat (limited to 'macros/luatex/latex/piton/piton.dtx')
-rw-r--r-- | macros/luatex/latex/piton/piton.dtx | 101 |
1 files changed, 75 insertions, 26 deletions
diff --git a/macros/luatex/latex/piton/piton.dtx b/macros/luatex/latex/piton/piton.dtx index 48e6f777e5..d7180b9fa3 100644 --- a/macros/luatex/latex/piton/piton.dtx +++ b/macros/luatex/latex/piton/piton.dtx @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{0.6} -\def\myfiledate{2022/09/14} +\def\myfileversion{0.6a} +\def\myfiledate{2022/09/19} % % %<*batchfile> @@ -159,25 +159,30 @@ def fact(n): % % \bigskip % It's possible to compose comments in LaTeX by beginning with |##| (it's a -% ``LaTeX escape''). The characters |##| themselves won't be printed. +% ``LaTeX escape''). The characters |##| themselves won't be printed and the +% spaces after |##| are removed. % % \section{Customization} % % \subsection{The command \textbackslash PitonOptions} % -% The command |\PitonOptions| provides four keys: |gobble|, |auto-gobble|, -% |line-numbers| and |all-line-numbers|. +% The command |\PitonOptions| provides five keys: |gobble|, |auto-gobble|, +% |env-gobble|, |line-numbers| and |all-line-numbers|. % % \begin{itemize} % \item The key |gobble| takes in as value a positive integer~$n$: the first $n$ % characters are discarded (before the process of hightlighning of the code) for % each line of the environment |{Piton}|. % -% \item Then the key |auto-gobble| is in force, the extnsion \pkg{piton} compute +% \item Then the key |auto-gobble| is in force, the extension \pkg{piton} computes % the minimal value $n$ of the number of consecutives space beginning each (non % empty) line of the environment |{Piton}| and applies |gobble| with that value % of~$n$. % +% \item When the key |env-gobble| is in force, \pkg{piton} applies |gobble| with +% a value of $n$ equal to the number of spaces before |\end{Piton}| on the last +% line (if that line contains only spaces). +% % \item With the key |line-numbers|, the \emph{non empty} lines are numbered in % the environments |{Piton}| and in the listings resulting from the use of % |\PitonInputFile|. @@ -388,6 +393,18 @@ def fact(n): % \end{macrocode} % % \bigskip +% \begin{macrocode} +\msg_new:nnn { piton } { LuaLaTeX~mandatory } + { The~package~'piton'~must~be~used~with~LuaLaTeX.\\ It~won't~be~loaded. } +\sys_if_engine_luatex:F { \msg_critical:nn { piton } { LuaLaTeX~mandatory } } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\RequirePackage { luatexbase } +% \end{macrocode} +% +% \bigskip % We define a set of keys |piton/package| for these options. % \begin{macrocode} \keys_define:nn { piton / package } @@ -432,16 +449,24 @@ def fact(n): \endgroup % \end{macrocode} % -% \bigskip -% \begin{macrocode} -\msg_new:nnn { piton } { LuaLaTeX~mandatory } - { The~package~'piton'~must~be~used~with~LuaLaTeX.\\ It~won't~be~loaded. } -\sys_if_engine_luatex:F { \msg_critical:nn { piton } { LuaLaTeX~mandatory } } -% \end{macrocode} % % \bigskip % \begin{macrocode} -\RequirePackage { luatexbase } +\AtBeginDocument + { + \@ifpackageloaded { xcolor } + { } + { \msg_fatal:nn { piton } { xcolor~not~loaded } } + } +% \end{macrocode} +% +% \begin{macrocode} +\msg_new:nnn { piton } { xcolor~not~loaded } + { + xcolor~not~loaded \\ + The~package~'xcolor'~is~required~by~'piton'.\\ + This~error~is~fatal. + } % \end{macrocode} % % \bigskip @@ -477,7 +502,10 @@ def fact(n): % \medskip % \begin{macrocode} \cs_new_protected:Npn \@@_print_number: - { \bool_if:NT \l_@@_line_numbers_bool \@@_actually_print_number: } + { + \bool_if:NT \l_@@_line_numbers_bool + { \@@_actually_print_number: } + } % \end{macrocode} % % \medskip @@ -522,8 +550,8 @@ def fact(n): % % \bigskip % \begin{macrocode} -\cs_new_protected:Npn \@@_define_trim_syntax:n #1 - { \lua_now:n { define_trim_syntax(#1) } } +\cs_new_protected:Npn \@@_define_gobble_syntax:n #1 + { \lua_now:n { define_gobble_syntax(#1) } } % \end{macrocode} % % \bigskip @@ -561,26 +589,42 @@ def fact(n): % \end{macrocode} % % \begin{macrocode} -\keys_define:nn { piton / PitonOptions } +\keys_define:nn { PitonOptions } { gobble .int_set:N = \l_@@_gobble_int , gobble .value_required:n = true , auto-gobble .code:n = \int_set:Nn \l_@@_gobble_int { -1 } , auto-gobble .value_forbidden:n = true , + env-gobble .code:n = \int_set:Nn \l_@@_gobble_int { -2 } , + env-gobble .value_forbidden:n = true , line-numbers .bool_set:N = \l_@@_line_numbers_bool , line-numbers .default:n = true , all-line-numbers .code:n = \bool_set_true:N \l_@@_line_numbers_bool \bool_set_true:N \l_@@_all_line_numbers_bool , - all-line-numbers .value_forbidden:n = true + all-line-numbers .value_forbidden:n = true , + unknown .code:n = + \msg_error:nn { piton } { Unknown~key~for~PitonOptions } } % \end{macrocode} % +% \bigskip +% \begin{macrocode} +\msg_new:nnn { piton } { Unknown~key~for~PitonOptions } + { + Unknown~key \\ + The~key~'\l_keys_key_str'~is~unknown~for~\token_to_str:N \PitonOptions.~The~ + available~keys~are:~all-line-numbers,~auto-gobble,~env-gobble,~gobble~and~ + line-numbers.\\ + If~you~go~on,~that~key~will~be~ignored. + } +% \end{macrocode} +% % \bigskip % The argument of |\PitonOptions| is provided by currification. % \begin{macrocode} \NewDocumentCommand \PitonOptions { } - { \keys_set:nn { piton / PitonOptions } } + { \keys_set:nn { PitonOptions } } % \end{macrocode} % % \bigskip @@ -621,9 +665,11 @@ def fact(n): { \lua_now:e { Parse(token.scan_argument()) } } { -1 } { \lua_now:e { AutoGobbleParse(token.scan_argument()) } } + { -2 } + { \lua_now:e { EnvGobbleParse(token.scan_argument()) } } } { - \exp_args:NV \@@_define_trim_syntax:n \l_@@_gobble_int + \exp_args:NV \@@_define_gobble_syntax:n \l_@@_gobble_int \lua_now:e { GobbleParse(token.scan_argument()) } } { ##1 } @@ -639,22 +685,25 @@ def fact(n): % % % \bigskip -% We can now define the new environment by defining the two TeX macros -% characteristic to the LaTeX environment. +% We can now define the new environment. % \begin{macrocode} - \NewDocumentEnvironment { #1 } { #2 } + \NewDocumentEnvironment { #1 } { #2 } { #3 \group_begin: \tl_map_function:nN - { \ \\ \{ \} \$ \& \# \^ \_ \% \~ \^^M } + { \ \\ \{ \} \$ \& \# \^ \_ \% \~ } \char_set_catcode_other:N - \use:c { __piton_collect_ #1 :w } + \use:c { __piton_collect_ #1 :w } } { #4 } +% \end{macrocode} +% +% \begin{macrocode} + \AddToHook { env / #1 / begin } { \char_set_catcode_other:N \^^M } } % \end{macrocode} -% +% % \bigskip % \begin{macrocode} \NewPitonEnvironment { Piton } { } { } { } |