| 1 |
% piton.4ht (2024-10-01-13:46), generated from tex4ht-4ht.tex |
| 2 |
% Copyright 2023-2024 TeX Users Group |
| 3 |
% |
| 4 |
% This work may be distributed and/or modified under the |
| 5 |
% conditions of the LaTeX Project Public License, either |
| 6 |
% version 1.3c of this license or (at your option) any |
| 7 |
% later version. The latest version of this license is in |
| 8 |
% http://www.latex-project.org/lppl.txt |
| 9 |
% and version 1.3c or later is part of all distributions |
| 10 |
% of LaTeX version 2005/12/01 or later. |
| 11 |
% |
| 12 |
% This work has the LPPL maintenance status "maintained". |
| 13 |
% |
| 14 |
% The Current Maintainer of this work |
| 15 |
% is the TeX4ht Project <http://tug.org/tex4ht>. |
| 16 |
% |
| 17 |
% If you modify this program, changing the |
| 18 |
% version identification would be appreciated. |
| 19 |
\immediate\write-1{version 2024-10-01-13:46} |
| 20 |
|
| 21 |
|
| 22 |
\ExplSyntaxOn |
| 23 |
\IfPackageLoadedTF{xcolor}{}{\RequirePackage{xcolor}} |
| 24 |
|
| 25 |
\def\:pitonvisiblespace{ \HCode{\string&\#x2423;} } |
| 26 |
\cs_new_protected:Npn \:__piton_replace_spaces:n #1 |
| 27 |
{ |
| 28 |
\tl_set:Nn \l_tmpa_tl { #1 } |
| 29 |
\bool_if:NTF \l__piton_show_spaces_bool |
| 30 |
{ |
| 31 |
\tl_set:Nn \l__piton_space_tl {\:pitonvisiblespace} % U+2423 |
| 32 |
\regex_replace_all:nnN { \x20 } {\c{:pitonvisiblespace}} \l_tmpa_tl |
| 33 |
} |
| 34 |
{ |
| 35 |
\bool_if:NTF \l__piton_break_lines_in_Piton_bool |
| 36 |
{ |
| 37 |
\regex_replace_all:nnN |
| 38 |
{ \x20 } |
| 39 |
{ \c { __piton_breakable_space: } } |
| 40 |
\l_tmpa_tl |
| 41 |
\regex_replace_all:nnN |
| 42 |
{ \c { l__piton_space_tl } } |
| 43 |
{ \c { __piton_breakable_space: } } |
| 44 |
\l_tmpa_tl |
| 45 |
} |
| 46 |
{ |
| 47 |
\regex_replace_all:nnN { \x20 } { \x20 } \l_tmpa_tl |
| 48 |
} |
| 49 |
} |
| 50 |
\l_tmpa_tl |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
\HLet\__piton_replace_spaces:n\:__piton_replace_spaces:n |
| 55 |
|
| 56 |
|
| 57 |
\NewConfigure{pitonline}{3} |
| 58 |
\NewConfigure{pitonnumber}{2} |
| 59 |
\protected\def\:tempa #1\__piton_end_line:{ |
| 60 |
\:pitonendignorelines\glet\:pitonendignorelines\relax |
| 61 |
\group_begin: |
| 62 |
% we set line in a box, because otherwise lines are collapsed sometimes |
| 63 |
\hbox_set:Nn \l_tmpa_box{ |
| 64 |
\a:pitonline |
| 65 |
\a:pitonnumber |
| 66 |
\bool_if:NT \l__piton_line_numbers_bool |
| 67 |
{ |
| 68 |
\bool_if:nF |
| 69 |
{ |
| 70 |
\str_if_eq_p:nn { #1 } { \PitonStyle {Prompt}{} } |
| 71 |
&& |
| 72 |
\l__piton_skip_empty_lines_bool |
| 73 |
} |
| 74 |
{ \int_gincr:N \g__piton_visual_line_int} |
| 75 |
|
| 76 |
\bool_if:nT |
| 77 |
{ |
| 78 |
! \str_if_eq_p:nn { #1 } { \PitonStyle {Prompt}{} } |
| 79 |
|| |
| 80 |
( ! \l__piton_skip_empty_lines_bool && \l__piton_label_empty_lines_bool ) |
| 81 |
} |
| 82 |
\__piton_print_number: |
| 83 |
} |
| 84 |
\b:pitonnumber |
| 85 |
\language = -1 |
| 86 |
\raggedright |
| 87 |
\strut |
| 88 |
% \HCode{<code>} |
| 89 |
\b:pitonline |
| 90 |
\NoFonts |
| 91 |
\__piton_replace_spaces:n { #1 } |
| 92 |
\EndNoFonts |
| 93 |
% |
| 94 |
\c:pitonline |
| 95 |
} |
| 96 |
\box_use_drop:N \l_tmpa_box |
| 97 |
\group_end: |
| 98 |
} |
| 99 |
\HLet\__piton_begin_line:\:tempa |
| 100 |
|
| 101 |
|
| 102 |
\NewConfigure{piton}{2} |
| 103 |
|
| 104 |
% Piton environments and file input produces extra blank line at the start |
| 105 |
% we use TeX4ht specials to remove them |
| 106 |
\gdef\:pitonendignorelines{} |
| 107 |
\pend:def\__piton_pre_env:{\a:piton |
| 108 |
\ht:special{t4ht@[}% ignore next linebreak, to preven spurious blank line at the beginning of listings |
| 109 |
\gdef\:pitonendignorelines{\ht:special{t4ht@]}} |
| 110 |
} |
| 111 |
\append:def\__piton_write_aux:{\b:piton} |
| 112 |
|
| 113 |
|
| 114 |
\NewDocumentCommand { \:__piton_piton_standard } { m } |
| 115 |
{ |
| 116 |
\group_begin: |
| 117 |
\ttfamily |
| 118 |
\a:pitonline\b:pitonline |
| 119 |
\automatichyphenmode = 1 |
| 120 |
\cs_set_eq:NN \\ \c_backslash_str |
| 121 |
\cs_set_eq:NN \% \c_percent_str |
| 122 |
\cs_set_eq:NN \{ \c_left_brace_str |
| 123 |
\cs_set_eq:NN \} \c_right_brace_str |
| 124 |
\cs_set_eq:NN \$ \c_dollar_str |
| 125 |
\cs_set_eq:cN { ~ } \space |
| 126 |
\cs_set_protected:Npn \__piton_begin_line: { } |
| 127 |
\cs_set_protected:Npn \__piton_end_line: { } |
| 128 |
\tl_set:Ne \l_tmpa_tl |
| 129 |
{ |
| 130 |
\lua_now:e |
| 131 |
{ piton.ParseBis('\l__piton_language_str',token.scan_string()) } |
| 132 |
{ #1 } |
| 133 |
} |
| 134 |
\bool_if:NTF \l__piton_show_spaces_bool |
| 135 |
{ \regex_replace_all:nnN { \x20 } { ^^^^2423 } \l_tmpa_tl } % U+2423 |
| 136 |
{ |
| 137 |
\bool_if:NT \l__piton_break_lines_in_piton_bool |
| 138 |
{ \regex_replace_all:nnN { \x20 } { \x20 } \l_tmpa_tl } |
| 139 |
} |
| 140 |
% our extra code to remove the space glyph |
| 141 |
\regex_replace_all:nnN { \x20 } { \c { __piton_breakable_space: } } \l_tmpa_tl |
| 142 |
\l_tmpa_tl |
| 143 |
\c:pitonline |
| 144 |
\group_end: |
| 145 |
} |
| 146 |
|
| 147 |
\HLet\__piton_piton_standard\:__piton_piton_standard |
| 148 |
|
| 149 |
\NewDocumentCommand { \:__piton_piton_verbatim } { v } |
| 150 |
{ |
| 151 |
\group_begin: |
| 152 |
\ttfamily |
| 153 |
\a:pitonline\b:pitonline |
| 154 |
\automatichyphenmode = 1 |
| 155 |
\cs_set_protected:Npn \__piton_begin_line: { } |
| 156 |
\cs_set_protected:Npn \__piton_end_line: { } |
| 157 |
\tl_set:Ne \l_tmpa_tl |
| 158 |
{ |
| 159 |
\lua_now:e |
| 160 |
{ piton.Parse('\l__piton_language_str',token.scan_string()) } |
| 161 |
{ #1 } |
| 162 |
} |
| 163 |
\bool_if:NT \l__piton_show_spaces_bool |
| 164 |
{ \regex_replace_all:nnN { \x20 } { ^^^^2423 } \l_tmpa_tl } % U+2423 |
| 165 |
% our extra code to remove the space glyph |
| 166 |
\regex_replace_all:nnN { \x20 } { \c { __piton_breakable_space: } } \l_tmpa_tl |
| 167 |
\l_tmpa_tl |
| 168 |
\c:pitonline |
| 169 |
\group_end: |
| 170 |
} |
| 171 |
|
| 172 |
\HLet\__piton_piton_verbatim\:__piton_piton_verbatim |
| 173 |
|
| 174 |
\ExplSyntaxOff |
| 175 |
\Hinput{piton} |
| 176 |
\endinput |
| 177 |
|