From 81ad2a9f387b54bdad66ad8e98714b742d059445 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 29 Jul 2013 22:37:58 +0000 Subject: gtl (29jul13) git-svn-id: svn://tug.org/texlive/trunk@31306 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/gtl/gtl.sty | 619 ++++++++++++++++++++++++++++++++ 1 file changed, 619 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/gtl/gtl.sty (limited to 'Master/texmf-dist/tex/latex') diff --git a/Master/texmf-dist/tex/latex/gtl/gtl.sty b/Master/texmf-dist/tex/latex/gtl/gtl.sty new file mode 100644 index 00000000000..8bd342609b0 --- /dev/null +++ b/Master/texmf-dist/tex/latex/gtl/gtl.sty @@ -0,0 +1,619 @@ +%% +%% This is file `gtl.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% gtl.dtx (with options: `package') +%% +%% Do not distribute a modified version of this file. +%% +%% Communicate any suggestions for changing this package +%% to Bruno Le Floch (blflatex@gmail.com). +%% +%% File: gtl.dtx Copyright (C) 2013 Bruno Le Floch +%% +%% It may be distributed and/or modified under the conditions of the +%% LaTeX Project Public License (LPPL), either version 1.3c of this +%% license or (at your option) any later version. The latest version +%% of this license is in the file +%% +%% http://www.latex-project.org/lppl.txt +%% +%% ----------------------------------------------------------------------- +\RequirePackage{expl3}[2013/07/01] +\ProvidesExplPackage + {gtl} {2013/07/28} {0.0a} {Manipulate unbalanced lists of tokens} +\cs_generate_variant:Nn \use:nn { no } +\cs_new:Npn \__gtl_exp_not_n:N #1 { \exp_not:n {#1} } +\cs_new:Npn \__gtl_brace:nn #1#2 { { #1 #2 } } +\cs_new:Npn \__gtl_brace_swap:nn #1#2 { { #2 #1 } } +\cs_new_nopar:Npn \__gtl_strip_nil_mark:w + { \__gtl_strip_nil_mark_aux:w \prg_do_nothing: } +\cs_new:Npn \__gtl_strip_nil_mark_aux:w #1 \q_nil \q_mark + { \exp_not:o {#1} } +\__scan_new:N \s__gtl +\cs_new_protected_nopar:Npn \gtl_set:Nn { \__gtl_set:NNn \tl_set:Nn } +\cs_new_protected_nopar:Npn \gtl_gset:Nn { \__gtl_set:NNn \tl_gset:Nn } +\cs_new_protected_nopar:Npn \gtl_const:Nn { \__gtl_set:NNn \tl_const:Nn } +\cs_new_protected_nopar:Npn \gtl_set:Nx { \__gtl_set:NNn \tl_set:Nx } +\cs_new_protected_nopar:Npn \gtl_gset:Nx { \__gtl_set:NNn \tl_gset:Nx } +\cs_new_protected_nopar:Npn \gtl_const:Nx { \__gtl_set:NNn \tl_const:Nx } +\cs_new_protected:Npn \__gtl_set:NNn #1#2#3 + { #1 #2 { \s__gtl { } {#3} { } \s__stop } } +\gtl_const:Nn \c_empty_gtl { } +\tl_const:Nn \c_group_end_gtl { \s__gtl { { } } { } { } \s__stop } +\tl_const:Nn \c_group_begin_gtl { \s__gtl { } { } { { } } \s__stop } +\cs_new_protected:Npn \gtl_new:N #1 + { \cs_new_eq:NN #1 \c_empty_gtl } +\cs_new_eq:NN \gtl_set_eq:NN \tl_set_eq:NN +\cs_new_eq:NN \gtl_gset_eq:NN \tl_gset_eq:NN +\cs_new_protected:Npn \gtl_clear:N #1 + { \gtl_set_eq:NN #1 \c_empty_gtl } +\cs_new_protected:Npn \gtl_gclear:N #1 + { \gtl_gset_eq:NN #1 \c_empty_gtl } +\cs_new_protected:Npn \gtl_clear_new:N #1 + { \gtl_if_exist:NTF #1 { \gtl_clear:N #1 } { \gtl_new:N #1 } } +\cs_new_protected:Npn \gtl_gclear_new:N #1 + { \gtl_if_exist:NTF #1 { \gtl_gclear:N #1 } { \gtl_new:N #1 } } +\prg_new_eq_conditional:NNn \gtl_if_exist:N \tl_if_exist:N + { p , T , F , TF } +\cs_new_protected:Npn \gtl_put_left:Nn #1#2 + { \tl_set:Nx #1 { \exp_after:wN \__gtl_put_left:wn #1 {#2} } } +\cs_new_protected:Npn \gtl_gput_left:Nn #1#2 + { \tl_gset:Nx #1 { \exp_after:wN \__gtl_put_left:wn #1 {#2} } } +\cs_new:Npn \__gtl_put_left:wn \s__gtl #1#2#3 \s__stop #4 + { + \tl_if_empty:nTF {#1} + { \exp_not:n { \s__gtl { } { #4 #2 } {#3} \s__stop } } + { + \s__gtl + { \exp_not:o { \__gtl_brace:nn {#4} #1 } } + { \exp_not:n {#2} } + { \exp_not:n {#3} } + \s__stop + } + } +\cs_new_protected:Npn \gtl_put_right:Nn #1#2 + { \tl_set:Nx #1 { \exp_after:wN \__gtl_put_right:wn #1 {#2} } } +\cs_new_protected:Npn \gtl_gput_right:Nn #1#2 + { \tl_gset:Nx #1 { \exp_after:wN \__gtl_put_right:wn #1 {#2} } } +\cs_new:Npn \__gtl_put_right:wn \s__gtl #1#2#3 \s__stop #4 + { + \tl_if_empty:nTF {#3} + { \exp_not:n { \s__gtl {#1} { #2 #4 } { } \s__stop } } + { + \s__gtl + { \exp_not:n {#1} } + { \exp_not:n {#2} } + { \exp_not:o { \__gtl_brace_swap:nn {#4} #3 } } + \s__stop + } + } +\cs_new_protected:Npn \gtl_concat:NNN #1#2#3 + { \tl_set:Nx #1 { \exp_last_two_unbraced:Noo \__gtl_concat:ww #2 #3 } } +\cs_new_protected:Npn \gtl_gconcat:NNN #1#2#3 + { \tl_gset:Nx #1 { \exp_last_two_unbraced:Noo \__gtl_concat:ww #2 #3 } } +\cs_new:Npn \__gtl_concat:ww \s__gtl #1#2#3 \s__stop \s__gtl #4#5#6 \s__stop + { + \tl_if_blank:nTF {#3} + { + \tl_if_blank:nTF {#4} + { \__gtl_concat_aux:nnnnnn } + { \__gtl_concat_auxi:nnnnnn } + } + { + \tl_if_blank:nTF {#4} + { \__gtl_concat_auxii:nnnnnn } + { \__gtl_concat_auxiv:nnnn } + } + {#1} {#2} {#3} {#4} {#5} {#6} + \s__stop + } +\cs_new:Npn \__gtl_concat_aux:nnnnnn #1#2#3#4#5#6 + { \exp_not:n { \s__gtl {#1} { #2 #5 } {#6} } } +\cs_new:Npn \__gtl_concat_auxi:nnnnnn #1#2#3#4#5#6 + { + \s__gtl + { + \exp_not:n {#1} + \exp_not:f + { \__gtl_concat_auxiii:w \__gtl_brace:nn {#2} #4 ~ \q_stop } + } + { \exp_not:n {#5} } + { \exp_not:n {#6} } + } +\cs_new:Npn \__gtl_concat_auxii:nnnnnn #1#2#3#4#5#6 + { + \s__gtl + { \exp_not:n {#1} } + { \exp_not:n {#2} } + { + \exp_not:n {#6} + \exp_not:f + { \__gtl_concat_auxiii:w \__gtl_brace_swap:nn {#5} #3 ~ \q_stop } + } + } +\cs_new:Npn \__gtl_concat_auxiii:w #1 ~ #2 \q_stop {#1} +\cs_new:Npn \__gtl_concat_auxiv:nnnn #1#2#3#4 + { + \tl_if_single:nTF {#3} + { \__gtl_concat_auxv:wnwnn } + { \__gtl_concat_auxvi:nnwnwnn } + #3 ~ \q_mark #4 ~ \q_mark {#1} {#2} + } +\cs_new:Npn \__gtl_concat_auxv:wnwnn + #1#2 \q_mark #3#4 \q_mark #5#6 + { + \__gtl_concat:ww + \s__gtl {#5} { #6 { #1 #3 } } { } \s__stop + \s__gtl {#4} + } +\cs_new:Npn \__gtl_concat_auxvi:nnwnwnn + #1#2#3 \q_mark #4#5 \q_mark #6#7 + { + \__gtl_concat:ww + \s__gtl {#6} {#7} { { #2 { #1 #4 } } #3 } \s__stop + \s__gtl {#5} + } +\cs_new:Npn \gtl_to_str:N #1 { \exp_after:wN \__gtl_to_str:w #1 } +\cs_new:Npn \gtl_to_str:n #1 { \__gtl_to_str:w #1 } +\cs_new:Npn \__gtl_to_str:w \s__gtl #1#2#3 \s__stop + { \__gtl_to_str_loopi:nnw { } #1 \q_nil \q_mark {#2} {#3} } +\cs_new:Npx \__gtl_to_str_loopi:nnw #1#2 + { + \exp_not:N \quark_if_nil:nTF {#2} + { \exp_not:N \__gtl_to_str_testi:nnw {#1} {#2} } + { \exp_not:N \__gtl_to_str_loopi:nnw { #1 #2 \iow_char:N \} } } + } +\cs_new:Npx \__gtl_to_str_testi:nnw #1#2#3 \q_mark + { + \exp_not:N \tl_if_empty:nTF {#3} + { \exp_not:N \__gtl_to_str_endi:nnn {#1} } + { + \exp_not:N \__gtl_to_str_loopi:nnw + { #1 #2 \iow_char:N \} } #3 \exp_not:N \q_mark + } + } +\cs_new:Npn \__gtl_to_str_endi:nnn #1#2#3 + { \__gtl_to_str_loopii:nnw #3 { #1 #2 } \q_nil \q_stop } +\cs_new:Npx \__gtl_to_str_loopii:nnw #1#2 + { + \exp_not:N \quark_if_nil:nTF {#2} + { \exp_not:N \__gtl_to_str_testii:nnw {#1} {#2} } + { \exp_not:N \__gtl_to_str_loopii:nnw { #2 \iow_char:N \{ #1 } } + } +\cs_new:Npx \__gtl_to_str_testii:nnw #1#2#3 \q_stop + { + \exp_not:N \tl_if_empty:nTF {#3} + { \exp_not:N \tl_to_str:n {#1} } + { + \exp_not:N \__gtl_to_str_loopii:nnw + { #2 \iow_char:N \{ #1 } #3 \exp_not:N \q_stop + } + } +\cs_new_protected:Npn \gtl_show:N #1 + { \exp_args:Nx \tl_show:n { \token_to_str:N #1 = \gtl_to_str:N #1 } } +\prg_new_conditional:Npnn \gtl_if_eq:NN #1#2 { p , T , F , TF } + { \tl_if_eq:NNTF #1 #2 { \prg_return_true: } { \prg_return_false: } } +\prg_new_conditional:Npnn \gtl_if_empty:N #1 { p , T , F , TF } + { + \tl_if_eq:NNTF #1 \c_empty_gtl + { \prg_return_true: } { \prg_return_false: } + } +\prg_new_conditional:Npnn \gtl_if_tl:N #1 { p , T , F , TF } + { \exp_after:wN \__gtl_if_tl_return:w #1 } +\cs_new:Npn \__gtl_if_tl_return:w \s__gtl #1#2#3 \s__stop + { + \tl_if_empty:nTF { #1 #3 } + { \prg_return_true: } { \prg_return_false: } + } +\prg_new_conditional:Npnn \gtl_if_single_token:N #1 { p , T , F , TF } + { \exp_after:wN \__gtl_if_single_token_return:w #1 } +\cs_new:Npn \__gtl_if_single_token_return:w \s__gtl #1#2#3 \s__stop + { + \bool_if:nTF + { + \tl_if_empty_p:n {#2} + && \tl_if_single_p:n { #1 #3 } + && \tl_if_empty_p:o { \use:n #1 #3 } + || + \tl_if_single_token_p:n {#2} + && \tl_if_empty_p:n { #1 #3 } + } + { \prg_return_true: } + { \prg_return_false: } + } +\prg_new_conditional:Npnn \gtl_if_blank:N #1 { p , T , F , TF } + { \exp_after:wN \__gtl_if_blank_return:w #1 } +\cs_new:Npn \__gtl_if_blank_return:w \s__gtl #1#2#3 \s__stop + { + \tl_if_blank:nTF { #1 #2 #3 } + { \prg_return_true: } + { \prg_return_false: } + } +\prg_new_conditional:Npnn \gtl_if_head_is_group_begin:N #1 + { p , T , F , TF } + { + \exp_after:wN \__gtl_head:wnnnnn #1 + { \prg_return_false: } + { \prg_return_true: } + { \prg_return_false: } + { \prg_return_false: } + { \prg_return_false: \use_none:n } + } +\prg_new_conditional:Npnn \gtl_if_head_is_group_end:N #1 + { p , T , F , TF } + { + \exp_after:wN \__gtl_head:wnnnnn #1 + { \prg_return_false: } + { \prg_return_false: } + { \prg_return_true: } + { \prg_return_false: } + { \prg_return_false: \use_none:n } + } +\prg_new_conditional:Npnn \gtl_if_head_is_space:N #1 + { p , T , F , TF } + { + \exp_after:wN \__gtl_head:wnnnnn #1 + { \prg_return_false: } + { \prg_return_false: } + { \prg_return_false: } + { \prg_return_true: } + { \prg_return_false: \use_none:n } + } +\prg_new_conditional:Npnn \gtl_if_head_is_N_type:N #1 + { p , T , F , TF } + { + \exp_after:wN \__gtl_head:wnnnnn #1 + { \prg_return_false: } + { \prg_return_false: } + { \prg_return_false: } + { \prg_return_false: } + { \prg_return_true: \use_none:n } + } +\prg_new_conditional:Npnn \gtl_if_head_eq_catcode:NN #1#2 + { p , T , F , TF } + { \__gtl_if_head_eq_code_return:NNN \if_catcode:w #1#2 } +\prg_new_conditional:Npnn \gtl_if_head_eq_charcode:NN #1#2 + { p , T , F , TF } + { \__gtl_if_head_eq_code_return:NNN \if_charcode:w #1#2 } +\cs_new:Npn \__gtl_if_head_eq_code_return:NNN #1#2#3 + { + #1 + \exp_not:N #3 + \exp_after:wN \__gtl_head:wnnnnn #2 + { ? \use_none:nn } + { \c_group_begin_token } + { \c_group_end_token } + { \c_space_token } + { \exp_not:N } + \prg_return_true: + \else: + \prg_return_false: + \fi: + } +\prg_new_conditional:Npnn \gtl_if_head_eq_meaning:NN #1#2 + { p , T , F , TF } + { \__gtl_if_head_eq_meaning_return:NN #1#2 } +\cs_new:Npn \__gtl_if_head_eq_meaning_return:NN #1#2 + { + \exp_after:wN \__gtl_head:wnnnnn #1 + { \if_false: } + { \if_meaning:w #2 \c_group_begin_token } + { \if_meaning:w #2 \c_group_end_token } + { \if_meaning:w #2 \c_space_token } + { \if_meaning:w #2 } + \prg_return_true: + \else: + \prg_return_false: + \fi: + } +\cs_new:Npn \__gtl_head:wnnnnn \s__gtl #1#2#3 \s__stop #4#5#6#7#8 + { + \tl_if_empty:nTF {#1} + { + \tl_if_empty:nTF {#2} + { \tl_if_empty:nTF {#3} {#4} {#5} } + { \__gtl_head_aux:nwnnnn {#2} \q_stop {#5} {#6} {#7} {#8} } + } + { \__gtl_head_aux:nwnnnn #1 \q_stop {#5} {#6} {#7} {#8} } + } +\cs_new:Npn \__gtl_head_aux:nwnnnn #1#2 \q_stop #3#4#5#6 + { + \tl_if_head_is_group:nTF {#1} {#3} + { + \tl_if_empty:nTF {#1} {#4} + { + \tl_if_head_is_space:nTF {#1} {#5} + { \if_false: { \fi: \__gtl_head_auxii:N #1 } {#6} } + } + } + } +\cs_new:Npn \__gtl_head_auxii:N #1 + { + \exp_after:wN \__gtl_head_auxiii:Nnn + \exp_after:wN #1 + \exp_after:wN { \if_false: } \fi: + } +\cs_new:Npn \__gtl_head_auxiii:Nnn #1#2#3 { #3 #1 } +\cs_new:Npn \gtl_head:N #1 + { + \exp_after:wN \__gtl_head:wnnnnn #1 + { } + { \exp_after:wN { \if_false: } \fi: } + { \if_false: { \fi: } } + { ~ } + { \__gtl_exp_not_n:N } + } +\cs_new:Npn \gtl_head_do:NN #1#2 + { + \exp_after:wN \__gtl_head:wnnnnn #1 + { #2 \q_no_value } + { \exp_after:wN #2 \exp_after:wN { \if_false: } \fi: } + { \if_false: { \fi: #2 } } + { #2 ~ } + { #2 } + } +\cs_new_protected:Npn \gtl_get_left:NN #1#2 + { + \exp_after:wN \__gtl_head:wnnnnn #1 + { \gtl_set:Nn #2 { \q_no_value } } + { \gtl_set_eq:NN #2 \c_group_begin_gtl } + { \gtl_set_eq:NN #2 \c_group_end_gtl } + { \gtl_set:Nn #2 { ~ } } + { \gtl_set:Nn #2 } + } +\cs_new_protected:Npn \gtl_pop_left:N #1 + { \tl_set:Nx #1 { \exp_after:wN \__gtl_pop_left:w #1 } } +\cs_new_protected:Npn \gtl_gpop_left:N #1 + { \tl_gset:Nx #1 { \exp_after:wN \__gtl_pop_left:w #1 } } +\cs_new:Npn \__gtl_pop_left:w \s__gtl #1#2#3 \s__stop + { + \tl_if_empty:nTF {#1} + { + \tl_if_empty:nTF {#2} + { \__gtl_pop_left_auxi:n {#3} } + { \__gtl_pop_left_auxiv:nn {#2} {#3} } + } + { \__gtl_pop_left_auxv:nnn {#1} {#2} {#3} } + } +\cs_new:Npn \__gtl_pop_left_auxi:n #1 + { + \s__gtl + { } + \__gtl_pop_left_auxii:nnnw { } { } #1 \q_nil \q_stop + \s__stop + } +\cs_new:Npn \__gtl_pop_left_auxii:nnnw #1#2#3 + { + \quark_if_nil:nTF {#3} + { \__gtl_pop_left_auxiii:nnnw {#1} {#2} {#3} } + { \__gtl_pop_left_auxii:nnnw { #1 #2 } { {#3} } } + } +\cs_new:Npn \__gtl_pop_left_auxiii:nnnw #1#2#3#4 \q_stop + { + \tl_if_empty:nTF {#4} + { \exp_not:n { #2 {#1} } } + { \__gtl_pop_left_auxii:nnnw { #1 #2 } { {#3} } } + } +\cs_new:Npn \__gtl_pop_left_auxiv:nn #1#2 + { + \s__gtl + { \tl_if_head_is_group:nT {#1} { { \tl_head:n {#1} } } } + { \tl_if_head_is_space:nTF {#1} { \exp_not:f } { \tl_tail:n } {#1} } + { \exp_not:n {#2} } + \s__stop + } +\cs_new:Npn \__gtl_pop_left_auxv:nnn #1#2#3 + { + \s__gtl + { \if_false: { \fi: \__gtl_pop_left_auxvi:n #1 } } + { \exp_not:n {#2} } + { \exp_not:n {#3} } + \s__stop + } +\cs_new:Npn \__gtl_pop_left_auxvi:n #1 + { + \tl_if_empty:nF {#1} + { + \tl_if_head_is_group:nT {#1} { { \tl_head:n {#1} } } + { + \tl_if_head_is_space:nTF {#1} + { \exp_not:f } { \tl_tail:n } {#1} + } + } + \exp_after:wN \exp_not:n \exp_after:wN { \if_false: } \fi: + } +\cs_new_protected:Npn \gtl_pop_left:NN #1#2 + { + \gtl_get_left:NN #1 #2 + \gtl_pop_left:N #1 + } +\cs_new_protected:Npn \gtl_gpop_left:NN #1#2 + { + \gtl_get_left:NN #1 #2 + \gtl_gpop_left:N #1 + } +\cs_new:Npn \gtl_left_tl:N #1 + { \exp_after:wN \__gtl_left_tl:w #1 } +\cs_new:Npn \__gtl_left_tl:w \s__gtl #1#2#3 \s__stop + { \tl_if_empty:nTF {#1} { \exp_not:n {#2} } { \tl_head:n {#1} } } +\cs_new_protected:Npn \gtl_pop_left_tl:N #1 + { \tl_set:Nx #1 { \exp_after:wN \__gtl_pop_left_tl:w #1 } } +\cs_new_protected:Npn \gtl_gpop_left_tl:N #1 + { \tl_gset:Nx #1 { \exp_after:wN \__gtl_pop_left_tl:w #1 } } +\cs_new:Npn \__gtl_pop_left_tl:w \s__gtl #1#2#3 \s__stop + { + \s__gtl + \tl_if_empty:nTF {#1} + { { } { } } + { + { { } \tl_tail:n {#1} } + { \exp_not:n {#2} } + } + { \exp_not:n {#3} } + \s__stop + } +\cs_new:Npn \gtl_left_item:NF #1 + { \exp_after:wN \__gtl_left_item:wF #1 } +\cs_new:Npn \__gtl_left_item:wF \s__gtl #1#2#3 \s__stop + { \__gtl_left_item_auxi:nwF #1 {#2} \q_stop } +\cs_new:Npn \__gtl_left_item_auxi:nwF #1#2 \q_stop #3 + { \tl_if_blank:nTF {#1} {#3} { \tl_head:n {#1} } } +\prg_new_protected_conditional:Npnn \gtl_pop_left_item:NN #1#2 { TF , T , F } + { \exp_after:wN \__gtl_pop_left_item:wNNN #1#2 \tl_set:Nx #1 } +\prg_new_protected_conditional:Npnn \gtl_gpop_left_item:NN #1#2 { TF , T , F } + { \exp_after:wN \__gtl_pop_left_item:wNNN #1#2 \tl_gset:Nx #1 } +\cs_new_protected:Npn \__gtl_pop_left_item:wNNN + \s__gtl #1#2#3 \s__stop #4#5#6 + { + \tl_if_empty:nTF {#1} + { + \tl_if_blank:nTF {#2} { \prg_return_false: } + { + \tl_set:Nx #4 { \tl_head:n {#2} } + #5 #6 + { + \s__gtl { } { \tl_tail:n {#2} } + { \exp_not:n {#3} } \s__stop + } + \prg_return_true: + } + } + { + \__gtl_pop_left_item_aux:nwnnNNN #1 \q_nil \q_stop + {#2} {#3} #4 #5 #6 + } + } +\cs_new_protected:Npn \__gtl_pop_left_item_aux:nwnnNNN + #1#2 \q_stop #3#4#5#6#7 + { + \tl_if_blank:nTF {#1} { \prg_return_false: } + { + \tl_set:Nx #5 { \tl_head:n {#1} } + #6 #7 + { + \s__gtl + { { \tl_tail:n {#1} } \__gtl_strip_nil_mark:w #2 \q_mark } + { \exp_not:n {#3} } + { \exp_not:n {#4} } + \s__stop + } + \prg_return_true: + } + } +\cs_new:Npn \gtl_left_text:NF #1 + { \exp_after:wN \__gtl_left_text:wF #1 } +\cs_new:Npn \__gtl_left_text:wF \s__gtl #1#2#3 \s__stop + { + \tl_if_empty:nTF {#1} + { \__gtl_left_text_auxi:nwF {#2} \q_stop } + { \__gtl_left_text_auxi:nwF #1 \q_stop } + } +\cs_new:Npn \__gtl_left_text_auxi:nwF #1#2 \q_stop + { \__gtl_left_text_auxii:wnwF #1 \q_mark { } \q_mark \q_stop } +\cs_new:Npn \__gtl_left_text_auxii:wnwF #1 # + { \__gtl_left_text_auxiii:nnwF {#1} } +\cs_new:Npn \__gtl_left_text_auxiii:nnwF #1#2 #3 \q_mark #4 \q_stop #5 + { \tl_if_empty:nTF {#4} {#5} { \exp_not:n { #1 {#2} } } } +\cs_new_protected:Npn \gtl_pop_left_text:N #1 + { \tl_set:Nx #1 { \exp_after:wN \__gtl_pop_left_text:w #1 } } +\cs_new_protected:Npn \gtl_gpop_left_text:N #1 + { \tl_gset:Nx #1 { \exp_after:wN \__gtl_pop_left_text:w #1 } } +\cs_new:Npn \__gtl_pop_left_text:w \s__gtl #1#2#3 \s__stop + { + \s__gtl + \tl_if_empty:nTF {#1} + { + { } + { \__gtl_pop_left_text_auxi:n {#2} } + } + { + { \__gtl_pop_left_text_auxiv:nw #1 \q_nil \q_mark } + { \exp_not:n {#2} } + } + { \exp_not:n {#3} } + \s__stop + } +\cs_new:Npn \__gtl_pop_left_text_auxi:n #1 + { + \__gtl_pop_left_text_auxii:wnw #1 + \q_nil \q_mark { } \q_mark \q_stop + } +\cs_new:Npn \__gtl_pop_left_text_auxii:wnw #1 # + { \__gtl_pop_left_text_auxiii:nnw {#1} } +\cs_new:Npn \__gtl_pop_left_text_auxiii:nnw #1#2#3 \q_mark #4 \q_stop + { + \tl_if_empty:nTF {#4} + { \__gtl_strip_nil_mark:w #1 } + { \__gtl_strip_nil_mark:w #3 \q_mark } + } +\cs_new:Npn \__gtl_pop_left_text_auxiv:nw #1 + { + { \__gtl_pop_left_text_auxi:n {#1} } + \__gtl_strip_nil_mark:w + } +\cs_new:Npn \__gtl_tl_count:n #1 + { \int_eval:n { \c_zero \__gtl_tl_count_loop:n #1 \q_nil \q_stop } } +\cs_new:Npn \__gtl_tl_count_loop:n #1 + { + \quark_if_nil:nTF {#1} + { \__gtl_tl_count_test:w } + { + \c_one \__gtl_tl_count_loop:n } + } +\cs_new:Npn \__gtl_tl_count_test:w #1 \q_stop + { \tl_if_empty:nF {#1} { + \c_one \__gtl_tl_count_loop:n #1 \q_stop } } +\cs_new:Npn \gtl_extra_end:N #1 + { \exp_after:wN \__gtl_extra_end:w #1 } +\cs_new:Npn \__gtl_extra_end:w \s__gtl #1#2#3 \s__stop + { \__gtl_tl_count:n {#1} } +\cs_new:Npn \gtl_extra_begin:N #1 + { \exp_after:wN \__gtl_extra_begin:w #1 } +\cs_new:Npn \__gtl_extra_begin:w \s__gtl #1#2#3 \s__stop + { \__gtl_tl_count:n {#3} } +\cs_new:Npn \gtl_count_tokens:N #1 + { \exp_after:wN \__gtl_count_tokens:w #1 } +\cs_new:Npn \__gtl_count_tokens:w \s__gtl #1#2#3 \s__stop + { + \int_eval:n + { \c_minus_one \__gtl_count_auxi:nw #1 {#2} #3 \q_nil \q_stop } + } +\cs_new:Npn \__gtl_count_auxi:nw #1 + { + \quark_if_nil:nTF {#1} + { \__gtl_count_auxii:w } + { + + \c_one + \__gtl_count_auxiii:n {#1} + \__gtl_count_auxi:nw + } + } +\cs_new:Npn \__gtl_count_auxii:w #1 \q_stop + { + \tl_if_empty:nF {#1} + { + + \c_two + \__gtl_count_auxi:nw #1 \q_stop + } + } +\cs_new:Npn \__gtl_count_auxiii:n #1 + { + \tl_if_empty:nF {#1} + { + \tl_if_head_is_group:nTF {#1} + { + + \c_two + \exp_args:No \__gtl_count_auxiii:n { \use:n #1 } + } + { + + \c_one + \tl_if_head_is_N_type:nTF {#1} + { \exp_args:No \__gtl_count_auxiii:n { \use_none:n #1 } } + { \exp_args:Nf \__gtl_count_auxiii:n {#1} } + } + } + } +%% +%% +%% End of file `gtl.sty'. -- cgit v1.2.3