%% %% This is file `xpeek.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% xpeek.dtx (with options: `package') %% ---------------------------------------------------------------- %% %% xpeek: Define commands that peek ahead in the input stream %% %% Copyright © 2012 by Joel C. Salomon. %% %% This work consists of the file xpeek.dtx, %% and the derived files xpeek.ins, %% xpeek.pdf, & %% xpeek.sty. %% 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 at ‹http://www.latex-project.org/lppl.txt›. %% %% This work is “maintained” (per LPPL maintenance status) by %% Joel C. Salomon ‹joelcsalomon@gmail.com›. %% %% ---------------------------------------------------------------- \RequirePackage{expl3, xparse} \ProvidesExplPackage {xpeek} {2012/08/15} {0.2} {Define commands that peek ahead in the input stream} \tl_new:N \g_xpeek_matchlist_tl \tl_new:N \g_xpeek_ignorelist_tl \tl_new:N \l__xpeek_code_tl \cs_new_protected:Npn \xpeek_after:nw #1 { \tl_set:Nn \l__xpeek_code_tl {#1} \peek_after:Nw \l__xpeek_code_tl } \tl_new:N \l__xpeek_collected_tokens_tl \cs_new_protected:Npn \xpeek_collect_do:nn #1#2 { \tl_clear:N \l__xpeek_collected_tokens_tl \__xpeek_collect_do:nnn {#1} {#2} {} } \cs_new_protected:Npn \__xpeek_collect_do:nnn #1#2#3 { \xpeek_after:nw { \xpeek_if_in:NNTF #1 \l_peek_token { \tl_put_right:Nn \l__xpeek_collected_tokens_tl {#3} \__xpeek_collect_do:nnn {#1} {#2} } { #2 { \l__xpeek_collected_tokens_tl #3 } } } } \bool_new:N \l__xpeek_bool \prg_new_protected_conditional:Npnn \xpeek_if_in:NN #1#2 { TF } { \bool_set_false:N \l__xpeek_bool \tl_map_inline:Nn #1 { \token_if_eq_charcode:NNT #2 ##1 { \bool_set_true:N \l__xpeek_bool \tl_map_break: } } \bool_if:NTF \l__xpeek_bool { \prg_return_true: } { \prg_return_false: } } %% %% %% End of file `xpeek.sty'.