%% %% This is file `l3keyval.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% l3keyval.dtx (with options: `package') %% %% %% EXPERIMENTAL CODE %% %% Do not distribute this file without also distributing the %% source files specified above. %% %% Do not distribute a modified version of this file. %% %% %% File: l3keyval.dtx Copyright (C) 2006 LaTeX3 project %% %% 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 %% %% This file is part of the ``expl3 bundle'' (The Work in LPPL) %% and all files in that bundle must be distributed together. %% %% The released version of this bundle is available from CTAN. %% %% ----------------------------------------------------------------------- %% %% The development version of the bundle can be found at %% %% http://www.latex-project.org/cgi-bin/cvsweb.cgi/ %% %% for those people who are interested. %% %%%%%%%%%%% %% NOTE: %% %%%%%%%%%%% %% %% Snapshots taken from the repository represent work in progress and may %% not work or may contain conflicting material! We therefore ask %% people _not_ to put them into distributions, archives, etc. without %% prior consultation with the LaTeX Project Team. %% %% ----------------------------------------------------------------------- \RequirePackage{l3names} \GetIdInfo$Id: l3keyval.dtx 573 2006-08-21 20:59:37Z morten $ {L3 Experimental keyval processing} \RequirePackage{l3quark} \RequirePackage{l3toks} \RequirePackage{l3int} \RequirePackage{l3token} \tlp_new:Nn\l_KV_tmpa_tlp{} \tlp_new:Nn\l_KV_tmpb_tlp{} \tlp_new:Nn \c_KV_single_equal_sign_tlp{=} \toks_new:N \l_KV_parse_toks \toks_new:N \l_KV_currkey_toks \toks_new:N \l_KV_currval_toks \bool_new:N \l_KV_remove_one_level_of_braces_bool \bool_set_true:N \l_KV_remove_one_level_of_braces_bool \group_begin: \char_set_catcode:nn{`\=}{13} \char_set_catcode:nn{`\,}{13} \char_set_lccode:nn{`\8}{`\=} \char_set_lccode:nn{`\9}{`\,} \tlist_to_lowercase:n{\group_end: \def_new:Npn \KV_sanitize_outerlevel_active_equals:N #1{ \tlp_replace_all_in:Nnn #1 = 8 } \def_new:Npn \KV_sanitize_outerlevel_active_commas:N #1{ \tlp_replace_all_in:Nnn #1 , 9 } } \group_begin: \char_set_catcode:nn{`\Q}{3} \gdef_long_new:Npn\KV_remove_surrounding_spaces:nw#1#2\q_nil{ #1{\KV_remove_surrounding_spaces_auxi:w \exp_not:N#2Q~Q} } \gdef_long_new:Npn\KV_remove_surrounding_spaces_auxi:w#1~Q{ \KV_remove_surrounding_spaces_auxii:w #1 Q } \gdef_long_new:Npn\KV_remove_surrounding_spaces_auxii:w#1Q#2{#1} \gdef_long_new:Npn\KV_add_value_element:w\q_stop#1\q_nil{ \toks_set:Nf\l_KV_currval_toks { \KV_remove_surrounding_spaces_auxi:w \exp_not:N#1Q~Q } \toks_put_right:No\l_KV_parse_toks{ \exp_after:NN {\toks_use:N \l_KV_currval_toks} } } \gdef_long_new:Npn\KV_set_key_element:w#1\q_nil{ \toks_set:Nf\l_KV_currkey_toks { \exp_after:NN\KV_remove_surrounding_spaces_auxi:w \exp_after:NN\exp_not:N\use_none:n #1Q~Q } \bool_if:NT \l_KV_remove_one_level_of_braces_bool { \toks_set:Nd \l_KV_currkey_toks{ \exp_after:NN \KV_add_element_aux:w \toks_use:N \l_KV_currkey_toks \q_nil } } } \group_end: \def_long_new:Npn \KV_add_element_aux:w#1\q_nil{#1} \def_long_new:Npn \KV_parse_sanitize_aux:n #1{ \group_begin: \toks_clear:N \l_KV_parse_toks \tlp_set:Nx\l_KV_tmpa_tlp{\exp_not:n{#1}} \KV_sanitize_outerlevel_active_equals:N\l_KV_tmpa_tlp \KV_sanitize_outerlevel_active_commas:N\l_KV_tmpa_tlp \exp_after:NN \KV_parse_elt:w \exp_after:NN\q_no_value \l_KV_tmpa_tlp,\q_nil, \exp_after:NN\group_end: \toks_use:N \l_KV_parse_toks } \def_long_new:Npn \KV_parse_no_sanitize_aux:n #1{ \group_begin: \toks_clear:N \l_KV_parse_toks \KV_parse_elt:w \q_no_value #1,\q_nil, \exp_after:NN\group_end: \toks_use:N \l_KV_parse_toks } \def_long:Npn \KV_parse_elt:w #1,{ \tlist_if_blank:oTF{\use_none:n #1} { \KV_parse_elt:w \q_no_value } { \quark_if_nil:oF {\use_arg_ii:nn #1 } { \KV_split_key_value_current:w #1==\q_nil \KV_parse_elt:w \q_no_value } } } \let_new:NN \KV_split_key_value_current:w \ERROR \def_long_new:Npn \KV_split_key_value_space_removal:w #1 = #2\q_nil{ \KV_set_key_element:w#1\q_nil \tlp_set:Nx\l_KV_tmpa_tlp{\exp_not:n{#2}} \tlp_if_eq:NNTF\l_KV_tmpa_tlp\c_KV_single_equal_sign_tlp { \toks_put_right:No\l_KV_parse_toks{ \exp_after:NN \KV_key_no_value_elt:n \exp_after:NN {\toks_use:N\l_KV_currkey_toks} } } { \KV_split_key_value_space_removal_detect_error:wTF#2\q_no_value\q_nil {\KV_split_key_value_space_removal_aux:w \q_stop #2} {\ERROR} } } \def_long_new:Npn \KV_split_key_value_space_removal_detect_error:wTF#1=#2#3\q_nil{ \tlist_if_head_eq_meaning:nNTF{#3}\q_no_value } \def_long_new:Npn \KV_val_preserve_braces:NnN #1#2#3{{#2}} \def_long_new:Npn\KV_split_key_value_space_removal_aux:w #1=={ \tlp_set:Nx\l_KV_tmpa_tlp{\exp_not:o{\use_none:nnn#1\q_nil\q_nil}} \toks_put_right:No\l_KV_parse_toks{ \exp_after:NN \KV_key_value_elt:nn \exp_after:NN {\toks_use:N\l_KV_currkey_toks} } \tlp_if_empty:NTF\l_KV_tmpa_tlp { \toks_put_right:Nn\l_KV_parse_toks{{}} } { \quark_if_nil:NTF\l_KV_tmpa_tlp { \bool_if:NTF \l_KV_remove_one_level_of_braces_bool { \toks_put_right:No\l_KV_parse_toks{ \exp_after:NN{\use_arg_ii:nnn #1\q_nil} } } { \toks_put_right:No\l_KV_parse_toks{ \exp_after:NN{\KV_val_preserve_braces:NnN #1\q_nil} } } } { \KV_add_value_element:w #1\q_nil } } } \def_long_new:Npn \KV_split_key_value_no_space_removal:w #1#2=#3=#4\q_nil{ \tlp_set:Nn\l_KV_tmpa_tlp{#4} \tlp_if_empty:NTF \l_KV_tmpa_tlp { \toks_put_right:Nn\l_KV_parse_toks{\KV_key_no_value_elt:n{#2}} } { \tlp_if_eq:NNTF\c_KV_single_equal_sign_tlp\l_KV_tmpa_tlp { \toks_put_right:Nn\l_KV_parse_toks{\KV_key_value_elt:nn{#2}{#3}} } {\ERROR} } } \def_long_new:Npn \KV_key_no_value_elt:n #1{\ERROR} \def_long_new:Npn \KV_key_value_elt:nn #1#2{\ERROR} \def_new:Npn \KV_parse_no_space_removal_no_sanitize:n { \let:NN \KV_split_key_value_current:w \KV_split_key_value_no_space_removal:w \KV_parse_no_sanitize_aux:n } \def_new:Npn \KV_parse_space_removal_sanitize:n { \let:NN \KV_split_key_value_current:w \KV_split_key_value_space_removal:w \KV_parse_sanitize_aux:n } \def_new:Npn \KV_parse_space_removal_no_sanitize:n { \let:NN \KV_split_key_value_current:w \KV_split_key_value_space_removal:w \KV_parse_no_sanitize_aux:n } %% %% %% End of file `l3keyval.sty'.