diff options
author | Karl Berry <karl@freefriends.org> | 2021-08-29 20:25:20 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-08-29 20:25:20 +0000 |
commit | e56e35b7667194ff586da96dffe19f8174ea02e6 (patch) | |
tree | 4f1b3e7383cd24b856da90714fd08c930c2fa6af /Master/texmf-dist/tex/latex/etl/etl.sty | |
parent | 3bbd8aed82ef6ef60094312f02510b40398c5df5 (diff) |
etl (29aug21)
git-svn-id: svn://tug.org/texlive/trunk@60364 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/etl/etl.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/etl/etl.sty | 125 |
1 files changed, 110 insertions, 15 deletions
diff --git a/Master/texmf-dist/tex/latex/etl/etl.sty b/Master/texmf-dist/tex/latex/etl/etl.sty index 55f55e73812..de2abad38c5 100644 --- a/Master/texmf-dist/tex/latex/etl/etl.sty +++ b/Master/texmf-dist/tex/latex/etl/etl.sty @@ -30,12 +30,12 @@ %% etl.sty %% \ProvidesExplPackage{etl} - {2021-08-20} {0.1} + {2021-08-28} {0.2} {expandable token list manipulation} \cs_if_exist:NF \tex_expanded:D { \msg_new:nnn { etl } { expanded-missing } - { The expanded primitive is required. } + { The~ expanded~ primitive~ is~ required. } \msg_fatal:nn { etl } { expanded-missing } } \cs_new_eq:NN \__etl_expanded:w \tex_expanded:D @@ -93,12 +93,10 @@ \cs_new:Npn \etl_act:nnnnnnn #1#2#3#4#5#6#7 { \__etl_unexpanded:w \__etl_expanded:w - { - { - \__etl_act:w #7 {\s__etl_stop} . \s__etl_stop {#5} {#1} {#2} {#3} - \__etl_act_result:n {#6} {#4} - } - } + {{ + \__etl_act:w #7 {\s__etl_stop} . \s__etl_stop {#5} {#1} {#2} {#3} + \__etl_act_result:n {#6} {#4} + }} } \cs_new:Npn \__etl_act:nnnnnnn #1#2#3#4#5#6#7 { @@ -684,17 +682,36 @@ { {#2} {#2} {} {#3} \s__etl_mark } {#1} } -\exp_args:Nno \use:n { \cs_new_protected:Npn \etl_new_if_in:Nnn #1#2 } +\exp_args:Nno \use:n { \cs_new_protected:Npn \etl_new_if_in:Nnn #1#2#3 } { - \exp_args:Nc \__etl_new_if_in:NNnn - { __etl_user_function ~ \cs_to_str:N #1 ~ \tl_to_str:n {#2} :w } + \scan_stop: + \if_false: { \fi: + \exp_args:Nc \__etl_new_if_in:NnNnn + { __etl_user_function ~ if_in ~ \tl_to_str:n {#2} :w } + ? #1 {#2} + {#3} + \if_false: } \fi: + } +\cs_new_protected:Npn \__etl_new_if_in:NnNnn #1#2#3#4 + { + \cs_if_exist:NTF #1 + { + \cs_set:Npn \__etl_tmp:w ##1 #4 {} + \cs_if_eq:NNTF #1 \__etl_tmp:w + { \__etl_new_if_in:NNnn #1 #3 {#4} } + { + \exp_args:Nc \__etl_new_if_in:NnNnn + { __etl_user_function ~ if_in #2 ~ \tl_to_str:n {#4} :w } + { #2? } + #3 {#4} + } + } + { \__etl_new_if_in:NNnn #1 #3 {#4} } } \cs_new_protected:Npn \__etl_new_if_in:NNnn #1#2#3#4 { - \scan_stop: - \if_false: { \fi: - \cs_new:Npn #1 ##1 #3 {} + \cs_gset:Npn #1 ##1 #3 {} \prg_new_conditional:Npnn #2 ##1 {#4} { \if:w @@ -709,7 +726,85 @@ \prg_return_false: \fi: } - \if_false: } \fi: + } +\msg_new:nnn { etl } { empty-search-text } + { The~ search~ text~ of~ #1 must~ not~ be~ empty. } +\cs_new_protected:Npn \__etl_new_replace_def:NNn #1#2#3 + { + \tl_if_empty:nTF {#3} + { \msg_error:nnn { etl } { empty-search-text } { #2 } } + { + \scan_stop: + \if_false: { \fi: + \exp_args:Nc \__etl_new_replace_def_aux:NnNnN + { __etl_user_function ~ replace ~ \tl_to_str:n {#3} ~ :Nnw } + ? + #2 {#3} + #1 + \if_false: } \fi: + } + } +\cs_new_protected:Npn \__etl_new_replace_def_aux:NnNnN #1#2#3#4#5 + { + \cs_if_exist:NTF #1 + { + \__etl_new_replace_def_aux:Nn \__etl_tmp:w {#4} + \cs_if_eq:NNTF #1 \__etl_tmp:w + { #5 #1#3 {#4} } + { + \exp_args:Nc \__etl_new_replace_def_aux:NnNnN + { __etl_user_function ~ replace #2 ~ \tl_to_str:n {#4} ~ :Nnw } + { #2? } #3 {#4} #5 + } + } + { + \__etl_new_replace_def_aux:Nn #1 {#4} + #5 #1#3 {#4} + } + } +\cs_new_protected:Npn \__etl_new_replace_def_aux:Nn #1#2 + { + \cs_gset:Npn #1 ##1##2 ##3#2 + { + \__etl_new_replace_wrap:w ##3 \s__etl_stop \__etl_unexpanded:w {##2} + ##1 #1 {##2} {}{} + } + } +\cs_new:Npn \__etl_new_replace_wrap:w #1\s__etl_stop + { \__etl_unexpanded:w \exp_after:wN { \use_none:nn #1 } } +\cs_new:Npn \__etl_new_replace_once:w #1#2 #3\s__etl_stop + { \__etl_unexpanded:w \exp_after:wN { \use_none:nn #3 } } +\cs_new:Npn \__etl_new_replace_done:w + { \exp_after:wN \use_none:n \exp_after:wN { \if_false: } \fi: } +\cs_new_protected:Npn \etl_new_replace_once:Nn + { \__etl_new_replace_def:NNn \__etl_new_replace_once:NNn } +\cs_new_protected:Npn \__etl_new_replace_once:NNn #1#2#3 + { + \cs_new:Npn #2 ##1##2 + { + \__etl_unexpanded:w \__etl_expanded:w + {{ + \if_false: { \fi: + #1 \__etl_new_replace_once:w {##2} {}{} ##1 \s__etl_stop + \__etl_new_replace_done:w #3 + } + }} + } + } +\cs_new_protected:Npn \etl_new_replace_all:Nn + { \__etl_new_replace_def:NNn \__etl_new_replace_all:NNn } +\cs_new_protected:Npn \__etl_new_replace_all:NNn #1#2#3 + { + \cs_new:Npn #2 ##1##2 + { + \__etl_unexpanded:w \__etl_expanded:w + {{ + \if_false: { \fi: + #1 #1 {##2} {}{} ##1 \s__etl_stop + \__etl_new_replace_done:w #3 + } + }} + } } %% %% |