| 1 |
%% |
| 2 |
%% This is file `piton.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% piton-code.dtx (with options: `STY') |
| 8 |
%% ------------------------------------------- |
| 9 |
%% Copyright (C) 2022-2026 by F. Pantigny |
| 10 |
%% |
| 11 |
%% This file may be distributed and/or modified under the |
| 12 |
%% conditions of the LaTeX Project Public License, either |
| 13 |
%% version 1.3 of this license or (at your option) any later |
| 14 |
%% version. The latest version of this license is in: |
| 15 |
%% |
| 16 |
%% http://www.latex-project.org/lppl.txt |
| 17 |
%% |
| 18 |
%% and version 1.3 or later is part of all distributions of |
| 19 |
%% LaTeX version 2005/12/01 or later. |
| 20 |
%% ------------------------------------------- |
| 21 |
%% |
| 22 |
\def\PitonFileVersion{4.13} |
| 23 |
\def\PitonFileDate{2026/05/25} |
| 24 |
\NeedsTeXFormat{LaTeX2e} |
| 25 |
\ProvidesExplPackage |
| 26 |
{piton} |
| 27 |
{\PitonFileDate} |
| 28 |
{\PitonFileVersion} |
| 29 |
{Highlight computer listings with LPEG on LuaLaTeX} |
| 30 |
\msg_new:nnn { piton } { latex-too-old } |
| 31 |
{ |
| 32 |
Your~LaTeX~release~is~too~old. \\ |
| 33 |
You~need~at~least~the~version~of~2025-06-01. \\ |
| 34 |
If~you~use~Overleaf,~you~need~at~least~"TeX~Live~2025".\\ |
| 35 |
The~package~'piton'~won't~be~loaded. |
| 36 |
} |
| 37 |
\providecommand { \IfFormatAtLeastTF } { \@ifl@t@r \fmtversion } |
| 38 |
\IfFormatAtLeastTF |
| 39 |
{ 2025-06-01 } |
| 40 |
{ } |
| 41 |
{ \msg_critical:nn { piton } { latex-too-old } } |
| 42 |
\RequirePackage { amstext } |
| 43 |
\RequirePackage { marginalia } |
| 44 |
\RequirePackage { transparent } |
| 45 |
\cs_new_protected:Npn \__piton_error:n { \msg_error:nn { piton } } |
| 46 |
\cs_new_protected:Npn \__piton_warning:n { \msg_warning:nn { piton } } |
| 47 |
\cs_new_protected:Npn \__piton_warning:nn { \msg_warning:nnn { piton } } |
| 48 |
\cs_new_protected:Npn \__piton_error:nn { \msg_error:nnn { piton } } |
| 49 |
\cs_new_protected:Npn \__piton_error:nnn { \msg_error:nnnn { piton } } |
| 50 |
\cs_new_protected:Npn \__piton_fatal:n { \msg_fatal:nn { piton } } |
| 51 |
\cs_new_protected:Npn \__piton_fatal:nn { \msg_fatal:nnn { piton } } |
| 52 |
\cs_new_protected:Npn \__piton_msg_new:nn { \msg_new:nnn { piton } } |
| 53 |
\cs_new_protected:Npn \__piton_msg_new:nnn #1 #2 #3 |
| 54 |
{ |
| 55 |
\bool_if:NTF \g__piton_messages_for_Overleaf_bool |
| 56 |
{ \msg_new:nnn { piton } { #1 } { #2 \\ #3 } } |
| 57 |
{ \msg_new:nnnn { piton } { #1 } { #2 } { #3 } } |
| 58 |
} |
| 59 |
\cs_new_protected:Npn \__piton_error_or_warning:n |
| 60 |
{ \bool_if:NTF \g__piton_messages_for_Overleaf_bool \__piton_warning:n \__piton_error:n } |
| 61 |
\cs_new_protected:Npn \__piton_error_or_warning:nn |
| 62 |
{ \bool_if:NTF \g__piton_messages_for_Overleaf_bool \__piton_warning:nn \__piton_error:nn } |
| 63 |
\bool_new:N \g__piton_messages_for_Overleaf_bool |
| 64 |
\bool_gset:Nn \g__piton_messages_for_Overleaf_bool |
| 65 |
{ |
| 66 |
\str_if_eq_p:on \c_sys_jobname_str { _region_ } % for Emacs |
| 67 |
|| \str_if_eq_p:on \c_sys_jobname_str { output } % for Overleaf |
| 68 |
} |
| 69 |
\__piton_msg_new:nn { LuaLaTeX~mandatory } |
| 70 |
{ |
| 71 |
LuaLaTeX~is~mandatory.\\ |
| 72 |
The~package~'piton'~requires~the~engine~LuaLaTeX.\\ |
| 73 |
\str_if_eq:onT \c_sys_jobname_str { output } |
| 74 |
{ If~you~use~Overleaf,~you~can~switch~to~LuaLaTeX~in~ |
| 75 |
"File~>~Settings~>~Compiler"~and~if~you~use~TeXPage, |
| 76 |
~you~should~go~in~"Settings". \\ } |
| 77 |
\IfClassLoadedT { beamer } |
| 78 |
{ |
| 79 |
Since~you~use~Beamer,~don't~forget~to~use~piton~in~frames~with~ |
| 80 |
the~key~'fragile'.\\ |
| 81 |
} |
| 82 |
\IfClassLoadedT { ltx-talk } |
| 83 |
{ |
| 84 |
Since~you~use~'ltx-talk',~don't~forget~to~use~piton~in~ |
| 85 |
environments~'frame*'.\\ |
| 86 |
} |
| 87 |
} |
| 88 |
\sys_if_engine_luatex:F { \__piton_fatal:n { LuaLaTeX~mandatory } } |
| 89 |
\RequirePackage { luacode } |
| 90 |
\__piton_msg_new:nnn { piton.lua~not~found } |
| 91 |
{ |
| 92 |
The~file~'piton.lua'~can't~be~found.~ |
| 93 |
If~you~want~to~know~how~to~retrieve~the~file~'piton.lua',~type~H~<return>. |
| 94 |
} |
| 95 |
{ |
| 96 |
On~the~site~CTAN,~go~to~the~page~of~'piton':~https://ctan.org/pkg/piton.~ |
| 97 |
The~file~'README.md'~explains~how~to~retrieve~the~files~'piton.sty'~and~ |
| 98 |
'piton.lua'. |
| 99 |
} |
| 100 |
\file_if_exist:nF { piton.lua } { \__piton_fatal:n { piton.lua~not~found } } |
| 101 |
\keys_define:nn { piton } |
| 102 |
{ |
| 103 |
footnote .bool_gset:N = \g__piton_footnote_bool , |
| 104 |
footnotehyper .bool_gset:N = \g__piton_footnotehyper_bool , |
| 105 |
footnote .usage:n = load , |
| 106 |
footnotehyper .usage:n = load , |
| 107 |
|
| 108 |
beamer .bool_gset:N = \g__piton_beamer_bool , |
| 109 |
beamer .usage:n = load , |
| 110 |
|
| 111 |
unknown .code:n = \__piton_error:n { Unknown~key~for~package } |
| 112 |
} |
| 113 |
\__piton_msg_new:nn { Unknown~key~for~package } |
| 114 |
{ |
| 115 |
Unknown~key.\\ |
| 116 |
You~have~used~the~key~'\l_keys_key_str'~when~loading~piton~ |
| 117 |
but~the~only~keys~available~here~are~'beamer',~'footnote'~ |
| 118 |
and~'footnotehyper'.~Other~keys~are~available~in~ |
| 119 |
\token_to_str:N \PitonOptions.\\ |
| 120 |
That~key~will~be~ignored. |
| 121 |
} |
| 122 |
\ProcessKeyOptions |
| 123 |
\IfClassLoadedT { beamer } { \bool_gset_true:N \g__piton_beamer_bool } |
| 124 |
\IfClassLoadedT { ltx-talk } { \bool_gset_true:N \g__piton_beamer_bool } |
| 125 |
\IfPackageLoadedT { beamerarticle } { \bool_gset_true:N \g__piton_beamer_bool } |
| 126 |
\lua_now:e |
| 127 |
{ |
| 128 |
piton = piton~or~{ } |
| 129 |
piton.last_code = '' |
| 130 |
piton.last_language = '' |
| 131 |
piton.join = '' |
| 132 |
piton.write = '' |
| 133 |
piton.path_write = '' |
| 134 |
\bool_if:NT \g__piton_beamer_bool { piton.beamer = true } |
| 135 |
} |
| 136 |
\RequirePackage { xcolor } |
| 137 |
\__piton_msg_new:nn { footnote~with~footnotehyper~package } |
| 138 |
{ |
| 139 |
Footnote~forbidden.\\ |
| 140 |
You~can't~use~the~option~'footnote'~because~the~package~ |
| 141 |
footnotehyper~has~already~been~loaded.~ |
| 142 |
If~you~want,~you~can~use~the~option~'footnotehyper'~and~the~footnotes~ |
| 143 |
within~the~environments~of~piton~will~be~extracted~with~the~tools~ |
| 144 |
of~the~package~footnotehyper.\\ |
| 145 |
If~you~go~on,~the~package~footnote~won't~be~loaded. |
| 146 |
} |
| 147 |
\__piton_msg_new:nn { footnotehyper~with~footnote~package } |
| 148 |
{ |
| 149 |
You~can't~use~the~option~'footnotehyper'~because~the~package~ |
| 150 |
footnote~has~already~been~loaded.~ |
| 151 |
If~you~want,~you~can~use~the~option~'footnote'~and~the~footnotes~ |
| 152 |
within~the~environments~of~piton~will~be~extracted~with~the~tools~ |
| 153 |
of~the~package~footnote.\\ |
| 154 |
If~you~go~on,~the~package~footnotehyper~won't~be~loaded. |
| 155 |
} |
| 156 |
\bool_if:NT \g__piton_footnote_bool |
| 157 |
{ |
| 158 |
\IfClassLoadedTF { beamer } |
| 159 |
{ \bool_gset_false:N \g__piton_footnote_bool } |
| 160 |
{ |
| 161 |
\IfPackageLoadedTF { footnotehyper } |
| 162 |
{ \__piton_error:n { footnote~with~footnotehyper~package } } |
| 163 |
{ \usepackage { footnote } } |
| 164 |
} |
| 165 |
} |
| 166 |
\bool_if:NT \g__piton_footnotehyper_bool |
| 167 |
{ |
| 168 |
\IfClassLoadedTF { beamer } |
| 169 |
{ \bool_gset_false:N \g__piton_footnote_bool } |
| 170 |
{ |
| 171 |
\IfPackageLoadedTF { footnote } |
| 172 |
{ \__piton_error:n { footnotehyper~with~footnote~package } } |
| 173 |
{ \usepackage { footnotehyper } } |
| 174 |
\bool_gset_true:N \g__piton_footnote_bool |
| 175 |
} |
| 176 |
} |
| 177 |
\dim_new:N \l__piton_rounded_corners_dim |
| 178 |
\bool_new:N \l__piton_in_label_bool |
| 179 |
\dim_new:N \l__piton_tmpc_dim |
| 180 |
\tl_new:N \l__piton_listing_tl |
| 181 |
\box_new:N \g__piton_output_box |
| 182 |
\str_new:N \l_piton_language_str |
| 183 |
\str_set:Nn \l_piton_language_str { python } |
| 184 |
\tl_new:N \g_piton_last_code_tl |
| 185 |
\seq_new:N \l__piton_path_seq |
| 186 |
\seq_new:N \g__piton_join_seq |
| 187 |
\str_new:N \l__piton_join_str |
| 188 |
\dim_new:N \l__piton_tcb_margins_dim |
| 189 |
\str_new:N \l__piton_box_str |
| 190 |
\bool_new:N \l__piton_in_PitonOptions_bool |
| 191 |
\bool_new:N \l__piton_in_PitonInputFile_bool |
| 192 |
\int_new:N \g__piton_nb_lines_int |
| 193 |
\int_new:N \l__piton_nb_non_empty_lines_int |
| 194 |
\int_new:N \g__piton_line_int |
| 195 |
\clist_new:N \l__piton_bg_color_clist |
| 196 |
\int_new:N \l__piton_bg_colors_int |
| 197 |
\tl_new:N \l__piton_space_in_string_tl |
| 198 |
\str_new:N \l__piton_begin_range_str |
| 199 |
\str_new:N \l__piton_end_range_str |
| 200 |
\bool_new:N \g__piton_math_comments_bool |
| 201 |
\str_new:N \l__piton_file_name_str |
| 202 |
\bool_new:N \l__piton_tcolorbox_bool |
| 203 |
\bool_new:N \l__piton_paperclip_bool |
| 204 |
\str_new:N \l__piton_paperclip_str |
| 205 |
\int_new:N \g__piton_paperclip_int |
| 206 |
\bool_new:N \l__piton_show_spaces_bool |
| 207 |
\bool_new:N \l__piton_break_lines_in_piton_bool |
| 208 |
\bool_new:N \l__piton_minimize_width_bool |
| 209 |
\dim_new:N \l__piton_width_dim |
| 210 |
\dim_new:N \l__piton_listing_width_dim |
| 211 |
\dim_new:N \l__piton_code_width_dim |
| 212 |
\box_new:N \l__piton_line_box |
| 213 |
\dim_new:N \l__piton_left_margin_dim |
| 214 |
\dim_new:N \l__piton_right_margin_dim |
| 215 |
\bool_new:N \l__piton_left_margin_auto_bool |
| 216 |
\bool_new:N \l__piton_right_margin_auto_bool |
| 217 |
\bool_new:N \l__piton_lmodern_drawn_bool |
| 218 |
\seq_new:N \g__piton_visual_line_numbers_seq |
| 219 |
\seq_new:N \g__piton_languages_seq |
| 220 |
\cs_new_protected:Npn \__piton_tab: |
| 221 |
{ |
| 222 |
\bool_if:NTF \l__piton_show_spaces_bool |
| 223 |
{ |
| 224 |
\hbox_set:Nn \l_tmpa_box |
| 225 |
{ \prg_replicate:nn \l__piton_tab_size_int { ~ } } |
| 226 |
\dim_set:Nn \l_tmpa_dim { \box_wd:N \l_tmpa_box } |
| 227 |
\( \mathcolor { gray } |
| 228 |
{ \hbox_to_wd:nn \l_tmpa_dim { \rightarrowfill } } \) |
| 229 |
} |
| 230 |
{ \hbox:n { \prg_replicate:nn \l__piton_tab_size_int { ~ } } } |
| 231 |
\int_gadd:Nn \g__piton_indentation_int \l__piton_tab_size_int |
| 232 |
} |
| 233 |
\tl_set_eq:NN \l__piton_space_in_string_tl \nobreakspace |
| 234 |
\int_new:N \g__piton_indentation_int |
| 235 |
\cs_new_protected:Npn \__piton_label:n #1 |
| 236 |
{ |
| 237 |
\bool_if:NTF \l__piton_line_numbers_bool |
| 238 |
{ |
| 239 |
\@bsphack |
| 240 |
\protected@write \@auxout { } |
| 241 |
{ |
| 242 |
\string \newlabel { #1 } |
| 243 |
{ |
| 244 |
{ \int_use:N \g__piton_visual_line_int } |
| 245 |
{ \thepage } |
| 246 |
{ } |
| 247 |
{ line.#1 } |
| 248 |
{ } |
| 249 |
} |
| 250 |
} |
| 251 |
\@esphack |
| 252 |
\IfPackageLoadedT { hyperref } |
| 253 |
{ \Hy@raisedlink { \hyper@anchorstart { line.#1 } \hyper@anchorend } } |
| 254 |
} |
| 255 |
{ \__piton_error:n { label~with~lines~numbers } } |
| 256 |
} |
| 257 |
\cs_new_protected:Npn \__piton_zlabel:n #1 |
| 258 |
{ |
| 259 |
\bool_if:NTF \l__piton_line_numbers_bool |
| 260 |
{ |
| 261 |
\@bsphack |
| 262 |
\protected@write \@auxout { } |
| 263 |
{ |
| 264 |
\string \zref@newlabel { #1 } |
| 265 |
{ |
| 266 |
\string \default { \int_use:N \g__piton_visual_line_int } |
| 267 |
\string \page { \thepage } |
| 268 |
\string \zc@type { line } |
| 269 |
\string \anchor { line.#1 } |
| 270 |
} |
| 271 |
} |
| 272 |
\@esphack |
| 273 |
\IfPackageLoadedT { hyperref } |
| 274 |
{ \Hy@raisedlink { \hyper@anchorstart { line.#1 } \hyper@anchorend } } |
| 275 |
} |
| 276 |
{ \__piton_error:n { label~with~lines~numbers } } |
| 277 |
} |
| 278 |
\NewDocumentCommand { \__piton_rowcolor:n } { o m } |
| 279 |
{ |
| 280 |
\tl_gset:ce |
| 281 |
{ g__piton_color_ \int_eval:n { \g__piton_line_int + 1 } _ tl } |
| 282 |
{ \tl_if_novalue:nTF { #1 } { #2 } { [ #1 ] { #2 } } } |
| 283 |
\bool_gset_true:N \g__piton_rowcolor_inside_bool |
| 284 |
} |
| 285 |
\NewDocumentCommand { \__piton_noop_rowcolor } { o m } { } |
| 286 |
\cs_new:Npn \__piton_marker_beginning:n #1 { } |
| 287 |
\cs_new:Npn \__piton_marker_end:n #1 { } |
| 288 |
\tl_new:N \g__piton_after_line_tl |
| 289 |
\cs_new_protected:Npn \__piton_trailing_space: { } |
| 290 |
\bool_new:N \g__piton_color_is_none_bool |
| 291 |
\bool_new:N \g__piton_next_color_is_none_bool |
| 292 |
\bool_new:N \g__piton_rowcolor_inside_bool |
| 293 |
\clist_new:N \l__piton_detected_commands_clist |
| 294 |
\clist_new:N \l__piton_raw_detected_commands_clist |
| 295 |
\clist_new:N \l__piton_beamer_commands_clist |
| 296 |
\clist_set:Nn \l__piton_beamer_commands_clist |
| 297 |
{ uncover, only , visible , invisible , alert , action} |
| 298 |
\clist_new:N \l__piton_beamer_environments_clist |
| 299 |
\clist_set:Nn \l__piton_beamer_environments_clist |
| 300 |
{ uncoverenv , onlyenv , visibleenv , invisibleenv , alertenv , actionenv } |
| 301 |
\hook_gput_code:nnn { begindocument } { . } |
| 302 |
{ |
| 303 |
\newtoks \PitonDetectedCommands |
| 304 |
\newtoks \PitonRawDetectedCommands |
| 305 |
\newtoks \PitonBeamerCommands |
| 306 |
\newtoks \PitonBeamerEnvironments |
| 307 |
\exp_args:NV \PitonDetectedCommands \l__piton_detected_commands_clist |
| 308 |
\exp_args:NV \PitonRawDetectedCommands \l__piton_raw_detected_commands_clist |
| 309 |
\exp_args:NV \PitonBeamerCommands \l__piton_beamer_commands_clist |
| 310 |
\exp_args:NV \PitonBeamerEnvironments \l__piton_beamer_environments_clist |
| 311 |
} |
| 312 |
\tl_new:N \g__piton_def_vertical_commands_tl |
| 313 |
\cs_new:Npn \__piton_retrieve_backslash:n #1 |
| 314 |
{ |
| 315 |
\str_if_eq:eeTF \c_backslash_str { \str_head:n { #1 } } |
| 316 |
{ \str_tail:n { #1 } } |
| 317 |
{ #1 } |
| 318 |
} |
| 319 |
\cs_new_protected:Npn \__piton_detected_commands:n #1 |
| 320 |
{ |
| 321 |
\clist_set:Nn \l_tmpa_clist { #1 } |
| 322 |
\clist_clear:N \l_tmpb_clist |
| 323 |
\clist_map_inline:Nn \l_tmpa_clist |
| 324 |
{ \clist_put_right:Ne \l_tmpb_clist { \__piton_retrieve_backslash:n { ##1 } } } |
| 325 |
\clist_if_in:NnTF \l_tmpb_clist { rowcolor } |
| 326 |
{ |
| 327 |
\__piton_error:n { rowcolor~in~detected-commands } |
| 328 |
\clist_remove_all:Nn \l_tmpb_clist { rowcolor } |
| 329 |
} |
| 330 |
\clist_put_right:No \l__piton_detected_commands_clist \l_tmpb_clist |
| 331 |
} |
| 332 |
\cs_new_protected:Npn \__piton_raw_detected_commands:n #1 |
| 333 |
{ |
| 334 |
\clist_set:Nn \l_tmpa_clist { #1 } |
| 335 |
\clist_clear:N \l_tmpb_clist |
| 336 |
\clist_map_inline:Nn \l_tmpa_clist |
| 337 |
{ \clist_put_right:Ne \l_tmpb_clist { \__piton_retrieve_backslash:n { ##1 } } } |
| 338 |
\clist_put_right:No \l__piton_raw_detected_commands_clist \l_tmpb_clist |
| 339 |
} |
| 340 |
\cs_new_protected:Npn \__piton_vertical_detected_commands:n #1 |
| 341 |
{ |
| 342 |
\clist_set:Nn \l_tmpa_clist { #1 } |
| 343 |
\clist_clear:N \l_tmpb_clist |
| 344 |
\clist_map_inline:Nn \l_tmpa_clist |
| 345 |
{ \clist_put_right:Ne \l_tmpb_clist { \__piton_retrieve_backslash:n { ##1 } } } |
| 346 |
\clist_put_right:No \l__piton_raw_detected_commands_clist \l_tmpb_clist |
| 347 |
\clist_map_inline:Nn \l_tmpb_clist |
| 348 |
{ |
| 349 |
\cs_set_eq:cc { __piton _ old _ ##1 : } { ##1 } |
| 350 |
\cs_new_protected:cn { __piton _ new _ ##1 : n } |
| 351 |
{ |
| 352 |
\bool_if:nTF |
| 353 |
{ \l__piton_tcolorbox_bool || ! \str_if_empty_p:N \l__piton_box_str } |
| 354 |
{ |
| 355 |
\tl_gput_right:Nn \g__piton_after_line_tl |
| 356 |
{ \use:c { __piton _old _ ##1 : } { ####1 } } |
| 357 |
} |
| 358 |
{ |
| 359 |
\cs_if_exist:cTF { g__piton_after_line _ \int_use:N \g__piton_line_int } |
| 360 |
{ \tl_gput_right:cn } |
| 361 |
{ \tl_gset:cn } |
| 362 |
{ g__piton_after_line _ \int_eval:n { \g__piton_line_int + 1 }_tl } |
| 363 |
{ \use:c { __piton _old _ ##1 : } { ####1 } } |
| 364 |
} |
| 365 |
} |
| 366 |
\tl_gput_right:Nn \g__piton_def_vertical_commands_tl |
| 367 |
{ \cs_set_eq:cc { ##1 } { __piton _ new _ ##1 : n } } |
| 368 |
} |
| 369 |
} |
| 370 |
\cs_new_protected:Npn \__piton_replace_spaces:n #1 |
| 371 |
{ |
| 372 |
\tl_set:Nn \l_tmpa_tl { #1 } |
| 373 |
\bool_if:NTF \l__piton_show_spaces_bool |
| 374 |
{ |
| 375 |
\tl_set:Nn \l__piton_space_in_string_tl { ␣ } % U+2423 |
| 376 |
\tl_replace_all:NVn \l_tmpa_tl \c_catcode_other_space_tl { ␣ } % U+2423 |
| 377 |
} |
| 378 |
{ |
| 379 |
\bool_if:NT \l__piton_break_lines_in_Piton_bool |
| 380 |
{ |
| 381 |
\tl_if_eq:NnF \l__piton_space_in_string_tl { ␣ } |
| 382 |
{ \tl_set_eq:NN \l__piton_space_in_string_tl \__piton_breakable_space: } |
| 383 |
\tl_replace_all:NVn \l_tmpa_tl |
| 384 |
\c_catcode_other_space_tl |
| 385 |
\__piton_breakable_space: |
| 386 |
} |
| 387 |
} |
| 388 |
\l_tmpa_tl |
| 389 |
} |
| 390 |
\cs_generate_variant:Nn \__piton_replace_spaces:n { o } |
| 391 |
|
| 392 |
\cs_set_protected:Npn \__piton_end_line: { } |
| 393 |
\cs_set_protected:Npn \__piton_begin_line: #1 \__piton_end_line: |
| 394 |
{ |
| 395 |
\group_begin: |
| 396 |
\int_gzero:N \g__piton_indentation_int |
| 397 |
\hbox_set:Nn \l__piton_line_box |
| 398 |
{ |
| 399 |
\skip_horizontal:N \l__piton_left_margin_dim |
| 400 |
\bool_if:NT \l__piton_line_numbers_bool |
| 401 |
{ |
| 402 |
\int_set:Nn \l_tmpa_int |
| 403 |
{ |
| 404 |
\lua_now:e |
| 405 |
{ |
| 406 |
tex.sprint |
| 407 |
( |
| 408 |
piton.empty_lines |
| 409 |
[ \int_eval:n { \g__piton_line_int + 1 } ] |
| 410 |
) |
| 411 |
} |
| 412 |
} |
| 413 |
\bool_lazy_or:nnT |
| 414 |
{ \int_compare_p:nNn \l_tmpa_int = \c_one_int } |
| 415 |
{ ! \l__piton_skip_empty_lines_bool } |
| 416 |
{ \int_gincr:N \g__piton_visual_line_int } |
| 417 |
|
| 418 |
\bool_lazy_or:nnTF |
| 419 |
{ \int_compare_p:nNn \l_tmpa_int = \c_one_int } |
| 420 |
{ ! \l__piton_skip_empty_lines_bool && \l__piton_label_empty_lines_bool } |
| 421 |
{ |
| 422 |
\bool_lazy_or:nnTF |
| 423 |
{ \int_compare_p:nNn { \l__piton_numbers_step_int } = 1 } |
| 424 |
{ |
| 425 |
\int_compare_p:nNn |
| 426 |
{ |
| 427 |
\int_mod:nn |
| 428 |
{ \g__piton_visual_line_int } |
| 429 |
{ \l__piton_numbers_step_int } |
| 430 |
} |
| 431 |
= \c_one_int |
| 432 |
} |
| 433 |
{ |
| 434 |
\str_if_eq:eeTF \l__piton_line_numbers_position_str { left } |
| 435 |
\__piton_print_number_left: |
| 436 |
{ |
| 437 |
\seq_gput_right:Ne \g__piton_visual_line_numbers_seq |
| 438 |
{ \int_use:N \g__piton_visual_line_int } |
| 439 |
} |
| 440 |
} |
| 441 |
{ |
| 442 |
\str_if_eq:eeT \l__piton_line_numbers_position_str { right } |
| 443 |
{ \seq_gput_right:Nn \g__piton_visual_line_numbers_seq { } } |
| 444 |
} |
| 445 |
} |
| 446 |
{ |
| 447 |
\str_if_eq:eeT \l__piton_line_numbers_position_str { right } |
| 448 |
{ \seq_gput_right:Nn \g__piton_visual_line_numbers_seq { } } |
| 449 |
} |
| 450 |
} |
| 451 |
\int_compare:nNnT \l__piton_bg_colors_int > { \c_zero_int } |
| 452 |
{ |
| 453 |
\dim_compare:nNnT \l__piton_left_margin_dim = \c_zero_dim |
| 454 |
{ \skip_horizontal:n { 0.5 em } } |
| 455 |
} |
| 456 |
\bool_if:NTF \l__piton_minimize_width_bool |
| 457 |
{ |
| 458 |
\hbox_set:Nn \l_tmpa_box |
| 459 |
{ |
| 460 |
\language = -1 |
| 461 |
\raggedright |
| 462 |
\strut |
| 463 |
\__piton_replace_spaces:n { #1 } |
| 464 |
\strut \hfil |
| 465 |
} |
| 466 |
\dim_compare:nNnTF { \box_wd:N \l_tmpa_box } < \l__piton_code_width_dim |
| 467 |
{ \box_use:N \l_tmpa_box } |
| 468 |
{ \__piton_vtop_of_code:n { #1 } } |
| 469 |
} |
| 470 |
{ \__piton_vtop_of_code:n { #1 } } |
| 471 |
} |
| 472 |
\box_set_dp:Nn \l__piton_line_box { \box_dp:N \l__piton_line_box + 1.25 pt } |
| 473 |
\box_set_ht:Nn \l__piton_line_box { \box_ht:N \l__piton_line_box + 1.25 pt } |
| 474 |
\box_use_drop:N \l__piton_line_box |
| 475 |
\group_end: |
| 476 |
\g__piton_after_line_tl |
| 477 |
\tl_gclear:N \g__piton_after_line_tl |
| 478 |
} |
| 479 |
\cs_new_protected:Npn \__piton_vtop_of_code:n #1 |
| 480 |
{ |
| 481 |
\vbox_top:n |
| 482 |
{ |
| 483 |
\hsize = \l__piton_code_width_dim |
| 484 |
\language = -1 |
| 485 |
\raggedright |
| 486 |
\strut |
| 487 |
\__piton_replace_spaces:n { #1 } |
| 488 |
\strut \hfil |
| 489 |
} |
| 490 |
} |
| 491 |
\cs_new_protected:Npn \__piton_add_bg_and_right_nb_to_line_and_use: |
| 492 |
{ |
| 493 |
\vtop |
| 494 |
{ |
| 495 |
\offinterlineskip |
| 496 |
\hbox |
| 497 |
{ |
| 498 |
\group_begin: |
| 499 |
\__piton_compute_and_set_color: |
| 500 |
\dim_set:Nn \l_tmpa_dim { \box_dp:N \l__piton_line_box } |
| 501 |
\bool_if:NT \g__piton_next_color_is_none_bool |
| 502 |
{ \dim_sub:Nn \l_tmpa_dim { 2.5 pt } } |
| 503 |
\bool_if:NTF \g__piton_color_is_none_bool |
| 504 |
{ \dim_zero:N \l_tmpb_dim } |
| 505 |
{ \dim_set_eq:NN \l_tmpb_dim \l__piton_listing_width_dim } |
| 506 |
\dim_set:Nn \l__piton_tmpc_dim { \box_ht:N \l__piton_line_box } |
| 507 |
\dim_compare:nNnTF \l__piton_rounded_corners_dim > \c_zero_dim |
| 508 |
{ |
| 509 |
\int_compare:nNnTF \g__piton_line_int = \c_one_int |
| 510 |
{ |
| 511 |
\begin{tikzpicture}[baseline = 0cm] |
| 512 |
\fill (0,0) |
| 513 |
[rounded~corners = \l__piton_rounded_corners_dim] |
| 514 |
-- (0,\l__piton_tmpc_dim) |
| 515 |
-- (\l_tmpb_dim,\l__piton_tmpc_dim) |
| 516 |
[sharp~corners] -- (\l_tmpb_dim,-\l_tmpa_dim) |
| 517 |
-- (0,-\l_tmpa_dim) |
| 518 |
-- cycle ; |
| 519 |
\end{tikzpicture} |
| 520 |
} |
| 521 |
{ |
| 522 |
\int_compare:nNnTF \g__piton_line_int = \g__piton_nb_lines_int |
| 523 |
{ |
| 524 |
\begin{tikzpicture}[baseline = 0cm] |
| 525 |
\fill (0,0) -- (0,\l__piton_tmpc_dim) |
| 526 |
-- (\l_tmpb_dim,\l__piton_tmpc_dim) |
| 527 |
[rounded~corners = \l__piton_rounded_corners_dim] |
| 528 |
-- (\l_tmpb_dim,-\l_tmpa_dim) |
| 529 |
-- (0,-\l_tmpa_dim) |
| 530 |
-- cycle ; |
| 531 |
\end{tikzpicture} |
| 532 |
} |
| 533 |
{ |
| 534 |
\vrule height \l__piton_tmpc_dim |
| 535 |
depth \l_tmpa_dim |
| 536 |
width \l_tmpb_dim |
| 537 |
\dim_compare:nNnT \l_tmpb_dim = \c_zero_dim |
| 538 |
{ \skip_horizontal:N \l__piton_listing_width_dim } |
| 539 |
} |
| 540 |
} |
| 541 |
} |
| 542 |
{ |
| 543 |
\vrule height \l__piton_tmpc_dim |
| 544 |
depth \l_tmpa_dim |
| 545 |
width \l_tmpb_dim |
| 546 |
\dim_compare:nNnT \l_tmpb_dim = \c_zero_dim |
| 547 |
{ \skip_horizontal:N \l__piton_listing_width_dim } |
| 548 |
} |
| 549 |
\group_end: |
| 550 |
\bool_if:NT \l__piton_line_numbers_bool |
| 551 |
{ |
| 552 |
\str_if_eq:eeT \l__piton_line_numbers_position_str { right } |
| 553 |
{ |
| 554 |
\seq_gpop_right:NN \g__piton_visual_line_numbers_seq \l_tmpa_tl |
| 555 |
\__piton_print_number_right: |
| 556 |
} |
| 557 |
} |
| 558 |
} |
| 559 |
\bool_if:NT \g__piton_next_color_is_none_bool |
| 560 |
{ \skip_vertical:n { 2.5 pt } } |
| 561 |
\skip_vertical:n { - \box_ht_plus_dp:N \l__piton_line_box } |
| 562 |
\box_use_drop:N \l__piton_line_box |
| 563 |
} |
| 564 |
} |
| 565 |
\cs_set_protected:Npn \__piton_compute_and_set_color: |
| 566 |
{ |
| 567 |
\int_compare:nNnTF \l__piton_bg_colors_int = \c_zero_int |
| 568 |
{ \tl_set:Nn \l_tmpa_tl { none } } |
| 569 |
{ |
| 570 |
\int_set:Nn \l_tmpb_int |
| 571 |
{ \int_mod:nn \g__piton_line_int \l__piton_bg_colors_int + 1 } |
| 572 |
\tl_set:Ne \l_tmpa_tl { \clist_item:Nn \l__piton_bg_color_clist \l_tmpb_int } |
| 573 |
} |
| 574 |
\cs_if_exist:cT { g__piton_color_ \int_use:N \g__piton_line_int _ tl } |
| 575 |
{ |
| 576 |
\tl_set_eq:Nc \l_tmpa_tl { g__piton_color_ \int_use:N \g__piton_line_int _ tl} |
| 577 |
\cs_undefine:c { g__piton_color_ \int_use:N \g__piton_line_int _ tl} |
| 578 |
} |
| 579 |
\tl_if_eq:NnTF \l_tmpa_tl { none } |
| 580 |
{ \bool_gset_true:N \g__piton_color_is_none_bool } |
| 581 |
{ |
| 582 |
\bool_gset_false:N \g__piton_color_is_none_bool |
| 583 |
\__piton_color:o \l_tmpa_tl |
| 584 |
} |
| 585 |
\int_compare:nNnTF { \g__piton_line_int + 1 } = \g__piton_nb_lines_int |
| 586 |
{ \bool_gset_false:N \g__piton_next_color_is_none_bool } |
| 587 |
{ |
| 588 |
\int_compare:nNnTF \l__piton_bg_colors_int = \c_zero_int |
| 589 |
{ \tl_set:Nn \l_tmpa_tl { none } } |
| 590 |
{ |
| 591 |
\int_set:Nn \l_tmpb_int |
| 592 |
{ \int_mod:nn { \g__piton_line_int + 1 } \l__piton_bg_colors_int + 1 } |
| 593 |
\tl_set:Ne \l_tmpa_tl { \clist_item:Nn \l__piton_bg_color_clist \l_tmpb_int } |
| 594 |
} |
| 595 |
\cs_if_exist:cT { g__piton_color_ \int_eval:n { \g__piton_line_int + 1 } _ tl } |
| 596 |
{ |
| 597 |
\tl_set_eq:Nc \l_tmpa_tl |
| 598 |
{ g__piton_color_ \int_eval:n { \g__piton_line_int + 1 } _ tl } |
| 599 |
} |
| 600 |
\tl_if_eq:NnTF \l_tmpa_tl { none } |
| 601 |
{ \bool_gset_true:N \g__piton_next_color_is_none_bool } |
| 602 |
{ \bool_gset_false:N \g__piton_next_color_is_none_bool } |
| 603 |
} |
| 604 |
} |
| 605 |
\cs_set_protected:Npn \__piton_color:n #1 |
| 606 |
{ |
| 607 |
\tl_if_head_eq_meaning:nNTF { #1 } [ |
| 608 |
{ |
| 609 |
\tl_set:Nn \l_tmpa_tl { #1 } |
| 610 |
\tl_set_rescan:Nno \l_tmpa_tl { } \l_tmpa_tl |
| 611 |
\exp_last_unbraced:No \color \l_tmpa_tl |
| 612 |
} |
| 613 |
{ \color { #1 } } |
| 614 |
} |
| 615 |
\cs_generate_variant:Nn \__piton_color:n { o } |
| 616 |
\cs_new_protected:Npn \__piton_par: |
| 617 |
{ |
| 618 |
\int_gincr:N \g__piton_line_int |
| 619 |
\par |
| 620 |
\kern -2.5 pt |
| 621 |
\__piton_add_penalty_for_the_line: |
| 622 |
} |
| 623 |
\cs_set_protected:Npn \__piton_breakable_space: |
| 624 |
{ |
| 625 |
\discretionary |
| 626 |
{ \hbox:n { \color { gray } \l__piton_end_of_broken_line_tl } } |
| 627 |
{ |
| 628 |
\hbox_overlap_left:n |
| 629 |
{ |
| 630 |
{ |
| 631 |
\normalfont \footnotesize \color { gray } |
| 632 |
\l__piton_continuation_symbol_tl |
| 633 |
} |
| 634 |
\skip_horizontal:n { 0.3 em } |
| 635 |
\int_compare:nNnT \l__piton_bg_colors_int > \c_zero_int |
| 636 |
{ \skip_horizontal:n { 0.5 em } } |
| 637 |
} |
| 638 |
\bool_if:NT \l__piton_indent_broken_lines_bool |
| 639 |
{ |
| 640 |
\hbox:n |
| 641 |
{ |
| 642 |
\prg_replicate:nn { \g__piton_indentation_int } { ~ } |
| 643 |
{ \color { gray } \l__piton_csoi_tl } |
| 644 |
} |
| 645 |
} |
| 646 |
} |
| 647 |
{ \hbox { ~ } } |
| 648 |
} |
| 649 |
\bool_new:N \l__piton_line_numbers_bool |
| 650 |
\bool_new:N \l__piton_skip_empty_lines_bool |
| 651 |
\bool_set_true:N \l__piton_skip_empty_lines_bool |
| 652 |
\bool_new:N \l__piton_line_numbers_absolute_bool |
| 653 |
\tl_new:N \l__piton_line_numbers_format_tl |
| 654 |
\tl_set:Nn \l__piton_line_numbers_format_tl { \footnotesize \color { gray } } |
| 655 |
\bool_new:N \l__piton_label_empty_lines_bool |
| 656 |
\bool_set_true:N \l__piton_label_empty_lines_bool |
| 657 |
\int_new:N \l__piton_number_lines_start_int |
| 658 |
\str_new:N \l__piton_line_numbers_position_str |
| 659 |
\str_set:Nn \l__piton_line_numbers_position_str { left } |
| 660 |
\bool_new:N \l__piton_resume_bool |
| 661 |
\bool_new:N \g__piton_label_as_zlabel_bool |
| 662 |
\keys_define:nn { PitonOptions / marker } |
| 663 |
{ |
| 664 |
beginning .cs_set:Np = \__piton_marker_beginning:n #1 , |
| 665 |
beginning .value_required:n = true , |
| 666 |
end .cs_set:Np = \__piton_marker_end:n #1 , |
| 667 |
end .value_required:n = true , |
| 668 |
include-lines .bool_set:N = \l__piton_marker_include_lines_bool , |
| 669 |
unknown .code:n = \__piton_error:n { Unknown~key~for~marker } |
| 670 |
} |
| 671 |
\keys_define:nn { PitonOptions / line-numbers } |
| 672 |
{ |
| 673 |
true .code:n = \bool_set_true:N \l__piton_line_numbers_bool , |
| 674 |
false .code:n = \bool_set_false:N \l__piton_line_numbers_bool , |
| 675 |
|
| 676 |
start .code:n = |
| 677 |
\bool_set_true:N \l__piton_line_numbers_bool |
| 678 |
\int_set:Nn \l__piton_number_lines_start_int { #1 } , |
| 679 |
start .value_required:n = true , |
| 680 |
|
| 681 |
skip-empty-lines .code:n = |
| 682 |
\bool_if:NF \l__piton_in_PitonOptions_bool |
| 683 |
{ \bool_set_true:N \l__piton_line_numbers_bool } |
| 684 |
\str_if_eq:nnTF { #1 } { false } |
| 685 |
{ \bool_set_false:N \l__piton_skip_empty_lines_bool } |
| 686 |
{ \bool_set_true:N \l__piton_skip_empty_lines_bool } , |
| 687 |
|
| 688 |
label-empty-lines .code:n = |
| 689 |
\bool_if:NF \l__piton_in_PitonOptions_bool |
| 690 |
{ \bool_set_true:N \l__piton_line_numbers_bool } |
| 691 |
\str_if_eq:nnTF { #1 } { false } |
| 692 |
{ \bool_set_false:N \l__piton_label_empty_lines_bool } |
| 693 |
{ \bool_set_true:N \l__piton_label_empty_lines_bool } , |
| 694 |
|
| 695 |
absolute .code:n = |
| 696 |
\bool_if:NTF \l__piton_in_PitonOptions_bool |
| 697 |
{ \bool_set_true:N \l__piton_line_numbers_absolute_bool } |
| 698 |
{ \bool_set_true:N \l__piton_line_numbers_bool } |
| 699 |
\bool_if:NT \l__piton_in_PitonInputFile_bool |
| 700 |
{ |
| 701 |
\bool_set_true:N \l__piton_line_numbers_absolute_bool |
| 702 |
\bool_set_false:N \l__piton_skip_empty_lines_bool |
| 703 |
} , |
| 704 |
absolute .value_forbidden:n = true , |
| 705 |
|
| 706 |
resume .code:n = |
| 707 |
\bool_set_true:N \l__piton_resume_bool |
| 708 |
\bool_if:NF \l__piton_in_PitonOptions_bool |
| 709 |
{ \bool_set_true:N \l__piton_line_numbers_bool } , |
| 710 |
resume .value_forbidden:n = true , |
| 711 |
|
| 712 |
sep .dim_set:N = \l__piton_numbers_sep_dim , |
| 713 |
sep .value_required:n = true , |
| 714 |
sep .initial:n = 0.7 em , |
| 715 |
|
| 716 |
step .int_set:N = \l__piton_numbers_step_int , |
| 717 |
step .initial:n = 1 , |
| 718 |
step .value_required:n = true , |
| 719 |
|
| 720 |
position .choices:nn = { left , right } |
| 721 |
{ \str_set_eq:NN \l__piton_line_numbers_position_str \l_keys_choice_tl } , |
| 722 |
position .value_required:n = true , |
| 723 |
|
| 724 |
format .tl_set:N = \l__piton_line_numbers_format_tl , |
| 725 |
format .value_required:n = true , |
| 726 |
|
| 727 |
lmmono10-drawn .bool_set:N = \l__piton_lmodern_drawn_bool , |
| 728 |
lmmono10-drawn .default:n = true , |
| 729 |
|
| 730 |
unknown .code:n = |
| 731 |
\__piton_unknown_key:nn |
| 732 |
{ PitonOptions / line-numbers } |
| 733 |
{ Unknown~key~for~line-numbers } |
| 734 |
|
| 735 |
} |
| 736 |
\keys_define:nn { PitonOptions } |
| 737 |
{ |
| 738 |
indentations-for-Foxit .choices:nn = { true , false } |
| 739 |
{ |
| 740 |
\tl_if_eq:VnTF \l_keys_value_tl { true } |
| 741 |
{ \__piton_define_leading_space_Foxit: } |
| 742 |
{ \__piton_define_leading_space_normal: } |
| 743 |
} , |
| 744 |
box .choices:nn = { c , t , b , m } |
| 745 |
{ \str_set_eq:NN \l__piton_box_str \l_keys_choice_tl } , |
| 746 |
box .default:n = c , |
| 747 |
break-strings-anywhere .bool_set:N = \l__piton_break_strings_anywhere_bool , |
| 748 |
break-numbers-anywhere .bool_set:N = \l__piton_break_numbers_anywhere_bool , |
| 749 |
detected-commands .code:n = \__piton_detected_commands:n { #1 } , |
| 750 |
detected-commands .value_required:n = true , |
| 751 |
detected-commands .usage:n = preamble , |
| 752 |
vertical-detected-commands .code:n = \__piton_vertical_detected_commands:n { #1 } , |
| 753 |
vertical-detected-commands .value_required:n = true , |
| 754 |
vertical-detected-commands .usage:n = preamble , |
| 755 |
raw-detected-commands .code:n = \__piton_raw_detected_commands:n { #1 } , |
| 756 |
raw-detected-commands .value_required:n = true , |
| 757 |
raw-detected-commands .usage:n = preamble , |
| 758 |
detected-beamer-commands .code:n = |
| 759 |
\__piton_error_if_not_in_beamer: |
| 760 |
\clist_put_right:Nn \l__piton_beamer_commands_clist { #1 } , |
| 761 |
detected-beamer-commands .value_required:n = true , |
| 762 |
detected-beamer-commands .usage:n = preamble , |
| 763 |
detected-beamer-environments .code:n = |
| 764 |
\__piton_error_if_not_in_beamer: |
| 765 |
\clist_put_right:Nn \l__piton_beamer_environments_clist { #1 } , |
| 766 |
detected-beamer-environments .value_required:n = true , |
| 767 |
detected-beamer-environments .usage:n = preamble , |
| 768 |
begin-escape .code:n = |
| 769 |
\lua_now:e { piton.begin_escape = "\lua_escape:n{#1}" } , |
| 770 |
begin-escape .value_required:n = true , |
| 771 |
begin-escape .usage:n = preamble , |
| 772 |
|
| 773 |
end-escape .code:n = |
| 774 |
\lua_now:e { piton.end_escape = "\lua_escape:n{#1}" } , |
| 775 |
end-escape .value_required:n = true , |
| 776 |
end-escape .usage:n = preamble , |
| 777 |
|
| 778 |
begin-escape-math .code:n = |
| 779 |
\lua_now:e { piton.begin_escape_math = "\lua_escape:n{#1}" } , |
| 780 |
begin-escape-math .value_required:n = true , |
| 781 |
begin-escape-math .usage:n = preamble , |
| 782 |
|
| 783 |
end-escape-math .code:n = |
| 784 |
\lua_now:e { piton.end_escape_math = "\lua_escape:n{#1}" } , |
| 785 |
end-escape-math .value_required:n = true , |
| 786 |
end-escape-math .usage:n = preamble , |
| 787 |
|
| 788 |
comment-latex .code:n = \lua_now:n { comment_latex = "#1" } , |
| 789 |
comment-latex .value_required:n = true , |
| 790 |
comment-latex .usage:n = preamble , |
| 791 |
|
| 792 |
label-as-zlabel .bool_gset:N = \g__piton_label_as_zlabel_bool , |
| 793 |
label-as-zlabel .usage:n = preamble , |
| 794 |
|
| 795 |
math-comments .bool_gset:N = \g__piton_math_comments_bool , |
| 796 |
math-comments .usage:n = preamble , |
| 797 |
language .code:n = |
| 798 |
\str_set:Ne \l_piton_language_str { \str_lowercase:n { #1 } } , |
| 799 |
language .value_required:n = true , |
| 800 |
path .code:n = |
| 801 |
\seq_clear:N \l__piton_path_seq |
| 802 |
\clist_map_inline:nn { #1 } |
| 803 |
{ |
| 804 |
\str_set:Nn \l_tmpa_str { ##1 } |
| 805 |
\seq_put_right:No \l__piton_path_seq { \l_tmpa_str } |
| 806 |
} , |
| 807 |
path .value_required:n = true , |
| 808 |
path .initial:n = . , |
| 809 |
path-write .str_set:N = \l__piton_path_write_str , |
| 810 |
path-write .value_required:n = true , |
| 811 |
font-command .tl_set:N = \l__piton_font_command_tl , |
| 812 |
font-command .initial:n = \ttfamily , |
| 813 |
font-command .value_required:n = true , |
| 814 |
font-command+ .code:n |
| 815 |
= { \tl_put_right:Nn \l__piton_font_command_tl { #1 } } , |
| 816 |
font-command+ .value_required:n = true , |
| 817 |
font-command~+ .meta:n = { font-command+ = #1 } , |
| 818 |
font-command~+ .value_required:n = true , |
| 819 |
gobble .int_set:N = \l__piton_gobble_int , |
| 820 |
gobble .default:n = -1 , |
| 821 |
auto-gobble .code:n = \int_set:Nn \l__piton_gobble_int { -1 } , |
| 822 |
auto-gobble .value_forbidden:n = true , |
| 823 |
env-gobble .code:n = \int_set:Nn \l__piton_gobble_int { -2 } , |
| 824 |
env-gobble .value_forbidden:n = true , |
| 825 |
tabs-auto-gobble .code:n = \int_set:Nn \l__piton_gobble_int { -3 } , |
| 826 |
tabs-auto-gobble .value_forbidden:n = true , |
| 827 |
|
| 828 |
splittable-on-empty-lines .bool_set:N = \l__piton_splittable_on_empty_lines_bool , |
| 829 |
|
| 830 |
split-on-empty-lines .bool_set:N = \l__piton_split_on_empty_lines_bool , |
| 831 |
split-separation .tl_set:N = \l__piton_split_separation_tl , |
| 832 |
split-separation .value_required:n = true , |
| 833 |
split-separation .initial:n = \vspace { \baselineskip } \vspace { -1.25pt } , |
| 834 |
|
| 835 |
split-separation+ .code:n = |
| 836 |
\tl_put_right:Nn \l__piton_split_separation_tl { #1 } , |
| 837 |
split-separation+ .value_required:n = true , |
| 838 |
split-separation~+ .meta:n = { split-separation+ = #1 } , |
| 839 |
add-to-split-separation .meta:n = { split-separation+ = #1 } , |
| 840 |
|
| 841 |
marker .code:n = |
| 842 |
\bool_lazy_or:nnTF |
| 843 |
\l__piton_in_PitonInputFile_bool |
| 844 |
\l__piton_in_PitonOptions_bool |
| 845 |
{ \keys_set:nn { PitonOptions / marker } { #1 } } |
| 846 |
{ \__piton_error:n { Invalid~key } } , |
| 847 |
marker .value_required:n = true , |
| 848 |
|
| 849 |
line-numbers .code:n = |
| 850 |
\keys_set:nn { PitonOptions / line-numbers } { #1 } , |
| 851 |
line-numbers .default:n = true , |
| 852 |
splittable .int_set:N = \l__piton_splittable_int , |
| 853 |
splittable .default:n = 1 , |
| 854 |
splittable .initial:n = 100 , |
| 855 |
background-color .code:n = |
| 856 |
\clist_set:Nn \l__piton_bg_color_clist { #1 } |
| 857 |
\int_set:Nn \l__piton_bg_colors_int { \clist_count:N \l__piton_bg_color_clist } , |
| 858 |
background-color .value_required:n = true , |
| 859 |
prompt-background-color .tl_set:N = \l__piton_prompt_bg_color_tl , |
| 860 |
prompt-background-color .value_required:n = true , |
| 861 |
prompt-background-color .initial:n = gray!15 , |
| 862 |
print .bool_set:N = \l__piton_print_bool , |
| 863 |
print .value_required:n = true , |
| 864 |
print .initial:n = true , |
| 865 |
|
| 866 |
width .code:n = |
| 867 |
\str_if_eq:nnTF { #1 } { min } |
| 868 |
{ |
| 869 |
\bool_set_true:N \l__piton_minimize_width_bool |
| 870 |
\dim_zero:N \l__piton_width_dim |
| 871 |
} |
| 872 |
{ |
| 873 |
\bool_set_false:N \l__piton_minimize_width_bool |
| 874 |
\dim_set:Nn \l__piton_width_dim { #1 } |
| 875 |
} , |
| 876 |
width .value_required:n = true , |
| 877 |
|
| 878 |
max-width .code:n = |
| 879 |
\bool_set_true:N \l__piton_minimize_width_bool |
| 880 |
\dim_set:Nn \l__piton_width_dim { #1 } , |
| 881 |
max-width .value_required:n = true , |
| 882 |
|
| 883 |
paperclip .code:n = |
| 884 |
\bool_set_true:N \l__piton_paperclip_bool |
| 885 |
\tl_if_novalue:nTF { #1 } |
| 886 |
{ \str_set:Nn \l__piton_paperclip_str { } } |
| 887 |
{ \str_set:Nn \l__piton_paperclip_str { #1 } } , |
| 888 |
|
| 889 |
annotation .bool_set:N = \l__piton_annotation_bool , |
| 890 |
|
| 891 |
write .str_set:N = \l__piton_write_str , |
| 892 |
write .value_required:n = true , |
| 893 |
no-write .code:n = \str_set_eq:NN \l__piton_write_str \c_empty_str , |
| 894 |
no-write .value_forbidden:n = true , |
| 895 |
join .code:n = |
| 896 |
\str_set:Nn \l__piton_join_str { #1 } |
| 897 |
\seq_if_in:NnF \g__piton_join_seq { #1 } |
| 898 |
{ \seq_gput_right:No \g__piton_join_seq { #1 } } , |
| 899 |
join .value_required:n = true , |
| 900 |
join-separation .str_set:N = \l__piton_join_separation_str , |
| 901 |
join-separation .value_required:n = true , |
| 902 |
no-join .code:n = \str_set_eq:NN \l__piton_join_str \c_empty_str , |
| 903 |
no-join .value_forbidden:n = true , |
| 904 |
|
| 905 |
left-margin .code:n = |
| 906 |
\str_if_eq:nnTF { #1 } { auto } |
| 907 |
{ |
| 908 |
\dim_zero:N \l__piton_left_margin_dim |
| 909 |
\bool_set_true:N \l__piton_left_margin_auto_bool |
| 910 |
} |
| 911 |
{ |
| 912 |
\dim_set:Nn \l__piton_left_margin_dim { #1 } |
| 913 |
\bool_set_false:N \l__piton_left_margin_auto_bool |
| 914 |
} , |
| 915 |
left-margin .value_required:n = true , |
| 916 |
|
| 917 |
right-margin .code:n = |
| 918 |
\str_if_eq:nnTF { #1 } { auto } |
| 919 |
{ |
| 920 |
\dim_zero:N \l__piton_right_margin_dim |
| 921 |
\bool_set_true:N \l__piton_right_margin_auto_bool |
| 922 |
} |
| 923 |
{ |
| 924 |
\dim_set:Nn \l__piton_right_margin_dim { #1 } |
| 925 |
\bool_set_false:N \l__piton_right_margin_auto_bool |
| 926 |
} , |
| 927 |
right-margin .value_required:n = true , |
| 928 |
|
| 929 |
tab-size .int_set:N = \l__piton_tab_size_int , |
| 930 |
tab-size .value_required:n = true , |
| 931 |
tab-size .initial:n = 4 , |
| 932 |
|
| 933 |
show-spaces .bool_set:N = \l__piton_show_spaces_bool , |
| 934 |
show-spaces .value_forbidden:n = true , |
| 935 |
|
| 936 |
show-spaces-in-strings .code:n = |
| 937 |
\tl_set:Nn \l__piton_space_in_string_tl { ␣ } , % U+2423 |
| 938 |
show-spaces-in-strings .value_forbidden:n = true , |
| 939 |
|
| 940 |
break-lines-in-Piton .bool_set:N = \l__piton_break_lines_in_Piton_bool , |
| 941 |
break-lines-in-Piton .initial:n = true , |
| 942 |
|
| 943 |
break-lines-in-piton .bool_set:N = \l__piton_break_lines_in_piton_bool , |
| 944 |
|
| 945 |
break-lines .meta:n = { break-lines-in-piton , break-lines-in-Piton } , |
| 946 |
break-lines .value_forbidden:n = true , |
| 947 |
|
| 948 |
indent-broken-lines .bool_set:N = \l__piton_indent_broken_lines_bool , |
| 949 |
|
| 950 |
end-of-broken-line .tl_set:N = \l__piton_end_of_broken_line_tl , |
| 951 |
end-of-broken-line .value_required:n = true , |
| 952 |
end-of-broken-line .initial:n = \hspace* { 0.5em } \textbackslash , |
| 953 |
|
| 954 |
continuation-symbol .tl_set:N = \l__piton_continuation_symbol_tl , |
| 955 |
continuation-symbol .value_required:n = true , |
| 956 |
continuation-symbol .initial:n = + , |
| 957 |
|
| 958 |
continuation-symbol-on-indentation .tl_set:N = \l__piton_csoi_tl , |
| 959 |
continuation-symbol-on-indentation .value_required:n = true , |
| 960 |
continuation-symbol-on-indentation .initial:n = $\hookrightarrow \;$ , |
| 961 |
|
| 962 |
first-line .code:n = \__piton_in_PitonInputFile:n |
| 963 |
{ \int_set:Nn \l__piton_first_line_int { #1 } } , |
| 964 |
first-line .value_required:n = true , |
| 965 |
|
| 966 |
last-line .code:n = \__piton_in_PitonInputFile:n |
| 967 |
{ \int_set:Nn \l__piton_last_line_int { #1 } } , |
| 968 |
last-line .value_required:n = true , |
| 969 |
|
| 970 |
begin-range .code:n = \__piton_in_PitonInputFile:n |
| 971 |
{ \str_set:Nn \l__piton_begin_range_str { #1 } } , |
| 972 |
begin-range .value_required:n = true , |
| 973 |
|
| 974 |
end-range .code:n = \__piton_in_PitonInputFile:n |
| 975 |
{ \str_set:Nn \l__piton_end_range_str { #1 } } , |
| 976 |
end-range .value_required:n = true , |
| 977 |
|
| 978 |
range .code:n = \__piton_in_PitonInputFile:n |
| 979 |
{ |
| 980 |
\str_set:Nn \l__piton_begin_range_str { #1 } |
| 981 |
\str_set:Nn \l__piton_end_range_str { #1 } |
| 982 |
} , |
| 983 |
range .value_required:n = true , |
| 984 |
|
| 985 |
env-used-by-split .code:n = |
| 986 |
\lua_now:n { piton.env_used_by_split = '#1' } , |
| 987 |
env-used-by-split .initial:n = Piton , |
| 988 |
|
| 989 |
resume .meta:n = line-numbers/resume , |
| 990 |
|
| 991 |
unknown .code:n = |
| 992 |
\__piton_unknown_key:nn |
| 993 |
{ PitonOptions } |
| 994 |
{ Unknown~key~for~PitonOptions } , |
| 995 |
|
| 996 |
% deprecated |
| 997 |
all-line-numbers .code:n = |
| 998 |
\bool_set_true:N \l__piton_line_numbers_bool |
| 999 |
\bool_set_false:N \l__piton_skip_empty_lines_bool , |
| 1000 |
rounded-corners .code:n = |
| 1001 |
\AtBeginDocument |
| 1002 |
{ |
| 1003 |
\IfPackageLoadedTF { tikz } |
| 1004 |
{ \dim_set:Nn \l__piton_rounded_corners_dim { #1 } } |
| 1005 |
{ \__piton_err_rounded_corners_without_Tikz: } |
| 1006 |
} , |
| 1007 |
rounded-corners .default:n = 4 pt |
| 1008 |
} |
| 1009 |
\hook_gput_code:nnn { begindocument } { . } |
| 1010 |
{ |
| 1011 |
\IfPackageLoadedTF { tcolorbox } |
| 1012 |
{ |
| 1013 |
\pgfkeysifdefined { / tcb / libload / breakable } |
| 1014 |
{ |
| 1015 |
\keys_define:nn { PitonOptions } |
| 1016 |
{ |
| 1017 |
tcolorbox .bool_set:N = \l__piton_tcolorbox_bool , |
| 1018 |
} |
| 1019 |
} |
| 1020 |
{ |
| 1021 |
\keys_define:nn { PitonOptions } |
| 1022 |
{ tcolorbox .code:n = \__piton_error:n { library~breakable~not~loaded } } |
| 1023 |
} |
| 1024 |
} |
| 1025 |
{ |
| 1026 |
\keys_define:nn { PitonOptions } |
| 1027 |
{ tcolorbox .code:n = \__piton_error:n { tcolorbox~not~loaded } } |
| 1028 |
} |
| 1029 |
} |
| 1030 |
\cs_new_protected:Npn \__piton_err_rounded_corners_without_Tikz: |
| 1031 |
{ |
| 1032 |
\__piton_error:n { rounded-corners~without~Tikz } |
| 1033 |
\cs_gset:Npn \__piton_err_rounded_corners_without_Tikz: { } |
| 1034 |
} |
| 1035 |
\cs_new_protected:Npn \__piton_in_PitonInputFile:n #1 |
| 1036 |
{ |
| 1037 |
\bool_if:NTF \l__piton_in_PitonInputFile_bool |
| 1038 |
{ #1 } |
| 1039 |
{ \__piton_error:n { Invalid~key } } |
| 1040 |
} |
| 1041 |
\NewDocumentCommand \PitonOptions { m } |
| 1042 |
{ |
| 1043 |
\bool_set_true:N \l__piton_in_PitonOptions_bool |
| 1044 |
\keys_set:nn { PitonOptions } { #1 } |
| 1045 |
\bool_set_false:N \l__piton_in_PitonOptions_bool |
| 1046 |
} |
| 1047 |
\NewDocumentCommand \__piton_fake_PitonOptions { } |
| 1048 |
{ \keys_set:nn { PitonOptions } } |
| 1049 |
\int_new:N \g__piton_visual_line_int |
| 1050 |
\cs_new_protected:Npn \__piton_incr_visual_line: |
| 1051 |
{ \bool_if:NF \l__piton_skip_empty_lines_bool { \int_gincr:N \g__piton_visual_line_int } } |
| 1052 |
\cs_new_protected:Npn \__piton_print_number_left: |
| 1053 |
{ |
| 1054 |
\hbox_overlap_left:n |
| 1055 |
{ |
| 1056 |
\__piton_actually_print_number:n { \int_to_arabic:n { \g__piton_visual_line_int } } |
| 1057 |
\skip_horizontal:N \l__piton_numbers_sep_dim |
| 1058 |
} |
| 1059 |
} |
| 1060 |
\cs_new_protected:Npn \__piton_print_number_right: |
| 1061 |
{ |
| 1062 |
\hbox_overlap_left:n |
| 1063 |
{ |
| 1064 |
\__piton_actually_print_number:n { \l_tmpa_tl } |
| 1065 |
\int_compare:nNnT \l__piton_bg_colors_int > 0 |
| 1066 |
{ \skip_horizontal:n { 0.1 em } } |
| 1067 |
} |
| 1068 |
} |
| 1069 |
\cs_new_protected:Npn \__piton_actually_print_number:n #1 |
| 1070 |
{ |
| 1071 |
\group_begin: |
| 1072 |
\bool_if:NTF \l__piton_lmodern_drawn_bool |
| 1073 |
{ \l__piton_line_numbers_format_tl { \__piton_draw_number:e { #1 } } } |
| 1074 |
{ |
| 1075 |
\pdfextension literal { /Artifact << /ActualText (\space) >> BDC } |
| 1076 |
\l__piton_line_numbers_format_tl { #1 } |
| 1077 |
\pdfextension literal { EMC } |
| 1078 |
} |
| 1079 |
\group_end: |
| 1080 |
} |
| 1081 |
\NewDocumentCommand { \NewPitonLanguage } { O { } m ! o } |
| 1082 |
{ |
| 1083 |
\tl_if_novalue:nTF { #3 } |
| 1084 |
{ \__piton_NewPitonLanguage:nnn { #1 } { #2 } } |
| 1085 |
{ \__piton_NewPitonLanguage:nnnnn { #1 } { #2 } { #3 } } |
| 1086 |
} |
| 1087 |
\prop_new:N \g__piton_languages_prop |
| 1088 |
\keys_define:nn { NewPitonLanguage } |
| 1089 |
{ |
| 1090 |
morekeywords .code:n = , |
| 1091 |
otherkeywords .code:n = , |
| 1092 |
sensitive .code:n = , |
| 1093 |
keywordsprefix .code:n = , |
| 1094 |
moretexcs .code:n = , |
| 1095 |
morestring .code:n = , |
| 1096 |
morecomment .code:n = , |
| 1097 |
moredelim .code:n = , |
| 1098 |
moredirectives .code:n = , |
| 1099 |
tag .code:n = , |
| 1100 |
alsodigit .code:n = , |
| 1101 |
alsoletter .code:n = , |
| 1102 |
alsoother .code:n = , |
| 1103 |
unknown .code:n = \__piton_error:n { Unknown~key~NewPitonLanguage } |
| 1104 |
} |
| 1105 |
\cs_new_protected:Npn \__piton_NewPitonLanguage:nnn #1 #2 #3 |
| 1106 |
{ |
| 1107 |
\tl_set:Ne \l_tmpa_tl |
| 1108 |
{ |
| 1109 |
\tl_if_blank:nF { #1 } { [ \str_lowercase:n { #1 } ] } |
| 1110 |
\str_lowercase:n { #2 } |
| 1111 |
} |
| 1112 |
\keys_set:nn { NewPitonLanguage } { #3 } |
| 1113 |
\prop_gput:Non \g__piton_languages_prop \l_tmpa_tl { #3 } |
| 1114 |
\__piton_NewPitonLanguage:on \l_tmpa_tl { #3 } |
| 1115 |
} |
| 1116 |
\cs_new_protected:Npn \__piton_NewPitonLanguage:nn #1 #2 |
| 1117 |
{ |
| 1118 |
\hook_gput_code:nnn { begindocument } { . } |
| 1119 |
{ \lua_now:e { piton.new_language("#1","\lua_escape:n{#2}") } } |
| 1120 |
} |
| 1121 |
\cs_generate_variant:Nn \__piton_NewPitonLanguage:nn { o } |
| 1122 |
\cs_new_protected:Npn \__piton_NewPitonLanguage:nnnnn #1 #2 #3 #4 #5 |
| 1123 |
{ |
| 1124 |
\tl_set:Ne \l_tmpa_tl |
| 1125 |
{ |
| 1126 |
\tl_if_blank:nF { #3 } { [ \str_lowercase:n { #3 } ] } |
| 1127 |
\str_lowercase:n { #4 } |
| 1128 |
} |
| 1129 |
\prop_get:NoNTF \g__piton_languages_prop \l_tmpa_tl \l_tmpb_tl |
| 1130 |
{ \__piton_NewPitonLanguage:nnno { #1 } { #2 } { #5 } \l_tmpb_tl } |
| 1131 |
{ \__piton_error:n { Language~not~defined } } |
| 1132 |
} |
| 1133 |
\cs_new_protected:Npn \__piton_NewPitonLanguage:nnnn #1 #2 #3 #4 |
| 1134 |
{ \__piton_NewPitonLanguage:nnn { #1 } { #2 } { #4 , #3 } } |
| 1135 |
\cs_generate_variant:Nn \__piton_NewPitonLanguage:nnnn { n n n o } |
| 1136 |
\NewDocumentCommand { \piton } { } |
| 1137 |
{ \peek_meaning:NTF \bgroup { \__piton_piton_standard } { \__piton_piton_verbatim } } |
| 1138 |
\NewDocumentCommand { \__piton_piton_standard } { m } |
| 1139 |
{ |
| 1140 |
\group_begin: |
| 1141 |
\tl_if_eq:NnF \l__piton_space_in_string_tl { ␣ } |
| 1142 |
{ |
| 1143 |
\bool_lazy_or:nnT |
| 1144 |
\l__piton_break_lines_in_piton_bool |
| 1145 |
\l__piton_break_strings_anywhere_bool |
| 1146 |
{ \tl_set:Nn \l__piton_space_in_string_tl { \exp_not:N \space } } |
| 1147 |
} |
| 1148 |
\automatichyphenmode = 1 |
| 1149 |
\cs_set_eq:NN \\ \c_backslash_str |
| 1150 |
\cs_set_eq:NN \% \c_percent_str |
| 1151 |
\cs_set_eq:NN \{ \c_left_brace_str |
| 1152 |
\cs_set_eq:NN \} \c_right_brace_str |
| 1153 |
\cs_set_eq:NN \$ \c_dollar_str |
| 1154 |
\cs_set_eq:cN { ~ } \space |
| 1155 |
\cs_set_eq:NN \__piton_begin_line: \prg_do_nothing: |
| 1156 |
\cs_set_eq:NN \rowcolor \__piton_noop_rowcolor |
| 1157 |
\tl_set:Ne \l_tmpa_tl |
| 1158 |
{ |
| 1159 |
\lua_now:e |
| 1160 |
{ piton.ParseBis('\l_piton_language_str',token.scan_string()) } |
| 1161 |
{ #1 } |
| 1162 |
} |
| 1163 |
\bool_if:NTF \l__piton_show_spaces_bool |
| 1164 |
{ \tl_replace_all:NVn \l_tmpa_tl \c_catcode_other_space_tl { ␣ } } % U+2423 |
| 1165 |
{ |
| 1166 |
\bool_if:NT \l__piton_break_lines_in_piton_bool |
| 1167 |
{ \tl_replace_all:NVn \l_tmpa_tl \c_catcode_other_space_tl \space } |
| 1168 |
} |
| 1169 |
\if_mode_math: |
| 1170 |
\text { \l__piton_font_command_tl \l_tmpa_tl } |
| 1171 |
\else: |
| 1172 |
\l__piton_font_command_tl \l_tmpa_tl |
| 1173 |
\fi: |
| 1174 |
\group_end: |
| 1175 |
} |
| 1176 |
\NewDocumentCommand { \__piton_piton_verbatim } { v } |
| 1177 |
{ |
| 1178 |
\group_begin: |
| 1179 |
\automatichyphenmode = 1 |
| 1180 |
\cs_set_eq:NN \__piton_begin_line: \prg_do_nothing: |
| 1181 |
\cs_set_eq:NN \rowcolor \__piton_noop_rowcolor |
| 1182 |
\tl_set:Ne \l_tmpa_tl |
| 1183 |
{ |
| 1184 |
\lua_now:e |
| 1185 |
{ piton.Parse('\l_piton_language_str',token.scan_string()) } |
| 1186 |
{ #1 } |
| 1187 |
} |
| 1188 |
\bool_if:NT \l__piton_show_spaces_bool |
| 1189 |
{ \tl_replace_all:NVn \l_tmpa_tl \c_catcode_other_space_tl { ␣ } } % U+2423 |
| 1190 |
\if_mode_math: |
| 1191 |
\text { \l__piton_font_command_tl \l_tmpa_tl } |
| 1192 |
\else: |
| 1193 |
\l__piton_font_command_tl \l_tmpa_tl |
| 1194 |
\fi: |
| 1195 |
\group_end: |
| 1196 |
} |
| 1197 |
|
| 1198 |
\cs_new_protected:Npn \__piton_piton:n #1 |
| 1199 |
{ \tl_if_blank:nF { #1 } { \__piton_piton_i:n { #1 } } } |
| 1200 |
|
| 1201 |
\cs_new_protected:Npn \__piton_piton_i:n #1 |
| 1202 |
{ |
| 1203 |
\group_begin: |
| 1204 |
\cs_set_eq:NN \__piton_begin_line: \prg_do_nothing: |
| 1205 |
\cs_set:cpn { pitonStyle _ \l_piton_language_str _ Prompt } { } |
| 1206 |
\cs_set:cpn { pitonStyle _ Prompt } { } |
| 1207 |
\cs_set_eq:NN \__piton_leading_space: \space |
| 1208 |
\cs_set_eq:NN \__piton_trailing_space: \space |
| 1209 |
\tl_set:Ne \l_tmpa_tl |
| 1210 |
{ |
| 1211 |
\lua_now:e |
| 1212 |
{ piton.ParseTer('\l_piton_language_str',token.scan_string()) } |
| 1213 |
{ #1 } |
| 1214 |
} |
| 1215 |
\bool_if:NT \l__piton_show_spaces_bool |
| 1216 |
{ \tl_replace_all:NVn \l_tmpa_tl \c_catcode_other_space_tl { ␣ } } % U+2423 |
| 1217 |
\__piton_replace_spaces:o \l_tmpa_tl |
| 1218 |
\group_end: |
| 1219 |
} |
| 1220 |
\cs_new_protected:Npn \__piton_pre_composition: |
| 1221 |
{ |
| 1222 |
\dim_compare:nNnT \l__piton_width_dim = \c_zero_dim |
| 1223 |
{ |
| 1224 |
\dim_set_eq:NN \l__piton_width_dim \linewidth |
| 1225 |
\str_if_empty:NF \l__piton_box_str |
| 1226 |
{ \bool_set_true:N \l__piton_minimize_width_bool } |
| 1227 |
} |
| 1228 |
\dim_set:Nn \l__piton_listing_width_dim |
| 1229 |
{ |
| 1230 |
\bool_if:NTF \l__piton_tcolorbox_bool |
| 1231 |
{ |
| 1232 |
\l__piton_width_dim - |
| 1233 |
( \kvtcb@left@rule |
| 1234 |
+ \kvtcb@leftupper |
| 1235 |
+ \kvtcb@boxsep * 2 |
| 1236 |
+ \kvtcb@rightupper |
| 1237 |
+ \kvtcb@right@rule ) |
| 1238 |
} |
| 1239 |
{ \l__piton_width_dim } |
| 1240 |
} |
| 1241 |
\legacy_if:nT { @inlabel } { \bool_set_true:N \l__piton_in_label_bool } |
| 1242 |
\automatichyphenmode = 1 |
| 1243 |
\bool_if:NF \l__piton_resume_bool { \int_gzero:N \g__piton_visual_line_int } |
| 1244 |
\g__piton_def_vertical_commands_tl |
| 1245 |
\int_gzero:N \g__piton_line_int |
| 1246 |
\int_gzero:N \g__piton_nb_lines_int |
| 1247 |
\dim_zero:N \parindent |
| 1248 |
\dim_zero:N \lineskip |
| 1249 |
\dim_zero:N \parskip |
| 1250 |
|
| 1251 |
\seq_gclear:N \g__piton_visual_line_numbers_seq |
| 1252 |
|
| 1253 |
\cs_set_eq:NN \rowcolor \__piton_rowcolor:n |
| 1254 |
\int_compare:nNnT \l__piton_bg_colors_int > { \c_zero_int } |
| 1255 |
{ \bool_set_true:N \l__piton_bg_bool } |
| 1256 |
\bool_gset_false:N \g__piton_rowcolor_inside_bool |
| 1257 |
\IfPackageLoadedTF { zref-base } |
| 1258 |
{ |
| 1259 |
\bool_if:NTF \g__piton_label_as_zlabel_bool |
| 1260 |
{ \cs_set_eq:NN \label \__piton_zlabel:n } |
| 1261 |
{ \cs_set_eq:NN \label \__piton_label:n } |
| 1262 |
\cs_set_eq:NN \zlabel \__piton_zlabel:n |
| 1263 |
} |
| 1264 |
{ \cs_set_eq:NN \label \__piton_label:n } |
| 1265 |
\l__piton_font_command_tl |
| 1266 |
} |
| 1267 |
|
| 1268 |
\cs_new_protected:Npn \__piton_compute_margin:N #1 |
| 1269 |
{ |
| 1270 |
\use:e |
| 1271 |
{ |
| 1272 |
\bool_if:NTF \l__piton_skip_empty_lines_bool |
| 1273 |
{ \lua_now:n { piton.CountNonEmptyLines(token.scan_argument()) } } |
| 1274 |
{ \lua_now:n { piton.CountLines(token.scan_argument()) } } |
| 1275 |
{ \l__piton_listing_tl } |
| 1276 |
} |
| 1277 |
\hbox_set:Nn \l_tmpa_box |
| 1278 |
{ |
| 1279 |
\l__piton_line_numbers_format_tl |
| 1280 |
\int_to_arabic:n |
| 1281 |
{ |
| 1282 |
\g__piton_visual_line_int |
| 1283 |
+ |
| 1284 |
\bool_if:NTF \l__piton_skip_empty_lines_bool |
| 1285 |
{ \l__piton_nb_non_empty_lines_int } |
| 1286 |
{ \g__piton_nb_lines_int } |
| 1287 |
} |
| 1288 |
} |
| 1289 |
\dim_set:Nn #1 { \box_wd:N \l_tmpa_box + \l__piton_numbers_sep_dim + 0.1 em } |
| 1290 |
} |
| 1291 |
\cs_new_protected:Npn \__piton_compute_code_width: |
| 1292 |
{ |
| 1293 |
\dim_set:Nn \l__piton_code_width_dim |
| 1294 |
{ |
| 1295 |
\l__piton_listing_width_dim |
| 1296 |
- |
| 1297 |
( |
| 1298 |
\int_compare:nNnTF \l__piton_bg_colors_int > { \c_zero_int } |
| 1299 |
{ |
| 1300 |
\dim_compare:nNnTF \l__piton_left_margin_dim > \c_zero_dim |
| 1301 |
{ \l__piton_left_margin_dim } |
| 1302 |
{ 0.5 em } |
| 1303 |
+ |
| 1304 |
\dim_compare:nNnTF \l__piton_right_margin_dim > \c_zero_dim |
| 1305 |
{ \l__piton_right_margin_dim } |
| 1306 |
{ 0.5 em } |
| 1307 |
} |
| 1308 |
{ \l__piton_left_margin_dim + \l__piton_right_margin_dim } |
| 1309 |
) |
| 1310 |
} |
| 1311 |
} |
| 1312 |
\cs_new_protected:Npn \__piton_recompute_listing_width: |
| 1313 |
{ |
| 1314 |
\dim_set:Nn \l__piton_listing_width_dim |
| 1315 |
{ |
| 1316 |
\box_wd:N \g__piton_output_box |
| 1317 |
+ |
| 1318 |
\int_compare:nNnTF \l__piton_bg_colors_int > \c_zero_int |
| 1319 |
{ |
| 1320 |
\dim_compare:nNnTF \l__piton_left_margin_dim > \c_zero_dim |
| 1321 |
{ \l__piton_left_margin_dim } |
| 1322 |
{ 0.5 em } |
| 1323 |
+ |
| 1324 |
\dim_compare:nNnTF \l__piton_right_margin_dim > \c_zero_dim |
| 1325 |
{ \l__piton_right_margin_dim } |
| 1326 |
{ 0.5 em } |
| 1327 |
} |
| 1328 |
{ \l__piton_left_margin_dim + \l__piton_right_margin_dim } |
| 1329 |
} |
| 1330 |
} |
| 1331 |
\cs_new_protected:Npn \__piton_store_body:n #1 |
| 1332 |
{ |
| 1333 |
\tl_set:Ne \obeyedline { \char_generate:nn { 13 } { 11 } } |
| 1334 |
\tl_set:Ne \l__piton_listing_tl { #1 } |
| 1335 |
\tl_set_eq:NN \ProcessedArgument \l__piton_listing_tl |
| 1336 |
} |
| 1337 |
\cs_new_protected:Nn \__piton_DefinePitonEnvironment:nnnnn |
| 1338 |
{ |
| 1339 |
\use:c { #1 DocumentEnvironment } { #2 } { #3 > { \__piton_store_body:n } c } |
| 1340 |
{ |
| 1341 |
\cs_set_eq:NN \PitonOptions \__piton_fake_PitonOptions |
| 1342 |
#4 |
| 1343 |
\__piton_pre_composition: |
| 1344 |
\int_compare:nNnT { \l__piton_number_lines_start_int } > { \c_zero_int } |
| 1345 |
{ |
| 1346 |
\int_gset:Nn \g__piton_visual_line_int |
| 1347 |
{ \l__piton_number_lines_start_int - 1 } |
| 1348 |
} |
| 1349 |
\bool_if:NT \g__piton_beamer_bool |
| 1350 |
{ \__piton_translate_beamer_env:o { \l__piton_listing_tl } } |
| 1351 |
\bool_if:NT \g__piton_footnote_bool \savenotes |
| 1352 |
\__piton_composition: |
| 1353 |
\bool_lazy_or:nnT { \l__piton_paperclip_bool } { \l__piton_annotation_bool } |
| 1354 |
{ \__piton_create_paperclip_annotation: } |
| 1355 |
\bool_if:NT \g__piton_footnote_bool \endsavenotes |
| 1356 |
#5 |
| 1357 |
} |
| 1358 |
{ \ignorespacesafterend } |
| 1359 |
} |
| 1360 |
\cs_new_protected:Npn \__piton_create_paperclip_annotation: |
| 1361 |
{ |
| 1362 |
\marginalia |
| 1363 |
{ |
| 1364 |
\vspace* { - 0.8 em } |
| 1365 |
\hbox:n |
| 1366 |
{ |
| 1367 |
\vrule~height~0~pt~depth~12~pt~width~0~pt |
| 1368 |
\bool_if:NT \l__piton_annotation_bool |
| 1369 |
{ |
| 1370 |
\lua_now:n |
| 1371 |
{ |
| 1372 |
pdf.immediateobj |
| 1373 |
( "<" .. piton.utf16 ( piton.get_last_code ( ) ) .. ">" ) |
| 1374 |
} |
| 1375 |
\pdfextension annot~width~5pt~height~10pt~depth~0pt |
| 1376 |
{ |
| 1377 |
/Subtype /Text |
| 1378 |
/Contents~\pdf_object_ref_last: |
| 1379 |
/Name /Note |
| 1380 |
/Subj (Computer~listing) |
| 1381 |
/ReplyType /Group |
| 1382 |
/F~512 |
| 1383 |
/C [0.8~0.8~0.8] |
| 1384 |
} |
| 1385 |
\hspace* { 7 mm } |
| 1386 |
} |
| 1387 |
\bool_if:NT \l__piton_paperclip_bool { \__piton_create_paperclip: } |
| 1388 |
} |
| 1389 |
} |
| 1390 |
} |
| 1391 |
\cs_new_protected:Npn \__piton_create_paperclip: |
| 1392 |
{ |
| 1393 |
\str_if_empty:NT \l__piton_paperclip_str |
| 1394 |
{ |
| 1395 |
\int_gincr:N \g__piton_paperclip_int |
| 1396 |
\str_set:Ne \l__piton_paperclip_str { listing_\int_use:N \g__piton_paperclip_int .txt } |
| 1397 |
} |
| 1398 |
\lua_now:n { pdf.immediateobj ( "stream" , tostring ( piton.get_last_code() ) ) } |
| 1399 |
\box_move_down:nn |
| 1400 |
{ 10 pt } |
| 1401 |
{ |
| 1402 |
\hbox:n |
| 1403 |
{ |
| 1404 |
\pdfextension annot~width~10pt~height~20pt~depth~0pt |
| 1405 |
{ |
| 1406 |
/Subtype /FileAttachment |
| 1407 |
/Name /Paperclip |
| 1408 |
/F~8 % no zoom |
| 1409 |
/Contents (The~computer~listing) |
| 1410 |
/FS << |
| 1411 |
/Type /Filespec |
| 1412 |
/F (\l__piton_paperclip_str) |
| 1413 |
/EF << /F~\pdf_object_ref_last: >> |
| 1414 |
/AFRelationship /Supplement |
| 1415 |
>> |
| 1416 |
} |
| 1417 |
} |
| 1418 |
} |
| 1419 |
} |
| 1420 |
\NewDocumentCommand { \NewPitonEnvironment } { } |
| 1421 |
{ \__piton_DefinePitonEnvironment:nnnnn { New } } |
| 1422 |
\NewDocumentCommand { \DeclarePitonEnvironment } { } |
| 1423 |
{ \__piton_DefinePitonEnvironment:nnnnn { Declare } } |
| 1424 |
\NewDocumentCommand { \RenewPitonEnvironment } { } |
| 1425 |
{ \__piton_DefinePitonEnvironment:nnnnn { Renew } } |
| 1426 |
\NewDocumentCommand { \ProvidePitonEnvironment } { } |
| 1427 |
{ \__piton_DefinePitonEnvironment:nnnnn { Provide } } |
| 1428 |
\cs_new_protected:Npn \__piton_translate_beamer_env:n |
| 1429 |
{ \lua_now:e { piton.TranslateBeamerEnv(token.scan_argument ( ) ) } } |
| 1430 |
\cs_generate_variant:Nn \__piton_translate_beamer_env:n { o } |
| 1431 |
\cs_new_protected:Npn \__piton_composition: |
| 1432 |
{ |
| 1433 |
\str_if_empty:NT \l__piton_box_str |
| 1434 |
{ |
| 1435 |
\mode_if_vertical:F |
| 1436 |
{ \bool_if:NF \l__piton_in_PitonInputFile_bool { \newline } } |
| 1437 |
} |
| 1438 |
\bool_if:NT \l__piton_line_numbers_bool |
| 1439 |
{ |
| 1440 |
\bool_lazy_and:nnT |
| 1441 |
{ \l__piton_left_margin_auto_bool } |
| 1442 |
{ \str_if_eq_p:ee \l__piton_line_numbers_position_str { left } } |
| 1443 |
{ \__piton_compute_margin:N \l__piton_left_margin_dim } |
| 1444 |
\bool_lazy_and:nnT |
| 1445 |
{ \l__piton_right_margin_auto_bool } |
| 1446 |
{ \str_if_eq_p:ee \l__piton_line_numbers_position_str { right } } |
| 1447 |
{ \__piton_compute_margin:N \l__piton_right_margin_dim } |
| 1448 |
} |
| 1449 |
\lua_now:e |
| 1450 |
{ |
| 1451 |
piton.join_separation = "\l__piton_join_separation_str" |
| 1452 |
piton.join = "\l__piton_join_str" |
| 1453 |
piton.write = "\l__piton_write_str" |
| 1454 |
piton.path_write = "\l__piton_path_write_str" |
| 1455 |
} |
| 1456 |
\noindent |
| 1457 |
\bool_if:NTF \l__piton_print_bool |
| 1458 |
{ |
| 1459 |
\bool_if:NTF \l__piton_split_on_empty_lines_bool |
| 1460 |
{ \par \__piton_retrieve_gobble_split_parse:o \l__piton_listing_tl } |
| 1461 |
{ |
| 1462 |
\__piton_create_output_box: |
| 1463 |
\bool_if:NTF \l__piton_tcolorbox_bool |
| 1464 |
{ |
| 1465 |
\str_if_empty:NTF \l__piton_box_str |
| 1466 |
\__piton_composition_iii: |
| 1467 |
\__piton_composition_iv: |
| 1468 |
} |
| 1469 |
{ |
| 1470 |
\str_if_empty:NTF \l__piton_box_str |
| 1471 |
\__piton_composition_i: |
| 1472 |
\__piton_composition_ii: |
| 1473 |
} |
| 1474 |
} |
| 1475 |
} |
| 1476 |
{ \__piton_gobble_parse_no_print:o \l__piton_listing_tl } |
| 1477 |
} |
| 1478 |
\cs_new_protected:Npn \__piton_composition_i: |
| 1479 |
{ |
| 1480 |
\box_clear:N \g_tmpa_box |
| 1481 |
\box_clear_new:N \g__piton_line_box |
| 1482 |
\vbox_set:Nn \l_tmpa_box |
| 1483 |
{ |
| 1484 |
\vbox_unpack_drop:N \g__piton_output_box |
| 1485 |
\bool_gset_false:N \g_tmpa_bool |
| 1486 |
\unskip \unskip |
| 1487 |
\bool_gset_false:N \g_tmpa_bool |
| 1488 |
\bool_do_until:nn \g_tmpa_bool |
| 1489 |
{ |
| 1490 |
\unskip \unskip \unskip |
| 1491 |
\unpenalty \unkern |
| 1492 |
\box_set_to_last:N \l__piton_line_box |
| 1493 |
\box_if_empty:NTF \l__piton_line_box |
| 1494 |
{ \bool_gset_true:N \g_tmpa_bool } |
| 1495 |
{ |
| 1496 |
\vbox_gset:Nn \g_tmpa_box |
| 1497 |
{ |
| 1498 |
\vbox_unpack:N \g_tmpa_box |
| 1499 |
\box_use:N \l__piton_line_box |
| 1500 |
} |
| 1501 |
} |
| 1502 |
} |
| 1503 |
} |
| 1504 |
\bool_gset_false:N \g_tmpa_bool |
| 1505 |
\int_zero:N \g__piton_line_int |
| 1506 |
\bool_do_until:nn \g_tmpa_bool |
| 1507 |
{ |
| 1508 |
\vbox_gset:Nn \g_tmpa_box |
| 1509 |
{ |
| 1510 |
\vbox_unpack_drop:N \g_tmpa_box |
| 1511 |
\box_gset_to_last:N \g__piton_line_box |
| 1512 |
} |
| 1513 |
\box_if_empty:NTF \g__piton_line_box |
| 1514 |
{ \bool_gset_true:N \g_tmpa_bool } |
| 1515 |
{ |
| 1516 |
\box_use:N \g__piton_line_box |
| 1517 |
\int_gincr:N \g__piton_line_int |
| 1518 |
\par |
| 1519 |
\kern -2.5 pt |
| 1520 |
\__piton_add_penalty_for_the_line: |
| 1521 |
\cs_if_exist_use:cT { g__piton_after_line _ \int_use:N \g__piton_line_int } |
| 1522 |
{ \cs_undefine:c { g__piton_after_line _ \int_use:N \g__piton_line_int } } |
| 1523 |
\int_compare:nNnT \g__piton_line_int < \g__piton_nb_lines_int |
| 1524 |
{ \mode_leave_vertical: } |
| 1525 |
} |
| 1526 |
} |
| 1527 |
\skip_vertical:n { 2.5 pt } |
| 1528 |
} |
| 1529 |
\cs_new_protected:Npn \__piton_composition_ii: |
| 1530 |
{ |
| 1531 |
\use:e { \begin { minipage } [ \l__piton_box_str ] } |
| 1532 |
{ \l__piton_listing_width_dim } |
| 1533 |
\vbox_unpack:N \g__piton_output_box |
| 1534 |
\kern 2.5 pt |
| 1535 |
\end { minipage } |
| 1536 |
} |
| 1537 |
\cs_new_protected:Npn \__piton_composition_iii: |
| 1538 |
{ |
| 1539 |
\use:e |
| 1540 |
{ |
| 1541 |
\begin { tcolorbox } |
| 1542 |
[ breakable , text~width = \l__piton_listing_width_dim ] |
| 1543 |
} |
| 1544 |
\par |
| 1545 |
\vbox_unpack:N \g__piton_output_box |
| 1546 |
\end { tcolorbox } |
| 1547 |
} |
| 1548 |
\cs_new_protected:Npn \__piton_composition_iv: |
| 1549 |
{ |
| 1550 |
\use:e |
| 1551 |
{ |
| 1552 |
\begin { tcolorbox } |
| 1553 |
[ |
| 1554 |
hbox , |
| 1555 |
text~width = \l__piton_listing_width_dim , |
| 1556 |
nobeforeafter , |
| 1557 |
box~align = |
| 1558 |
\str_case:Nn \l__piton_box_str |
| 1559 |
{ |
| 1560 |
t { top } |
| 1561 |
b { bottom } |
| 1562 |
c { center } |
| 1563 |
m { center } |
| 1564 |
} |
| 1565 |
] |
| 1566 |
} |
| 1567 |
\box_use:N \g__piton_output_box |
| 1568 |
\end { tcolorbox } |
| 1569 |
} |
| 1570 |
\cs_new_protected:Npn \__piton_add_penalty_for_the_line: |
| 1571 |
{ |
| 1572 |
\int_case:nn |
| 1573 |
{ |
| 1574 |
\lua_now:e |
| 1575 |
{ |
| 1576 |
tex.sprint |
| 1577 |
( piton.lines_status [ \int_use:N \g__piton_line_int ] ) |
| 1578 |
} |
| 1579 |
} |
| 1580 |
{ 1 { \penalty 100 } 2 \nobreak } |
| 1581 |
} |
| 1582 |
\cs_new_protected:Npn \__piton_create_output_box: |
| 1583 |
{ |
| 1584 |
\__piton_compute_code_width: |
| 1585 |
\vbox_gset:Nn \g__piton_output_box |
| 1586 |
{ \__piton_retrieve_gobble_parse:o \l__piton_listing_tl } |
| 1587 |
\bool_if:NT \l__piton_minimize_width_bool { \__piton_recompute_listing_width: } |
| 1588 |
\bool_lazy_any:nT |
| 1589 |
{ |
| 1590 |
{ \int_compare_p:nNn \l__piton_bg_colors_int > \c_zero_int } |
| 1591 |
{ \g__piton_rowcolor_inside_bool } |
| 1592 |
{ |
| 1593 |
\l__piton_line_numbers_bool |
| 1594 |
&& |
| 1595 |
\str_if_eq_p:ee \l__piton_line_numbers_position_str { right } |
| 1596 |
} |
| 1597 |
} |
| 1598 |
\__piton_add_bg_and_right_nb_to_output_box: |
| 1599 |
} |
| 1600 |
\cs_new_protected:Npn \__piton_add_bg_and_right_nb_to_output_box: |
| 1601 |
{ |
| 1602 |
\int_gset_eq:NN \g__piton_line_int \g__piton_nb_lines_int |
| 1603 |
\vbox_set:Nn \l_tmpa_box |
| 1604 |
{ |
| 1605 |
\vbox_unpack_drop:N \g__piton_output_box |
| 1606 |
\bool_gset_false:N \g_tmpa_bool |
| 1607 |
\unskip \unskip |
| 1608 |
\bool_do_until:nn \g_tmpa_bool |
| 1609 |
{ |
| 1610 |
\unskip \unskip \unskip |
| 1611 |
\int_set_eq:NN \l_tmpa_int \lastpenalty |
| 1612 |
\unpenalty \unkern |
| 1613 |
\box_set_to_last:N \l__piton_line_box |
| 1614 |
\box_if_empty:NTF \l__piton_line_box |
| 1615 |
{ \bool_gset_true:N \g_tmpa_bool } |
| 1616 |
{ |
| 1617 |
\vbox_gset:Nn \g__piton_output_box |
| 1618 |
{ |
| 1619 |
\__piton_add_bg_and_right_nb_to_line_and_use: |
| 1620 |
\kern -2.5 pt |
| 1621 |
\penalty \l_tmpa_int |
| 1622 |
\vbox_unpack:N \g__piton_output_box |
| 1623 |
} |
| 1624 |
} |
| 1625 |
\int_gdecr:N \g__piton_line_int |
| 1626 |
} |
| 1627 |
} |
| 1628 |
} |
| 1629 |
\cs_new_protected:Npn \__piton_gobble_parse_no_print:n |
| 1630 |
{ |
| 1631 |
\lua_now:e |
| 1632 |
{ |
| 1633 |
piton.GobbleParseNoPrint |
| 1634 |
( |
| 1635 |
'\l_piton_language_str' , |
| 1636 |
\int_use:N \l__piton_gobble_int , |
| 1637 |
token.scan_argument ( ) |
| 1638 |
) |
| 1639 |
} |
| 1640 |
} |
| 1641 |
\cs_generate_variant:Nn \__piton_gobble_parse_no_print:n { o } |
| 1642 |
\cs_new_protected:Npn \__piton_retrieve_gobble_parse:n |
| 1643 |
{ |
| 1644 |
\lua_now:e |
| 1645 |
{ |
| 1646 |
piton.RetrieveGobbleParse |
| 1647 |
( |
| 1648 |
'\l_piton_language_str' , |
| 1649 |
\int_use:N \l__piton_gobble_int , |
| 1650 |
\bool_if:NTF \l__piton_splittable_on_empty_lines_bool |
| 1651 |
{ \int_eval:n { - \l__piton_splittable_int } } |
| 1652 |
{ \int_use:N \l__piton_splittable_int } , |
| 1653 |
token.scan_argument ( ) |
| 1654 |
) |
| 1655 |
} |
| 1656 |
} |
| 1657 |
\cs_generate_variant:Nn \__piton_retrieve_gobble_parse:n { o } |
| 1658 |
\cs_new_protected:Npn \__piton_retrieve_gobble_split_parse:n |
| 1659 |
{ |
| 1660 |
\lua_now:e |
| 1661 |
{ |
| 1662 |
piton.RetrieveGobbleSplitParse |
| 1663 |
( |
| 1664 |
'\l_piton_language_str' , |
| 1665 |
\int_use:N \l__piton_gobble_int , |
| 1666 |
\int_use:N \l__piton_splittable_int , |
| 1667 |
token.scan_argument ( ) |
| 1668 |
) |
| 1669 |
} |
| 1670 |
} |
| 1671 |
\cs_generate_variant:Nn \__piton_retrieve_gobble_split_parse:n { o } |
| 1672 |
\bool_if:NTF \g__piton_beamer_bool |
| 1673 |
{ |
| 1674 |
\NewPitonEnvironment { Piton } { D < > { .- } O { } } |
| 1675 |
{ |
| 1676 |
\keys_set:nn { PitonOptions } { #2 } |
| 1677 |
\begin { actionenv } < #1 > |
| 1678 |
} |
| 1679 |
{ \end { actionenv } } |
| 1680 |
} |
| 1681 |
{ |
| 1682 |
\NewPitonEnvironment { Piton } { O { } } |
| 1683 |
{ \keys_set:nn { PitonOptions } { #1 } } |
| 1684 |
{ } |
| 1685 |
} |
| 1686 |
\NewDocumentCommand { \PitonInputFileTF } { d < > O { } m m m } |
| 1687 |
{ |
| 1688 |
\mode_if_vertical:F { \par } |
| 1689 |
\group_begin: |
| 1690 |
\seq_concat:NNN |
| 1691 |
\l_file_search_path_seq |
| 1692 |
\l__piton_path_seq |
| 1693 |
\l_file_search_path_seq |
| 1694 |
\file_get_full_name:nNTF { #3 } \l__piton_file_name_str |
| 1695 |
{ |
| 1696 |
\__piton_input_file:nn { #1 } { #2 } |
| 1697 |
#4 |
| 1698 |
} |
| 1699 |
{ #5 } |
| 1700 |
\group_end: |
| 1701 |
} |
| 1702 |
\cs_new_protected:Npn \__piton_unknown_file:n #1 |
| 1703 |
{ \msg_error:nnn { piton } { Unknown~file } { #1 } } |
| 1704 |
\NewDocumentCommand { \PitonInputFile } { d < > O { } m } |
| 1705 |
{ |
| 1706 |
\PitonInputFileTF < #1 > [ #2 ] { #3 } { } |
| 1707 |
{ |
| 1708 |
\iow_log:n { No~file~#3 } |
| 1709 |
\__piton_unknown_file:n { #3 } |
| 1710 |
} |
| 1711 |
} |
| 1712 |
\NewDocumentCommand { \PitonInputFileT } { d < > O { } m m } |
| 1713 |
{ |
| 1714 |
\PitonInputFileTF < #1 > [ #2 ] { #3 } { #4 } |
| 1715 |
{ |
| 1716 |
\iow_log:n { No~file~#3 } |
| 1717 |
\__piton_unknown_file:n { #3 } |
| 1718 |
} |
| 1719 |
} |
| 1720 |
\NewDocumentCommand { \PitonInputFileF } { d < > O { } m m } |
| 1721 |
{ \PitonInputFileTF < #1 > [ #2 ] { #3 } { } { #4 } } |
| 1722 |
\cs_new_protected:Npn \__piton_input_file:nn #1 #2 |
| 1723 |
{ |
| 1724 |
\tl_if_novalue:nF { #1 } |
| 1725 |
{ |
| 1726 |
\bool_if:NTF \g__piton_beamer_bool |
| 1727 |
{ \begin { uncoverenv } < #1 > } |
| 1728 |
{ \__piton_error_or_warning:n { overlay~without~beamer } } |
| 1729 |
} |
| 1730 |
\group_begin: |
| 1731 |
\iow_log:e { (\l__piton_file_name_str) } |
| 1732 |
\int_zero_new:N \l__piton_first_line_int |
| 1733 |
\int_zero_new:N \l__piton_last_line_int |
| 1734 |
\int_set_eq:NN \l__piton_last_line_int \c_max_int |
| 1735 |
\bool_set_true:N \l__piton_in_PitonInputFile_bool |
| 1736 |
\keys_set:nn { PitonOptions } { #2 } |
| 1737 |
\bool_if:NT \l__piton_line_numbers_absolute_bool |
| 1738 |
{ \bool_set_false:N \l__piton_skip_empty_lines_bool } |
| 1739 |
\bool_if:nTF |
| 1740 |
{ |
| 1741 |
( |
| 1742 |
\int_compare_p:nNn \l__piton_first_line_int > \c_zero_int |
| 1743 |
|| \int_compare_p:nNn \l__piton_last_line_int < \c_max_int |
| 1744 |
) |
| 1745 |
&& ! \str_if_empty_p:N \l__piton_begin_range_str |
| 1746 |
} |
| 1747 |
{ |
| 1748 |
\__piton_error_or_warning:n { bad~range~specification } |
| 1749 |
\int_zero:N \l__piton_first_line_int |
| 1750 |
\int_set_eq:NN \l__piton_last_line_int \c_max_int |
| 1751 |
} |
| 1752 |
{ |
| 1753 |
\str_if_empty:NF \l__piton_begin_range_str |
| 1754 |
{ |
| 1755 |
\__piton_compute_range: |
| 1756 |
\bool_lazy_or:nnT |
| 1757 |
\l__piton_marker_include_lines_bool |
| 1758 |
{ ! \str_if_eq_p:NN \l__piton_begin_range_str \l__piton_end_range_str } |
| 1759 |
{ |
| 1760 |
\int_decr:N \l__piton_first_line_int |
| 1761 |
\int_incr:N \l__piton_last_line_int |
| 1762 |
} |
| 1763 |
} |
| 1764 |
} |
| 1765 |
\__piton_pre_composition: |
| 1766 |
\bool_if:NT \l__piton_line_numbers_absolute_bool |
| 1767 |
{ \int_gset:Nn \g__piton_visual_line_int { \l__piton_first_line_int - 1 } } |
| 1768 |
\int_compare:nNnT \l__piton_number_lines_start_int > \c_zero_int |
| 1769 |
{ |
| 1770 |
\int_gset:Nn \g__piton_visual_line_int |
| 1771 |
{ \l__piton_number_lines_start_int - 1 } |
| 1772 |
} |
| 1773 |
\int_compare:nNnT \g__piton_visual_line_int < \c_zero_int |
| 1774 |
{ \int_gzero:N \g__piton_visual_line_int } |
| 1775 |
\lua_now:e |
| 1776 |
{ |
| 1777 |
piton.ReadFile( |
| 1778 |
'\l__piton_file_name_str' , |
| 1779 |
\int_use:N \l__piton_first_line_int , |
| 1780 |
\int_use:N \l__piton_last_line_int ) |
| 1781 |
} |
| 1782 |
\__piton_composition: |
| 1783 |
\group_end: |
| 1784 |
\tl_if_novalue:nF { #1 } |
| 1785 |
{ \bool_if:NT \g__piton_beamer_bool { \end { uncoverenv } } } |
| 1786 |
} |
| 1787 |
\cs_new_protected:Npn \__piton_compute_range: |
| 1788 |
{ |
| 1789 |
\str_set:Ne \l_tmpa_str { \__piton_marker_beginning:n { \l__piton_begin_range_str } } |
| 1790 |
\str_set:Ne \l_tmpb_str { \__piton_marker_end:n { \l__piton_end_range_str } } |
| 1791 |
\tl_replace_all:Nee \l_tmpa_str { \c_backslash_str \c_hash_str } \c_hash_str |
| 1792 |
\tl_replace_all:Nee \l_tmpb_str { \c_backslash_str \c_hash_str } \c_hash_str |
| 1793 |
\lua_now:e |
| 1794 |
{ |
| 1795 |
piton.ComputeRange |
| 1796 |
( '\l_tmpa_str' , '\l_tmpb_str' , '\l__piton_file_name_str' ) |
| 1797 |
} |
| 1798 |
} |
| 1799 |
\NewDocumentCommand { \PitonStyle } { m } |
| 1800 |
{ |
| 1801 |
\cs_if_exist_use:cF { pitonStyle _ \l_piton_language_str _ #1 } |
| 1802 |
{ \use:c { pitonStyle _ #1 } } |
| 1803 |
} |
| 1804 |
\NewDocumentCommand { \OptionalLocalPitonStyle } { m } |
| 1805 |
{ \cs_if_exist_use:c { pitonStyle _ \l_piton_language_str _ #1 } } |
| 1806 |
\NewDocumentCommand { \SetPitonStyle } { O { } m } |
| 1807 |
{ |
| 1808 |
\str_clear_new:N \l__piton_SetPitonStyle_option_str |
| 1809 |
\str_set:Ne \l__piton_SetPitonStyle_option_str { \str_lowercase:n { #1 } } |
| 1810 |
\str_if_eq:onT { \l__piton_SetPitonStyle_option_str } { current-language } |
| 1811 |
{ \str_set_eq:NN \l__piton_SetPitonStyle_option_str \l_piton_language_str } |
| 1812 |
\keys_set:nn { piton / Styles } { #2 } |
| 1813 |
} |
| 1814 |
\cs_new_protected:Npn \__piton_math_scantokens:n #1 |
| 1815 |
{ \normalfont \scantextokens { \begin{math} #1 \end{math} } } |
| 1816 |
\clist_new:N \g__piton_styles_clist |
| 1817 |
\clist_gset:Nn \g__piton_styles_clist |
| 1818 |
{ |
| 1819 |
Comment , |
| 1820 |
Comment.Internal , |
| 1821 |
Comment.LaTeX , |
| 1822 |
Discard , |
| 1823 |
Delim , |
| 1824 |
Exception , |
| 1825 |
FormattingType , |
| 1826 |
Identifier.Internal , |
| 1827 |
Identifier , |
| 1828 |
InitialValues , |
| 1829 |
Interpol.Inside , |
| 1830 |
Keyword , |
| 1831 |
Keyword.Governing , |
| 1832 |
Keyword.Constant , |
| 1833 |
Keyword2 , |
| 1834 |
Keyword3 , |
| 1835 |
Keyword4 , |
| 1836 |
Keyword5 , |
| 1837 |
Keyword6 , |
| 1838 |
Keyword7 , |
| 1839 |
Keyword8 , |
| 1840 |
Keyword9 , |
| 1841 |
Name.Builtin , |
| 1842 |
Name.Class , |
| 1843 |
Name.Constructor , |
| 1844 |
Name.Decorator , |
| 1845 |
Name.Field , |
| 1846 |
Name.Function , |
| 1847 |
Name.Module , |
| 1848 |
Name.Namespace , |
| 1849 |
Name.Table , |
| 1850 |
Name.Type , |
| 1851 |
Number , |
| 1852 |
Number.Internal , |
| 1853 |
Operator , |
| 1854 |
Operator.Word , |
| 1855 |
Preproc , |
| 1856 |
Prompt , |
| 1857 |
Punct , |
| 1858 |
String.Doc , |
| 1859 |
String.Doc.Internal , |
| 1860 |
String.Interpol , |
| 1861 |
String.Long , |
| 1862 |
String.Long.Internal , |
| 1863 |
String.Short , |
| 1864 |
String.Short.Internal , |
| 1865 |
Tag , |
| 1866 |
TypeParameter , |
| 1867 |
UserFunction , |
| 1868 |
TypeExpression , |
| 1869 |
Directive |
| 1870 |
} |
| 1871 |
\clist_map_inline:Nn \g__piton_styles_clist |
| 1872 |
{ |
| 1873 |
\keys_define:nn { piton / Styles } |
| 1874 |
{ |
| 1875 |
#1 .value_required:n = true , |
| 1876 |
#1 .code:n = |
| 1877 |
\tl_set:cn |
| 1878 |
{ |
| 1879 |
pitonStyle _ |
| 1880 |
\str_if_empty:NF \l__piton_SetPitonStyle_option_str |
| 1881 |
{ \l__piton_SetPitonStyle_option_str _ } |
| 1882 |
#1 |
| 1883 |
} |
| 1884 |
{ ##1 } |
| 1885 |
} |
| 1886 |
} |
| 1887 |
|
| 1888 |
\keys_define:nn { piton / Styles } |
| 1889 |
{ |
| 1890 |
String .meta:n = { String.Long = #1 , String.Short = #1 } , |
| 1891 |
String .value_required:n = true , |
| 1892 |
Comment.Math .tl_set:c = pitonStyle _ Comment.Math , |
| 1893 |
Comment.Math .value_required:n = true , |
| 1894 |
unknown .code:n = \__piton_unknown_style: |
| 1895 |
} |
| 1896 |
\cs_new_protected:Npn \__piton_unknown_style: |
| 1897 |
{ |
| 1898 |
\str_if_eq:eeTF \l__piton_SetPitonStyle_option_str { expl } |
| 1899 |
{ |
| 1900 |
\seq_set_split:Nne \l_tmpa_seq { . } \l_keys_key_str |
| 1901 |
\seq_get_left:NN \l_tmpa_seq \l_tmpa_str |
| 1902 |
\bool_lazy_and:nnTF |
| 1903 |
{ \int_compare_p:nNn { \seq_count:N \l_tmpa_seq } > { 1 } } |
| 1904 |
{ |
| 1905 |
\str_if_eq_p:Vn \l_tmpa_str { Module } |
| 1906 |
|| |
| 1907 |
\str_if_eq_p:Vn \l_tmpa_str { Type } |
| 1908 |
} |
| 1909 |
{ \tl_set:co { pitonStyle _ expl _ \l_keys_key_str } \l_keys_value_tl } |
| 1910 |
{ \__piton_error:n { Unknown~key~for~SetPitonStyle } } |
| 1911 |
} |
| 1912 |
{ \__piton_error:n { Unknown~key~for~SetPitonStyle } } |
| 1913 |
} |
| 1914 |
\SetPitonStyle[OCaml] |
| 1915 |
{ |
| 1916 |
TypeExpression = |
| 1917 |
{ |
| 1918 |
\SetPitonStyle [ OCaml ] |
| 1919 |
{ |
| 1920 |
Identifier = \PitonStyle { Name.Type } , |
| 1921 |
Name.Builtin = \PitonStyle { Name.Type} |
| 1922 |
} |
| 1923 |
\__piton_piton:n |
| 1924 |
} |
| 1925 |
} |
| 1926 |
\clist_gput_left:Nn \g__piton_styles_clist { String } |
| 1927 |
\clist_gsort:Nn \g__piton_styles_clist |
| 1928 |
{ |
| 1929 |
\str_compare:nNnTF { #1 } < { #2 } |
| 1930 |
\sort_return_same: |
| 1931 |
\sort_return_swapped: |
| 1932 |
} |
| 1933 |
\cs_set_eq:NN \__piton_break_strings_anywhere:n \prg_do_nothing: |
| 1934 |
|
| 1935 |
\cs_set_eq:NN \__piton_break_numbers_anywhere:n \prg_do_nothing: |
| 1936 |
|
| 1937 |
\cs_new_protected:Npn \__piton_actually_break_anywhere:n #1 |
| 1938 |
{ |
| 1939 |
\tl_set:Nn \l_tmpa_tl { #1 } |
| 1940 |
\tl_replace_all:NVn \l_tmpa_tl \c_catcode_other_space_tl \space |
| 1941 |
\seq_clear:N \l_tmpa_seq |
| 1942 |
\tl_map_inline:Nn \l_tmpa_tl { \seq_put_right:Nn \l_tmpa_seq { ##1 } } |
| 1943 |
\seq_use:Nn \l_tmpa_seq { \- } |
| 1944 |
} |
| 1945 |
\cs_new_protected:Npn \__piton_comment:n #1 |
| 1946 |
{ \PitonStyle { Comment } { \PitonSpaceSubstitute { #1 } } } |
| 1947 |
\cs_new_protected:Npn \PitonSpaceSubstitute #1 % noqa |
| 1948 |
{ |
| 1949 |
\bool_if:NTF \l__piton_break_lines_in_Piton_bool |
| 1950 |
{ |
| 1951 |
\tl_set:Nn \l_tmpa_tl { #1 } |
| 1952 |
\tl_replace_all:NVn \l_tmpa_tl |
| 1953 |
\c_catcode_other_space_tl |
| 1954 |
\__piton_breakable_space: |
| 1955 |
\l_tmpa_tl |
| 1956 |
} |
| 1957 |
{ #1 } |
| 1958 |
} |
| 1959 |
\cs_new_protected:Npn \__piton_string_long:n #1 |
| 1960 |
{ |
| 1961 |
\PitonStyle { String.Long } |
| 1962 |
{ |
| 1963 |
\bool_if:NTF \l__piton_break_strings_anywhere_bool |
| 1964 |
{ \__piton_actually_break_anywhere:n { #1 } } |
| 1965 |
{ |
| 1966 |
\bool_if:NTF \l__piton_break_lines_in_Piton_bool |
| 1967 |
{ |
| 1968 |
\tl_set:Nn \l_tmpa_tl { #1 } |
| 1969 |
\tl_replace_all:NVn \l_tmpa_tl |
| 1970 |
\c_catcode_other_space_tl |
| 1971 |
\__piton_breakable_space: |
| 1972 |
\l_tmpa_tl |
| 1973 |
} |
| 1974 |
{ #1 } |
| 1975 |
} |
| 1976 |
} |
| 1977 |
} |
| 1978 |
\cs_new_protected:Npn \__piton_string_short:n #1 |
| 1979 |
{ |
| 1980 |
\PitonStyle { String.Short } |
| 1981 |
{ |
| 1982 |
\bool_if:NT \l__piton_break_strings_anywhere_bool |
| 1983 |
{ \__piton_actually_break_anywhere:n } |
| 1984 |
{ #1 } |
| 1985 |
} |
| 1986 |
} |
| 1987 |
\cs_new_protected:Npn \__piton_string_doc:n #1 |
| 1988 |
{ |
| 1989 |
\PitonStyle { String.Doc } |
| 1990 |
{ |
| 1991 |
\bool_if:NTF \l__piton_break_lines_in_Piton_bool |
| 1992 |
{ |
| 1993 |
\tl_set:Nn \l_tmpa_tl { #1 } |
| 1994 |
\tl_replace_all:NVn \l_tmpa_tl |
| 1995 |
\c_catcode_other_space_tl |
| 1996 |
\__piton_breakable_space: |
| 1997 |
\l_tmpa_tl |
| 1998 |
} |
| 1999 |
{ #1 } |
| 2000 |
} |
| 2001 |
} |
| 2002 |
\cs_new_protected:Npn \__piton_number:n #1 |
| 2003 |
{ |
| 2004 |
\PitonStyle { Number } |
| 2005 |
{ |
| 2006 |
\bool_if:NT \l__piton_break_numbers_anywhere_bool |
| 2007 |
{ \__piton_actually_break_anywhere:n } |
| 2008 |
{ #1 } |
| 2009 |
} |
| 2010 |
} |
| 2011 |
\SetPitonStyle |
| 2012 |
{ |
| 2013 |
Comment = \color [ HTML ] { 0099FF } \itshape , |
| 2014 |
Comment.Internal = \__piton_comment:n , |
| 2015 |
Exception = \color [ HTML ] { CC0000 } , |
| 2016 |
Keyword = \color [ HTML ] { 006699 } \bfseries , |
| 2017 |
Keyword.Governing = \color [ HTML ] { 006699 } \bfseries , |
| 2018 |
Keyword.Constant = \color [ HTML ] { 006699 } \bfseries , |
| 2019 |
Name.Builtin = \color [ HTML ] { 336666 } , |
| 2020 |
Name.Decorator = \color [ HTML ] { 9999FF }, |
| 2021 |
Name.Class = \color [ HTML ] { 00AA88 } \bfseries , |
| 2022 |
Name.Function = \color [ HTML ] { CC00FF } , |
| 2023 |
Name.Namespace = \color [ HTML ] { 00CCFF } , |
| 2024 |
Name.Constructor = \color [ HTML ] { 006000 } \bfseries , |
| 2025 |
Name.Field = \color [ HTML ] { AA6600 } , |
| 2026 |
Name.Module = \color [ HTML ] { 0060A0 } \bfseries , |
| 2027 |
Name.Table = \color [ HTML ] { 309030 } , |
| 2028 |
Number = \color [ HTML ] { FF6600 } , |
| 2029 |
Number.Internal = \__piton_number:n , |
| 2030 |
Operator = \color [ HTML ] { 555555 } , |
| 2031 |
Operator.Word = \bfseries , |
| 2032 |
String = \color [ HTML ] { CC3300 } , |
| 2033 |
String.Long.Internal = \__piton_string_long:n , |
| 2034 |
String.Short.Internal = \__piton_string_short:n , |
| 2035 |
String.Doc.Internal = \__piton_string_doc:n , |
| 2036 |
String.Doc = \color [ HTML ] { CC3300 } \itshape , |
| 2037 |
String.Interpol = \color [ HTML ] { AA0000 } , |
| 2038 |
Comment.LaTeX = \normalfont \color [ rgb ] { .468, .532, .6 } , |
| 2039 |
Name.Type = \color [ HTML ] { 336666 } , |
| 2040 |
InitialValues = \__piton_piton:n , |
| 2041 |
Interpol.Inside = { \l__piton_font_command_tl \__piton_piton:n } , |
| 2042 |
TypeParameter = \color [ HTML ] { 336666} \itshape , |
| 2043 |
Preproc = \color [ HTML ] { AA6600} \slshape , |
| 2044 |
Identifier.Internal = \__piton_identifier:n , |
| 2045 |
Identifier = , |
| 2046 |
Directive = \color [ HTML ] { AA6600} , |
| 2047 |
Tag = \colorbox { gray!10 } , |
| 2048 |
UserFunction = \PitonStyle { Identifier } , |
| 2049 |
Prompt = , |
| 2050 |
Discard = \use_none:n |
| 2051 |
} |
| 2052 |
\clist_new:N \g__piton_expl_styles_clist |
| 2053 |
\clist_gset:Nn \g__piton_expl_styles_clist |
| 2054 |
{ |
| 2055 |
Scope.l , |
| 2056 |
Scope.g , |
| 2057 |
Scope.c |
| 2058 |
} |
| 2059 |
\clist_map_inline:Nn \g__piton_expl_styles_clist |
| 2060 |
{ |
| 2061 |
\keys_define:nn { piton / Styles } |
| 2062 |
{ |
| 2063 |
#1 .value_required:n = true , |
| 2064 |
#1 .code:n = |
| 2065 |
\tl_set:cn |
| 2066 |
{ |
| 2067 |
pitonStyle _ |
| 2068 |
\str_if_empty:NF \l__piton_SetPitonStyle_option_str |
| 2069 |
{ \l__piton_SetPitonStyle_option_str _ } |
| 2070 |
#1 |
| 2071 |
} |
| 2072 |
{ ##1 } |
| 2073 |
} |
| 2074 |
} |
| 2075 |
\SetPitonStyle [ expl ] |
| 2076 |
{ |
| 2077 |
Scope.l = , |
| 2078 |
Scope.g = \bfseries , |
| 2079 |
Scope.c = \slshape , |
| 2080 |
Type.bool = \color [ HTML ] { AA6600} , |
| 2081 |
Type.box = \color [ HTML ] { 267910 } , |
| 2082 |
Type.clist = \color [ HTML ] { 309030 } , |
| 2083 |
Type.fp = \color [ HTML ] { FF3300 } , |
| 2084 |
Type.int = \color [ HTML ] { FF6600 } , |
| 2085 |
Type.seq = \color [ HTML ] { 309030 } , |
| 2086 |
Type.skip = \color [ HTML ] { 0CC060 } , |
| 2087 |
Type.str = \color [ HTML ] { CC3300 } , |
| 2088 |
Type.tl = \color [ HTML ] { AA2200 } , |
| 2089 |
Module.bool = \color [ HTML ] { AA6600} , |
| 2090 |
Module.box = \color [ HTML ] { 267910 } , |
| 2091 |
Module.cs = \bfseries \color [ HTML ] { 006699 } , |
| 2092 |
Module.exp = \bfseries \color [ HTML ] { 404040 } , |
| 2093 |
Module.hbox = \color [ HTML ] { 267910 } , |
| 2094 |
Module.prg = \bfseries , |
| 2095 |
Module.clist = \color [ HTML ] { 309030 } , |
| 2096 |
Module.fp = \color [ HTML ] { FF3300 } , |
| 2097 |
Module.int = \color [ HTML ] { FF6600 } , |
| 2098 |
Module.seq = \color [ HTML ] { 309030 } , |
| 2099 |
Module.skip = \color [ HTML ] { 0CC060 } , |
| 2100 |
Module.str = \color [ HTML ] { CC3300 } , |
| 2101 |
Module.tl = \color [ HTML ] { AA2200 } , |
| 2102 |
Module.vbox = \color [ HTML ] { 267910 } |
| 2103 |
} |
| 2104 |
\hook_gput_code:nnn { begindocument } { . } |
| 2105 |
{ |
| 2106 |
\bool_if:NT \g__piton_math_comments_bool |
| 2107 |
{ \SetPitonStyle { Comment.Math = \__piton_math_scantokens:n } } |
| 2108 |
} |
| 2109 |
\NewDocumentCommand { \SetPitonIdentifier } { o m m } |
| 2110 |
{ |
| 2111 |
\clist_set:Nn \l_tmpa_clist { #2 } |
| 2112 |
\tl_if_novalue:nTF { #1 } |
| 2113 |
{ |
| 2114 |
\clist_map_inline:Nn \l_tmpa_clist |
| 2115 |
{ \cs_set:cpn { PitonIdentifier _ ##1 } { #3 } } |
| 2116 |
} |
| 2117 |
{ |
| 2118 |
\str_set:Ne \l_tmpa_str { \str_lowercase:n { #1 } } |
| 2119 |
\str_if_eq:onT \l_tmpa_str { current-language } |
| 2120 |
{ \str_set_eq:NN \l_tmpa_str \l_piton_language_str } |
| 2121 |
\clist_map_inline:Nn \l_tmpa_clist |
| 2122 |
{ \cs_set:cpn { PitonIdentifier _ \l_tmpa_str _ ##1 } { #3 } } |
| 2123 |
} |
| 2124 |
} |
| 2125 |
\cs_new_protected:Npn \__piton_identifier:n #1 |
| 2126 |
{ |
| 2127 |
\str_set:Nn \l_tmpa_str { #1 } |
| 2128 |
\cs_if_exist_use:cF { PitonIdentifier _ \l_piton_language_str _ \l_tmpa_str } |
| 2129 |
{ |
| 2130 |
\cs_if_exist_use:cF { PitonIdentifier _ \l_tmpa_str } |
| 2131 |
{ \PitonStyle { Identifier } } |
| 2132 |
} |
| 2133 |
{ #1 } |
| 2134 |
} |
| 2135 |
\cs_new_protected:cpn { pitonStyle _ Name.Function.Internal } #1 |
| 2136 |
{ |
| 2137 |
{ \PitonStyle { Name.Function } { #1 } } |
| 2138 |
\str_set:Nn \l_tmpa_str { #1 } |
| 2139 |
\cs_gset_protected:cpn { PitonIdentifier _ \l_piton_language_str _ \l_tmpa_str } |
| 2140 |
{ \PitonStyle { UserFunction } } |
| 2141 |
\seq_if_exist:cF { g__piton_functions _ \l_piton_language_str _ seq } |
| 2142 |
{ \seq_new:c { g__piton_functions _ \l_piton_language_str _ seq } } |
| 2143 |
\seq_gput_right:co { g__piton_functions _ \l_piton_language_str _ seq } \l_tmpa_str |
| 2144 |
\seq_if_in:NoF \g__piton_languages_seq { \l_piton_language_str } |
| 2145 |
{ \seq_gput_left:No \g__piton_languages_seq { \l_piton_language_str } } |
| 2146 |
} |
| 2147 |
\NewDocumentCommand \PitonClearUserFunctions { ! o } |
| 2148 |
{ |
| 2149 |
\tl_if_novalue:nTF { #1 } |
| 2150 |
{ \__piton_clear_all_functions: } |
| 2151 |
{ \__piton_clear_list_functions:n { #1 } } |
| 2152 |
} |
| 2153 |
\cs_new_protected:Npn \__piton_clear_list_functions:n #1 |
| 2154 |
{ |
| 2155 |
\clist_set:Nn \l_tmpa_clist { #1 } |
| 2156 |
\clist_map_function:NN \l_tmpa_clist \__piton_clear_functions_i:n |
| 2157 |
\clist_map_inline:nn { #1 } |
| 2158 |
{ \seq_gremove_all:Nn \g__piton_languages_seq { ##1 } } |
| 2159 |
} |
| 2160 |
\cs_new_protected:Npn \__piton_clear_functions_i:n #1 |
| 2161 |
{ \__piton_clear_functions_ii:n { \str_lowercase:n { #1 } } } |
| 2162 |
\cs_new_protected:Npn \__piton_clear_functions_ii:n #1 |
| 2163 |
{ |
| 2164 |
\seq_if_exist:cT { g__piton_functions _ #1 _ seq } |
| 2165 |
{ |
| 2166 |
\seq_map_inline:cn { g__piton_functions _ #1 _ seq } |
| 2167 |
{ \cs_undefine:c { PitonIdentifier _ #1 _ ##1} } |
| 2168 |
\seq_gclear:c { g__piton_functions _ #1 _ seq } |
| 2169 |
} |
| 2170 |
} |
| 2171 |
\cs_generate_variant:Nn \__piton_clear_functions_ii:n { e } |
| 2172 |
\cs_new_protected:Npn \__piton_clear_functions:n #1 |
| 2173 |
{ |
| 2174 |
\__piton_clear_functions_i:n { #1 } |
| 2175 |
\seq_gremove_all:Nn \g__piton_languages_seq { #1 } |
| 2176 |
} |
| 2177 |
\cs_new_protected:Npn \__piton_clear_all_functions: |
| 2178 |
{ |
| 2179 |
\seq_map_function:NN \g__piton_languages_seq \__piton_clear_functions_i:n |
| 2180 |
\seq_gclear:N \g__piton_languages_seq |
| 2181 |
} |
| 2182 |
\AtEndDocument |
| 2183 |
{ |
| 2184 |
\lua_now:n { piton.write_files_now ( ) } |
| 2185 |
\IfPDFManagementActiveTF |
| 2186 |
{ \__piton_join_files: } |
| 2187 |
{ \__piton_join_files_legacy: } |
| 2188 |
} |
| 2189 |
\cs_new_protected:Npn \__piton_join_files: |
| 2190 |
{ |
| 2191 |
\seq_map_inline:Nn \g__piton_join_seq |
| 2192 |
{ |
| 2193 |
\lua_now:n { pdf.immediateobj ( "stream" , piton.join_files["##1"] ) } |
| 2194 |
\str_set_convert:Nnnn \l_tmpa_str { ##1 } { } { utf16/hex } |
| 2195 |
\pdfmanagement_add:nne { Catalog / Names } { EmbeddedFiles } |
| 2196 |
{ |
| 2197 |
<< |
| 2198 |
/Type /Filespec |
| 2199 |
/UF <\l_tmpa_str> |
| 2200 |
/EF << /F~\pdf_object_ref_last: >> |
| 2201 |
/Desc (Computer~listing) |
| 2202 |
/AFRelationship /Supplement |
| 2203 |
>> |
| 2204 |
} |
| 2205 |
} |
| 2206 |
} |
| 2207 |
\cs_new_protected:Npn \__piton_join_files_legacy: |
| 2208 |
{ |
| 2209 |
\seq_map_inline:Nn \g__piton_join_seq |
| 2210 |
{ |
| 2211 |
\str_set_convert:Nnnn \l_tmpa_str { ##1 } { } { utf16/hex } |
| 2212 |
\lua_now:n { pdf.immediateobj ( "stream" , piton.join_files["##1"] ) } |
| 2213 |
\pdfextension annot~width~0pt~height~0pt~depth~0pt |
| 2214 |
{ |
| 2215 |
/Subtype /FileAttachment |
| 2216 |
/F~2 |
| 2217 |
/Name /Paperclip |
| 2218 |
/Contents (Computer~listing) |
| 2219 |
/FS << |
| 2220 |
/Type /Filespec |
| 2221 |
/UF <\l_tmpa_str> |
| 2222 |
/EF << /F~\pdf_object_ref_last: >> |
| 2223 |
/AFRelationship /Supplement |
| 2224 |
>> |
| 2225 |
} |
| 2226 |
} |
| 2227 |
} |
| 2228 |
\cs_new_protected:Npn \__piton_define_leading_space_normal: |
| 2229 |
{ |
| 2230 |
\cs_set_protected:Npn \__piton_leading_space: |
| 2231 |
{ |
| 2232 |
\int_gincr:N \g__piton_indentation_int |
| 2233 |
\hbox:n { ~ } |
| 2234 |
} |
| 2235 |
} |
| 2236 |
\cs_new_protected:Npn \__piton_define_leading_space_Foxit: |
| 2237 |
{ |
| 2238 |
\cs_set_protected:Npn \__piton_leading_space: |
| 2239 |
{ |
| 2240 |
\int_gincr:N \g__piton_indentation_int |
| 2241 |
\pdfextension literal { /Artifact << /ActualText (\space) >> BDC } |
| 2242 |
{ |
| 2243 |
\color { white } |
| 2244 |
\transparent { 0 } |
| 2245 |
. % previously : ␣ U+2423 |
| 2246 |
} |
| 2247 |
\pdfextension literal { EMC } |
| 2248 |
} |
| 2249 |
} |
| 2250 |
\__piton_define_leading_space_Foxit: |
| 2251 |
\AddToHook { env / piton / before } |
| 2252 |
{ \__piton_fatal:n { No~environment~piton } } |
| 2253 |
\cs_new_protected:Npn \__piton_unknown_key:nn #1 #2 |
| 2254 |
{ |
| 2255 |
\str_set_eq:NN \l_tmpa_str \l_keys_key_str |
| 2256 |
\str_replace_all:Nnn \l_tmpa_str { ~ } { - } |
| 2257 |
\str_set:Ne \l_tmpa_str { \str_lowercase:f { \l_tmpa_str } } |
| 2258 |
\bool_set_false:N \l_tmpa_bool |
| 2259 |
\clist_map_inline:nn { #1 } |
| 2260 |
{ |
| 2261 |
\keys_if_exist:neT { ##1 } { \l_tmpa_str } |
| 2262 |
{ |
| 2263 |
\__piton_error:n { key~with~normal~form~exists } |
| 2264 |
\bool_set_true:N \l_tmpa_bool |
| 2265 |
\clist_map_break: |
| 2266 |
} |
| 2267 |
} |
| 2268 |
\bool_if:NF \l_tmpa_bool { \__piton_error:n { #2 } } |
| 2269 |
} |
| 2270 |
\__piton_msg_new:nn { key~with~normal~form~exists } |
| 2271 |
{ |
| 2272 |
The~key~'\l_keys_key_str'~does~not~exists.~It~will~be~ignored.\\ |
| 2273 |
Maybe~you~want~to~use~the~key~'\l_tmpa_str'. |
| 2274 |
} |
| 2275 |
\__piton_msg_new:nn { No~environment~piton } |
| 2276 |
{ |
| 2277 |
There~is~no~environment~piton!\\ |
| 2278 |
There~is~an~environment~{Piton}~and~a~command~ |
| 2279 |
\token_to_str:N \piton\ but~there~is~no~environment~ |
| 2280 |
{piton}. |
| 2281 |
} |
| 2282 |
\__piton_msg_new:nn { rounded-corners~without~Tikz } |
| 2283 |
{ |
| 2284 |
TikZ~not~used \\ |
| 2285 |
You~can't~use~the~key~'rounded-corners'~because~ |
| 2286 |
you~have~not~loaded~the~package~TikZ.~ |
| 2287 |
If~you~go~on,~your~key~will~be~ignored.~ |
| 2288 |
You~won't~have~similar~error~till~the~end~of~the~document. |
| 2289 |
} |
| 2290 |
\__piton_msg_new:nn { tcolorbox~not~loaded } |
| 2291 |
{ |
| 2292 |
tcolorbox~not~loaded \\ |
| 2293 |
You~can't~use~the~key~'tcolorbox'~because~ |
| 2294 |
you~have~not~loaded~the~package~tcolorbox.~ |
| 2295 |
Use~\token_to_str:N \usepackage[breakable]{tcolorbox}.~ |
| 2296 |
If~you~go~on,~that~key~will~be~ignored. |
| 2297 |
} |
| 2298 |
\__piton_msg_new:nn { library~breakable~not~loaded } |
| 2299 |
{ |
| 2300 |
breakable~not~loaded \\ |
| 2301 |
You~can't~use~the~key~'tcolorbox'~because~ |
| 2302 |
you~have~not~loaded~the~library~'breakable'~of~tcolorbox'.~ |
| 2303 |
Use~\token_to_str:N \tcbuselibrary{breakable}~in~the~preamble~ |
| 2304 |
of~your~document.~ |
| 2305 |
If~you~go~on,~that~key~will~be~ignored. |
| 2306 |
} |
| 2307 |
\__piton_msg_new:nn { Language~not~defined } |
| 2308 |
{ |
| 2309 |
Language~not~defined \\ |
| 2310 |
The~language~'\l_tmpa_tl'~has~not~been~defined~previously.~ |
| 2311 |
If~you~go~on,~your~command~\token_to_str:N \NewPitonLanguage\ |
| 2312 |
will~be~ignored. |
| 2313 |
} |
| 2314 |
\__piton_msg_new:nn { bad~version~of~piton.lua } |
| 2315 |
{ |
| 2316 |
Bad~number~version~of~'piton.lua'\\ |
| 2317 |
The~file~'piton.lua'~loaded~has~not~the~same~number~of~ |
| 2318 |
version~as~the~file~'piton.sty'.~You~can~go~on~but~you~should~ |
| 2319 |
address~that~issue. |
| 2320 |
} |
| 2321 |
\__piton_msg_new:nn { Unknown~key~NewPitonLanguage } |
| 2322 |
{ |
| 2323 |
Unknown~key~for~\token_to_str:N \NewPitonLanguage.\\ |
| 2324 |
The~key~'\l_keys_key_str'~is~unknown.~ |
| 2325 |
This~key~will~be~ignored. |
| 2326 |
} |
| 2327 |
\__piton_msg_new:nn { Unknown~key~for~SetPitonStyle } |
| 2328 |
{ |
| 2329 |
The~style~'\l_keys_key_str'~is~unknown.\\ |
| 2330 |
This~setting~will~be~ignored.~ |
| 2331 |
The~available~styles~are~(in~alphabetic~order):~ |
| 2332 |
\clist_use:Nnnn \g__piton_styles_clist { ~and~ } { ,~ } { ~and~ }. |
| 2333 |
} |
| 2334 |
\__piton_msg_new:nn { Invalid~key } |
| 2335 |
{ |
| 2336 |
Wrong~use~of~key.\\ |
| 2337 |
You~can't~use~the~key~'\l_keys_key_str'~here.~ |
| 2338 |
Your~key~will~be~ignored. |
| 2339 |
} |
| 2340 |
\__piton_msg_new:nn { Unknown~key~for~line-numbers } |
| 2341 |
{ |
| 2342 |
Unknown~key. \\ |
| 2343 |
The~key~'line-numbers / \l_keys_key_str'~is~unknown.~ |
| 2344 |
The~available~keys~of~the~family~'line-numbers'~are~(in~ |
| 2345 |
alphabetic~order):~ |
| 2346 |
absolute,~false,~label-empty-lines,~lmmono10-drawn,~ |
| 2347 |
~position,~resume,~skip-empty-lines,~ |
| 2348 |
sep,~start~and~true.~ |
| 2349 |
Your~key~will~be~ignored. |
| 2350 |
} |
| 2351 |
\__piton_msg_new:nn { Unknown~key~for~marker } |
| 2352 |
{ |
| 2353 |
Unknown~key. \\ |
| 2354 |
The~key~'marker / \l_keys_key_str'~is~unknown.~ |
| 2355 |
The~available~keys~of~the~family~'marker'~are~(in~ |
| 2356 |
alphabetic~order):~ beginning,~end~and~include-lines.~ |
| 2357 |
Your~key~will~be~ignored. |
| 2358 |
} |
| 2359 |
\__piton_msg_new:nn { bad~range~specification } |
| 2360 |
{ |
| 2361 |
Incompatible~keys.\\ |
| 2362 |
You~can't~specify~the~range~of~lines~to~include~by~using~both~ |
| 2363 |
markers~and~explicit~number~of~lines.~ |
| 2364 |
Your~whole~file~'\l__piton_file_name_str'~will~be~included. |
| 2365 |
} |
| 2366 |
\cs_new_nopar:Nn \__piton_thepage: |
| 2367 |
{ |
| 2368 |
\thepage |
| 2369 |
\cs_if_exist:NT \insertframenumber |
| 2370 |
{ |
| 2371 |
~(frame~\insertframenumber |
| 2372 |
\cs_if_exist:NT \beamer@slidenumber { ,~slide~\insertslidenumber } |
| 2373 |
) |
| 2374 |
} |
| 2375 |
} |
| 2376 |
\__piton_msg_new:nn { SyntaxError } |
| 2377 |
{ |
| 2378 |
Syntax~Error~on~page~\__piton_thepage:.\\ |
| 2379 |
Your~code~of~the~language~'\l_piton_language_str'~is~not~ |
| 2380 |
syntactically~correct.~ |
| 2381 |
It~won't~be~printed~in~the~PDF~file. |
| 2382 |
} |
| 2383 |
\__piton_msg_new:nn { FileError } |
| 2384 |
{ |
| 2385 |
File~Error.\\ |
| 2386 |
It's~not~possible~to~write~on~the~file~'#1' \\ |
| 2387 |
\sys_if_shell_unrestricted:F |
| 2388 |
{ (try~to~compile~with~'lualatex~-shell-escape').\\ } |
| 2389 |
If~you~go~on,~nothing~will~be~written~on~that~file. |
| 2390 |
} |
| 2391 |
\__piton_msg_new:nn { InexistentDirectory } |
| 2392 |
{ |
| 2393 |
Inexistent~directory.\\ |
| 2394 |
The~directory~'\l__piton_path_write_str'~ |
| 2395 |
given~in~the~key~'path-write'~does~not~exist.~ |
| 2396 |
Nothing~will~be~written~on~'\l__piton_write_str'. |
| 2397 |
} |
| 2398 |
\__piton_msg_new:nn { begin~marker~not~found } |
| 2399 |
{ |
| 2400 |
Marker~not~found.\\ |
| 2401 |
The~range~'\l__piton_begin_range_str'~provided~to~the~ |
| 2402 |
command~\token_to_str:N \PitonInputFile\ has~not~been~found.~ |
| 2403 |
The~whole~file~'\l__piton_file_name_str'~will~be~inserted. |
| 2404 |
} |
| 2405 |
\__piton_msg_new:nn { end~marker~not~found } |
| 2406 |
{ |
| 2407 |
Marker~not~found.\\ |
| 2408 |
The~marker~of~end~of~the~range~'\l__piton_end_range_str'~ |
| 2409 |
provided~to~the~command~\token_to_str:N \PitonInputFile\ |
| 2410 |
has~not~been~found.~The~file~'\l__piton_file_name_str'~will~ |
| 2411 |
be~inserted~till~the~end. |
| 2412 |
} |
| 2413 |
\__piton_msg_new:nn { Unknown~file } |
| 2414 |
{ |
| 2415 |
Unknown~file. \\ |
| 2416 |
The~file~'#1'~is~unknown.~ |
| 2417 |
Your~command~\token_to_str:N \PitonInputFile\ will~be~ignored. |
| 2418 |
} |
| 2419 |
\cs_new_protected:Npn \__piton_error_if_not_in_beamer: |
| 2420 |
{ |
| 2421 |
\bool_if:NF \g__piton_beamer_bool |
| 2422 |
{ \__piton_error_or_warning:n { Without~beamer } } |
| 2423 |
} |
| 2424 |
\__piton_msg_new:nn { Without~beamer } |
| 2425 |
{ |
| 2426 |
Key~'\l_keys_key_str'~without~Beamer.\\ |
| 2427 |
You~should~not~use~the~key~'\l_keys_key_str'~since~you~ |
| 2428 |
are~not~in~Beamer.~However,~you~can~go~on. |
| 2429 |
} |
| 2430 |
\__piton_msg_new:nn { rowcolor~in~detected-commands } |
| 2431 |
{ |
| 2432 |
'rowcolor'~forbidden~in~'detected-commands'.\\ |
| 2433 |
You~should~put~'rowcolor'~in~'raw-detected-commands'.~ |
| 2434 |
That~key~will~be~ignored. |
| 2435 |
} |
| 2436 |
\__piton_msg_new:nnn { Unknown~key~for~PitonOptions } |
| 2437 |
{ |
| 2438 |
Unknown~key. \\ |
| 2439 |
The~key~'\l_keys_key_str'~is~unknown~for~\token_to_str:N \PitonOptions.~ |
| 2440 |
It~will~be~ignored.~ |
| 2441 |
For~a~list~of~the~available~keys,~type~H~<return>. |
| 2442 |
} |
| 2443 |
{ |
| 2444 |
The~available~keys~are~(in~alphabetic~order):~ |
| 2445 |
annotation,~ |
| 2446 |
add-to-split-separation,~ |
| 2447 |
auto-gobble,~ |
| 2448 |
background-color,~ |
| 2449 |
begin-range,~ |
| 2450 |
box,~ |
| 2451 |
break-lines,~ |
| 2452 |
break-lines-in-piton,~ |
| 2453 |
break-lines-in-Piton,~ |
| 2454 |
break-numbers-anywhere,~ |
| 2455 |
break-strings-anywhere,~ |
| 2456 |
continuation-symbol,~ |
| 2457 |
continuation-symbol-on-indentation,~ |
| 2458 |
detected-beamer-commands,~ |
| 2459 |
detected-beamer-environments,~ |
| 2460 |
detected-commands,~ |
| 2461 |
end-of-broken-line,~ |
| 2462 |
end-range,~ |
| 2463 |
env-gobble,~ |
| 2464 |
env-used-by-split,~ |
| 2465 |
font-command(+),~ |
| 2466 |
gobble,~ |
| 2467 |
indent-broken-lines,~ |
| 2468 |
join,~ |
| 2469 |
label-as-zlabel,~ |
| 2470 |
language,~ |
| 2471 |
left-margin,~ |
| 2472 |
line-numbers/,~ |
| 2473 |
marker/,~ |
| 2474 |
math-comments,~ |
| 2475 |
no-join,~ |
| 2476 |
no-write,~ |
| 2477 |
path,~ |
| 2478 |
path-write,~ |
| 2479 |
print,~ |
| 2480 |
prompt-background-color,~ |
| 2481 |
raw-detected-commands,~ |
| 2482 |
resume,~ |
| 2483 |
right-margin,~ |
| 2484 |
rounded-corners,~ |
| 2485 |
show-spaces,~ |
| 2486 |
show-spaces-in-strings,~ |
| 2487 |
splittable,~ |
| 2488 |
splittable-on-empty-lines,~ |
| 2489 |
split-on-empty-lines,~ |
| 2490 |
split-separation,~ |
| 2491 |
tabs-auto-gobble,~ |
| 2492 |
tab-size,~ |
| 2493 |
tcolorbox,~ |
| 2494 |
varwidth,~ |
| 2495 |
vertical-detected-commands,~ |
| 2496 |
width~and~write. |
| 2497 |
} |
| 2498 |
\__piton_msg_new:nn { label~with~lines~numbers } |
| 2499 |
{ |
| 2500 |
You~can't~use~the~command~\token_to_str:N \label\ |
| 2501 |
or~\token_to_str:N \zlabel\ |
| 2502 |
because~the~key~'line-numbers'~ |
| 2503 |
is~not~active.~If~you~go~on,~that~command~will~ignored. |
| 2504 |
} |
| 2505 |
\__piton_msg_new:nn { overlay~without~beamer } |
| 2506 |
{ |
| 2507 |
You~can't~use~an~argument~<...>~for~your~command~ |
| 2508 |
\token_to_str:N \PitonInputFile\ because~you~are~not~ |
| 2509 |
in~Beamer.~If~you~go~on,~that~argument~will~be~ignored. |
| 2510 |
} |
| 2511 |
\__piton_msg_new:nn { label~as~zlabel~needs~zref~package } |
| 2512 |
{ |
| 2513 |
The~key~'label-as-zlabel'~requires~the~package~'zref'.~ |
| 2514 |
Please~load~the~package~'zref'~before~setting~the~key. |
| 2515 |
} |
| 2516 |
\hook_gput_code:nnn { begindocument } { . } |
| 2517 |
{ |
| 2518 |
\bool_if:NT \g__piton_label_as_zlabel_bool |
| 2519 |
{ |
| 2520 |
\IfPackageLoadedF { zref-base } |
| 2521 |
{ \__piton_fatal:n { label~as~zlabel~needs~zref~package } } |
| 2522 |
} |
| 2523 |
} |
| 2524 |
\cs_new_protected:Npn \__piton_draw_number:n #1 |
| 2525 |
{ \tl_map_inline:nn { #1 } { \use:c { c__piton_glyph_ ##1 _tl } } } |
| 2526 |
\cs_generate_variant:Nn \__piton_draw_number:n { e } |
| 2527 |
\cs_set_eq:NN \tlconstcn \tl_const:cn |
| 2528 |
\ExplSyntaxOff |
| 2529 |
\tlconstcn{c__piton_glyph_0_tl} |
| 2530 |
{% |
| 2531 |
\hbox to 5pt |
| 2532 |
{% |
| 2533 |
\hfill |
| 2534 |
\pdfextension literal |
| 2535 |
{ |
| 2536 |
4.24 3.05 m |
| 2537 |
4.24 4.91 3.22 6.22 2.12 6.22 c |
| 2538 |
1.00 6.22 0 4.88 0 3.06 c |
| 2539 |
0 1.20 1.02 -0.11 2.12 -0.11 c |
| 2540 |
3.24 -0.11 4.24 1.23 4.24 3.05 c |
| 2541 |
3.55 3.16 m |
| 2542 |
3.55 1.68 2.90 0.50 2.12 0.50 c |
| 2543 |
1.34 0.50 0.69 1.68 0.69 3.16 c |
| 2544 |
0.69 4.62 1.38 5.61 2.12 5.61 c |
| 2545 |
2.85 5.61 3.55 4.63 3.55 3.16 c |
| 2546 |
h f |
| 2547 |
}% |
| 2548 |
\hfill |
| 2549 |
}% |
| 2550 |
} |
| 2551 |
\tlconstcn{c__piton_glyph_1_tl} |
| 2552 |
{% |
| 2553 |
\hbox to 5pt |
| 2554 |
{% |
| 2555 |
\hfill \kern 1 pt |
| 2556 |
\pdfextension literal |
| 2557 |
{ |
| 2558 |
3.37 0.3 m |
| 2559 |
3.37 0.61 3.13 0.61 2.97 0.61 c |
| 2560 |
2.06 0.61 l |
| 2561 |
2.06 5.81 l |
| 2562 |
2.06 5.97 2.06 6.22 1.76 6.22 c |
| 2563 |
1.57 6.22 1.51 6.1 1.46 5.98 c |
| 2564 |
1.08 5.13 0.56 5.02 0.37 5.0 c |
| 2565 |
0.21 4.99 0.0 4.97 0.0 4.69 c |
| 2566 |
0.0 4.44 0.18 4.39 0.33 4.39 c |
| 2567 |
0.52 4.39 0.93 4.45 1.37 4.83 c |
| 2568 |
1.37 0.61 l |
| 2569 |
0.46 0.61 l |
| 2570 |
0.3 0.61 0.06 0.61 0.06 0.3 c |
| 2571 |
0.06 0.0 0.31 0.0 0.46 0.0 c |
| 2572 |
2.97 0.0 l |
| 2573 |
3.12 0.0 3.37 0.0 3.37 0.3 c |
| 2574 |
h f |
| 2575 |
}% |
| 2576 |
\hfill |
| 2577 |
}% |
| 2578 |
} |
| 2579 |
\tlconstcn{c__piton_glyph_2_tl} |
| 2580 |
{% |
| 2581 |
\hbox to 5pt |
| 2582 |
{% |
| 2583 |
\hfill |
| 2584 |
\pdfextension literal |
| 2585 |
{ |
| 2586 |
4.2 0.41 m |
| 2587 |
4.2 0.67 l |
| 2588 |
4.2 0.86 4.2 1.08 3.86 1.08 c |
| 2589 |
3.51 1.08 3.51 0.89 3.51 0.61 c |
| 2590 |
1.13 0.61 l |
| 2591 |
1.72 1.12 2.68 1.87 3.11 2.27 c |
| 2592 |
3.74 2.83 4.2 3.47 4.2 4.27 c |
| 2593 |
4.2 5.47 3.19 6.22 1.97 6.22 c |
| 2594 |
0.79 6.22 0.0 5.4 0.0 4.55 c |
| 2595 |
0.0 4.18 0.28 4.07 0.45 4.07 c |
| 2596 |
0.66 4.07 0.89 4.24 0.89 4.52 c |
| 2597 |
0.89 4.64 0.84 4.77 0.75 4.84 c |
| 2598 |
0.9 5.3 1.37 5.61 1.92 5.61 c |
| 2599 |
2.74 5.61 3.51 5.15 3.51 4.27 c |
| 2600 |
3.51 3.57 3.02 2.99 2.36 2.44 c |
| 2601 |
0.15 0.58 l |
| 2602 |
0.06 0.5 0.0 0.45 0.0 0.31 c |
| 2603 |
0.0 0.0 0.25 0.0 0.41 0.0 c |
| 2604 |
3.8 0.0 l |
| 2605 |
4.13 0.0 4.2 0.09 4.2 0.41 c |
| 2606 |
h f |
| 2607 |
}% |
| 2608 |
\hfill |
| 2609 |
}% |
| 2610 |
} |
| 2611 |
\tlconstcn{c__piton_glyph_3_tl} |
| 2612 |
{% |
| 2613 |
\hbox to 5pt |
| 2614 |
{% |
| 2615 |
\hfill |
| 2616 |
\pdfextension literal |
| 2617 |
{ |
| 2618 |
4.36 1.74 m |
| 2619 |
4.36 2.45 3.89 3.04 3.23 3.34 c |
| 2620 |
3.79 3.7 4.07 4.27 4.07 4.81 c |
| 2621 |
4.07 5.55 3.34 6.22 2.19 6.22 c |
| 2622 |
0.99 6.22 0.29 5.74 0.29 5.05 c |
| 2623 |
0.29 4.72 0.54 4.58 0.74 4.58 c |
| 2624 |
0.95 4.58 1.18 4.75 1.18 5.03 c |
| 2625 |
1.18 5.17 1.12 5.27 1.09 5.3 c |
| 2626 |
1.4 5.61 2.11 5.61 2.2 5.61 c |
| 2627 |
2.88 5.61 3.38 5.25 3.38 4.8 c |
| 2628 |
3.38 4.5 3.23 4.15 2.96 3.93 c |
| 2629 |
2.64 3.67 2.39 3.65 2.03 3.63 c |
| 2630 |
1.46 3.59 1.31 3.59 1.31 3.3 c |
| 2631 |
1.31 2.99 1.55 2.99 1.71 2.99 c |
| 2632 |
2.17 2.99 l |
| 2633 |
3.16 2.99 3.67 2.32 3.67 1.74 c |
| 2634 |
3.67 1.13 3.11 0.5 2.2 0.5 c |
| 2635 |
1.8 0.5 1.03 0.61 0.77 1.08 c |
| 2636 |
0.82 1.13 0.89 1.19 0.89 1.39 c |
| 2637 |
0.89 1.63 0.7 1.83 0.45 1.83 c |
| 2638 |
0.22 1.83 0.0 1.68 0.0 1.36 c |
| 2639 |
0.0 0.47 0.97 -0.11 2.2 -0.11 c |
| 2640 |
3.51 -0.11 4.36 0.81 4.36 1.74 c |
| 2641 |
h f |
| 2642 |
}% |
| 2643 |
\hfill |
| 2644 |
}% |
| 2645 |
} |
| 2646 |
\tlconstcn{c__piton_glyph_4_tl} |
| 2647 |
{% |
| 2648 |
\hbox to 5pt |
| 2649 |
{% |
| 2650 |
\hfill |
| 2651 |
\pdfextension literal |
| 2652 |
{ |
| 2653 |
4.66 1.99 m |
| 2654 |
4.66 2.3 4.42 2.3 4.26 2.3 c |
| 2655 |
3.48 2.3 l |
| 2656 |
3.48 5.82 l |
| 2657 |
3.48 6.15 3.41 6.23 3.07 6.23 c |
| 2658 |
2.79 6.23 l |
| 2659 |
2.55 6.23 2.5 6.22 2.37 6.02 c |
| 2660 |
0.09 2.44 l |
| 2661 |
0.0 2.31 0.0 2.29 0.0 2.09 c |
| 2662 |
0.0 1.76 0.09 1.69 0.4 1.69 c |
| 2663 |
2.92 1.69 l |
| 2664 |
2.92 0.61 l |
| 2665 |
2.3 0.61 l |
| 2666 |
2.14 0.61 1.9 0.61 1.9 0.3 c |
| 2667 |
1.9 0.0 2.15 0.0 2.3 0.0 c |
| 2668 |
4.1 0.0 l |
| 2669 |
4.25 0.0 4.5 0.0 4.5 0.3 c |
| 2670 |
4.5 0.61 4.26 0.61 4.1 0.61 c |
| 2671 |
3.48 0.61 l |
| 2672 |
3.48 1.69 l |
| 2673 |
4.26 1.69 l |
| 2674 |
4.41 1.69 4.66 1.69 4.66 1.99 c |
| 2675 |
2.92 2.3 m |
| 2676 |
0.7 2.3 l |
| 2677 |
2.92 5.79 l |
| 2678 |
h f |
| 2679 |
}% |
| 2680 |
\hfill |
| 2681 |
}% |
| 2682 |
} |
| 2683 |
\tlconstcn{c__piton_glyph_5_tl} |
| 2684 |
{% |
| 2685 |
\hbox to 5pt |
| 2686 |
{% |
| 2687 |
\hfill |
| 2688 |
\pdfextension literal |
| 2689 |
{ |
| 2690 |
4.2 1.9 m |
| 2691 |
4.2 2.91 3.43 3.89 2.25 3.89 c |
| 2692 |
1.9 3.89 1.46 3.82 1.05 3.6 c |
| 2693 |
1.05 5.5 l |
| 2694 |
3.45 5.5 l |
| 2695 |
3.6 5.5 3.85 5.5 3.85 5.8 c |
| 2696 |
3.85 6.11 3.61 6.11 3.45 6.11 c |
| 2697 |
0.76 6.11 l |
| 2698 |
0.43 6.11 0.36 6.02 0.36 5.7 c |
| 2699 |
0.36 3.04 l |
| 2700 |
0.36 2.86 0.36 2.63 0.68 2.63 c |
| 2701 |
0.86 2.63 0.9 2.68 0.98 2.78 c |
| 2702 |
1.25 3.1 1.66 3.28 2.24 3.28 c |
| 2703 |
3.06 3.28 3.51 2.55 3.51 1.9 c |
| 2704 |
3.51 1.1 2.8 0.5 1.96 0.5 c |
| 2705 |
1.68 0.5 1.04 0.58 0.76 1.13 c |
| 2706 |
0.81 1.18 0.89 1.25 0.89 1.45 c |
| 2707 |
0.89 1.74 0.66 1.9 0.45 1.9 c |
| 2708 |
0.3 1.9 0.0 1.81 0.0 1.42 c |
| 2709 |
0.0 0.59 0.84 -0.11 1.96 -0.11 c |
| 2710 |
3.21 -0.11 4.2 0.79 4.2 1.9 c |
| 2711 |
h f |
| 2712 |
}% |
| 2713 |
\hfill |
| 2714 |
}% |
| 2715 |
} |
| 2716 |
\tlconstcn{c__piton_glyph_6_tl} |
| 2717 |
{% |
| 2718 |
\hbox to 5pt |
| 2719 |
{% |
| 2720 |
\hfill |
| 2721 |
\pdfextension literal |
| 2722 |
{ |
| 2723 |
4.18 1.93 m |
| 2724 |
4.18 3.07 3.3 3.96 2.2 3.96 c |
| 2725 |
1.68 3.96 1.16 3.79 0.71 3.38 c |
| 2726 |
0.85 4.79 1.79 5.61 2.67 5.61 c |
| 2727 |
3.01 5.61 3.17 5.5 3.22 5.45 c |
| 2728 |
3.17 5.4 3.12 5.34 3.12 5.16 c |
| 2729 |
3.12 4.92 3.3 4.72 3.56 4.72 c |
| 2730 |
3.81 4.72 4.01 4.89 4.01 5.19 c |
| 2731 |
4.01 5.68 3.65 6.22 2.68 6.22 c |
| 2732 |
1.34 6.22 0.0 5.01 0.0 2.99 c |
| 2733 |
0.0 0.62 1.12 -0.11 2.11 -0.11 c |
| 2734 |
3.2 -0.11 4.18 0.73 4.18 1.93 c |
| 2735 |
3.49 1.93 m |
| 2736 |
3.49 1.07 2.83 0.5 2.11 0.5 c |
| 2737 |
1.46 0.5 1.07 0.99 0.87 1.6 c |
| 2738 |
0.77 1.84 0.79 2.08 0.79 2.22 c |
| 2739 |
0.79 2.84 1.39 3.34 2.15 3.34 c |
| 2740 |
2.96 3.34 3.49 2.67 3.49 1.93 c |
| 2741 |
h f |
| 2742 |
}% |
| 2743 |
\hfill |
| 2744 |
}% |
| 2745 |
} |
| 2746 |
\tlconstcn{c__piton_glyph_7_tl} |
| 2747 |
{% |
| 2748 |
\hbox to 5pt |
| 2749 |
{% |
| 2750 |
\hfill |
| 2751 |
\pdfextension literal |
| 2752 |
{ |
| 2753 |
4.36 5.8 m |
| 2754 |
4.36 6.11 4.12 6.11 3.96 6.11 c |
| 2755 |
0.66 6.11 l |
| 2756 |
0.6 6.27 0.42 6.27 0.34 6.27 c |
| 2757 |
0.0 6.27 0.0 6.05 0.0 5.86 c |
| 2758 |
0.0 5.44 l |
| 2759 |
0.0 5.25 0.0 5.03 0.34 5.03 c |
| 2760 |
0.69 5.03 0.69 5.22 0.69 5.5 c |
| 2761 |
3.33 5.5 l |
| 2762 |
1.6 3.66 1.26 1.46 1.26 0.36 c |
| 2763 |
1.26 0.22 1.26 -0.11 1.61 -0.11 c |
| 2764 |
1.78 -0.11 1.95 0.0 1.95 0.29 c |
| 2765 |
2.0 3.13 3.53 4.87 4.14 5.46 c |
| 2766 |
4.34 5.64 4.36 5.66 4.36 5.8 c |
| 2767 |
h f |
| 2768 |
}% |
| 2769 |
\hfill |
| 2770 |
}% |
| 2771 |
} |
| 2772 |
\tlconstcn{c__piton_glyph_8_tl} |
| 2773 |
{% |
| 2774 |
\hbox to 5pt |
| 2775 |
{% |
| 2776 |
\hfill |
| 2777 |
\pdfextension literal |
| 2778 |
{ |
| 2779 |
4.36 1.74 m |
| 2780 |
4.36 2.49 3.71 3.08 2.97 3.29 c |
| 2781 |
3.77 3.56 4.22 4.05 4.22 4.62 c |
| 2782 |
4.22 5.44 3.37 6.22 2.18 6.22 c |
| 2783 |
0.98 6.22 0.14 5.43 0.14 4.62 c |
| 2784 |
0.14 4.05 0.6 3.55 1.39 3.29 c |
| 2785 |
0.64 3.08 0.0 2.49 0.0 1.74 c |
| 2786 |
0.0 0.77 0.93 -0.11 2.18 -0.11 c |
| 2787 |
3.44 -0.11 4.36 0.77 4.36 1.74 c |
| 2788 |
3.53 4.61 m |
| 2789 |
3.53 4.04 2.91 3.6 2.18 3.6 c |
| 2790 |
1.45 3.6 0.83 4.05 0.83 4.61 c |
| 2791 |
0.83 5.13 1.39 5.61 2.18 5.61 c |
| 2792 |
2.96 5.61 3.53 5.13 3.53 4.61 c |
| 2793 |
3.67 1.75 m |
| 2794 |
3.67 1.06 3.01 0.5 2.18 0.5 c |
| 2795 |
1.35 0.5 0.69 1.06 0.69 1.75 c |
| 2796 |
0.69 2.36 1.27 2.99 2.18 2.99 c |
| 2797 |
3.1 2.99 3.67 2.36 3.67 1.75 c |
| 2798 |
h f |
| 2799 |
}% |
| 2800 |
\hfill |
| 2801 |
}% |
| 2802 |
} |
| 2803 |
\tlconstcn{c__piton_glyph_9_tl} |
| 2804 |
{% |
| 2805 |
\hbox to 5pt |
| 2806 |
{% |
| 2807 |
\hfill |
| 2808 |
\pdfextension literal |
| 2809 |
{ |
| 2810 |
4.18 3.12 m |
| 2811 |
4.18 5.53 3.07 6.22 2.12 6.22 c |
| 2812 |
1.01 6.22 0.0 5.39 0.0 4.18 c |
| 2813 |
0.0 3.04 0.88 2.15 1.98 2.15 c |
| 2814 |
2.5 2.15 3.02 2.32 3.47 2.73 c |
| 2815 |
3.37 1.49 2.59 0.5 1.63 0.5 c |
| 2816 |
1.54 0.5 1.18 0.51 0.97 0.67 c |
| 2817 |
1.01 0.72 1.06 0.78 1.06 0.95 c |
| 2818 |
1.06 1.19 0.88 1.39 0.62 1.39 c |
| 2819 |
0.37 1.39 0.17 1.22 0.17 0.92 c |
| 2820 |
0.17 0.6 0.35 -0.11 1.63 -0.11 c |
| 2821 |
2.95 -0.11 4.18 1.14 4.18 3.12 c |
| 2822 |
3.4 3.89 m |
| 2823 |
3.4 3.34 2.86 2.77 2.03 2.77 c |
| 2824 |
1.22 2.77 0.69 3.44 0.69 4.18 c |
| 2825 |
0.69 5.05 1.4 5.61 2.12 5.61 c |
| 2826 |
2.55 5.61 2.83 5.38 2.99 5.18 c |
| 2827 |
3.31 4.79 3.4 4.6 3.4 3.89 c |
| 2828 |
h f |
| 2829 |
}% |
| 2830 |
\hfill |
| 2831 |
}% |
| 2832 |
} |
| 2833 |
\ExplSyntaxOn |
| 2834 |
\cs_new_protected:Npn \__piton_test_version:n #1 |
| 2835 |
{ |
| 2836 |
\str_if_eq:onF \PitonFileVersion { #1 } |
| 2837 |
{ \__piton_error:n { bad~version~of~piton.lua } } |
| 2838 |
} |
| 2839 |
\hook_gput_code:nnn { begindocument } { . } |
| 2840 |
{ |
| 2841 |
\lua_load_module:n { piton } |
| 2842 |
\lua_now:n |
| 2843 |
{ |
| 2844 |
tex.sprint ( luatexbase.catcodetables.expl , |
| 2845 |
[[\__piton_test_version:n {]] .. piton_version .. "}" ) |
| 2846 |
} |
| 2847 |
} |
| 2848 |
\endinput |
| 2849 |
%% |
| 2850 |
%% End of file `piton.sty'. |