%% %% 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-2009 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/svnroot/experimental/trunk/ %% %% 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 1890 2010-04-11 03:37:15Z will $ {L3 Experimental keyval processing} \ProvidesExplPackage {\filename}{\filedate}{\fileversion}{\filedescription} \package_check_loaded_expl: \tl_new:N \l_KV_tmpa_tl \tl_new:N \l_KV_tmpb_tl \tl_const:Nn \c_KV_single_equal_sign_tl { = } \tl_new:N \l_KV_parse_tl \tl_new:N \l_KV_currkey_tl \tl_new:N \l_KV_currval_tl \int_new:N \l_KV_level_int \bool_new:N \l_KV_remove_one_level_of_braces_bool \bool_set_true:N \l_KV_remove_one_level_of_braces_bool \cs_new_protected_nopar:Npn \KV_process_space_removal_sanitize:NNn { \KV_process_aux:NNNn \KV_parse_space_removal_sanitize:n } \cs_new_protected_nopar:Npn \KV_process_space_removal_no_sanitize:NNn { \KV_process_aux:NNNn \KV_parse_space_removal_no_sanitize:n } \cs_new_protected_nopar:Npn \KV_process_no_space_removal_no_sanitize:NNn { \KV_process_aux:NNNn \KV_parse_no_space_removal_no_sanitize:n } \cs_new_protected:Npn \KV_process_aux:NNNn #1#2#3#4 { \cs_set_eq:cN { KV_key_no_value_elt_ \int_use:N \l_KV_level_int :n } \KV_key_no_value_elt:n \cs_set_eq:cN { KV_key_value_elt_ \int_use:N \l_KV_level_int :nn } \KV_key_value_elt:nn \cs_set_eq:NN \KV_key_no_value_elt:n #2 \cs_set_eq:NN \KV_key_value_elt:nn #3 \int_incr:N \l_KV_level_int #1 {#4} \int_decr:N \l_KV_level_int \cs_set_eq:Nc \KV_key_no_value_elt:n { KV_key_no_value_elt_ \int_use:N \l_KV_level_int :n } \cs_set_eq:Nc \KV_key_value_elt:nn { KV_key_value_elt_ \int_use:N \l_KV_level_int :nn } } \group_begin: \char_set_catcode:nn{`\=}{13} \char_set_catcode:nn{`\,}{13} \char_set_lccode:nn{`\8}{`\=} \char_set_lccode:nn{`\9}{`\,} \tl_to_lowercase:n{\group_end: \cs_new_protected_nopar:Npn \KV_sanitize_outerlevel_active_equals:N #1{ \tl_replace_all_in:Nnn #1 = 8 } \cs_new_nopar:Npn \KV_sanitize_outerlevel_active_commas:N #1{ \tl_replace_all_in:Nnn #1 , 9 } } \group_begin: \char_set_catcode:nn{`\Q}{3} \cs_new:Npn\KV_remove_surrounding_spaces:nw#1#2\q_nil{ #1{\KV_remove_surrounding_spaces_auxi:w \exp_not:N#2Q~Q} } \cs_new:Npn\KV_remove_surrounding_spaces_auxi:w#1~Q{ \KV_remove_surrounding_spaces_auxii:w #1 Q } \cs_new:Npn\KV_remove_surrounding_spaces_auxii:w#1Q#2{#1} \cs_new_protected:Npn\KV_add_value_element:w\q_stop#1\q_nil{ \tl_set:Nf\l_KV_currval_tl { \KV_remove_surrounding_spaces_auxi:w \exp_not:N#1Q~Q } \tl_put_right:No\l_KV_parse_tl{ \exp_after:wN { \l_KV_currval_tl } } } \cs_new_protected:Npn\KV_set_key_element:w#1\q_nil{ \tl_set:Nf\l_KV_currkey_tl { \exp_last_unbraced:NNo \KV_remove_surrounding_spaces_auxi:w \exp_not:N \use_none:n #1Q~Q } \bool_if:NT \l_KV_remove_one_level_of_braces_bool { \exp_args:NNo \tl_set:No \l_KV_currkey_tl { \exp_after:wN \KV_add_element_aux:w \l_KV_currkey_tl \q_nil } } } \group_end: \cs_new:Npn \KV_add_element_aux:w#1\q_nil{#1} \cs_new_protected:Npn \KV_parse_sanitize_aux:n #1 { \group_begin: \tl_clear:N \l_KV_parse_tl \tl_set:Nn \l_KV_tmpa_tl {#1} \KV_sanitize_outerlevel_active_equals:N \l_KV_tmpa_tl \KV_sanitize_outerlevel_active_commas:N \l_KV_tmpa_tl \exp_last_unbraced:NNV \KV_parse_elt:w \q_no_value \l_KV_tmpa_tl , \q_nil , \exp_after:wN \group_end: \l_KV_parse_tl } \cs_new_protected:Npn \KV_parse_no_sanitize_aux:n #1{ \group_begin: \tl_clear:N \l_KV_parse_tl \KV_parse_elt:w \q_no_value #1 , \q_nil , \exp_after:wN \group_end: \l_KV_parse_tl } \cs_set:Npn \KV_parse_elt:w #1,{ \tl_if_blank:oTF{\use_none:n #1} { \KV_parse_elt:w \q_no_value } { \quark_if_nil:oF {\use_ii:nn #1 } { \KV_split_key_value_current:w #1==\q_nil \KV_parse_elt:w \q_no_value } } } \cs_new:Npn \KV_split_key_value_current:w {\ERROR} \cs_new_protected:Npn \KV_split_key_value_space_removal:w #1 = #2\q_nil{ \KV_set_key_element:w#1\q_nil \tl_set:Nn\l_KV_tmpa_tl{#2} \tl_if_eq:NNTF\l_KV_tmpa_tl\c_KV_single_equal_sign_tl { \tl_put_right:No\l_KV_parse_tl{ \exp_after:wN \KV_key_no_value_elt:n \exp_after:wN {\l_KV_currkey_tl} } } { \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} { \msg_kernel_error:nn { keyval } { misplaced-equals-sign } } } } \cs_new_protected:Npn \KV_split_key_value_space_removal_detect_error:wTF#1=#2#3\q_nil{ \tl_if_head_eq_meaning:nNTF{#3}\q_no_value } \cs_new:Npn \KV_val_preserve_braces:NnN #1#2#3{{#2}} \cs_new_protected:Npn\KV_split_key_value_space_removal_aux:w #1=={ \tl_set:Nx\l_KV_tmpa_tl{\exp_not:o{\use_none:nnn#1\q_nil\q_nil}} \tl_put_right:No\l_KV_parse_tl{ \exp_after:wN \KV_key_value_elt:nn \exp_after:wN {\l_KV_currkey_tl} } \tl_if_empty:NTF\l_KV_tmpa_tl { \tl_put_right:Nn\l_KV_parse_tl{{}} } { \quark_if_nil:NTF\l_KV_tmpa_tl { \bool_if:NTF \l_KV_remove_one_level_of_braces_bool { \tl_put_right:No\l_KV_parse_tl{ \exp_after:wN{\use_ii:nnn #1\q_nil} } } { \tl_put_right:No\l_KV_parse_tl{ \exp_after:wN{\KV_val_preserve_braces:NnN #1\q_nil} } } } { \KV_add_value_element:w #1\q_nil } } } \cs_new_protected:Npn \KV_split_key_value_no_space_removal:w #1#2=#3=#4\q_nil{ \tl_set:Nn\l_KV_tmpa_tl{#4} \tl_if_empty:NTF \l_KV_tmpa_tl { \tl_put_right:Nn\l_KV_parse_tl{\KV_key_no_value_elt:n{#2}} } { \tl_if_eq:NNTF\c_KV_single_equal_sign_tl\l_KV_tmpa_tl { \tl_put_right:Nn\l_KV_parse_tl{\KV_key_value_elt:nn{#2}{#3}} } { \msg_kernel_error:nn { keyval } { misplaced-equals-sign } } } } \cs_new:Npn \KV_key_no_value_elt:n #1{\ERROR} \cs_new:Npn \KV_key_value_elt:nn #1#2{\ERROR} \cs_new_protected_nopar:Npn \KV_parse_no_space_removal_no_sanitize:n { \cs_set_eq:NN \KV_split_key_value_current:w \KV_split_key_value_no_space_removal:w \KV_parse_no_sanitize_aux:n } \cs_new_protected_nopar:Npn \KV_parse_space_removal_sanitize:n { \cs_set_eq:NN \KV_split_key_value_current:w \KV_split_key_value_space_removal:w \KV_parse_sanitize_aux:n } \cs_new_protected_nopar:Npn \KV_parse_space_removal_no_sanitize:n { \cs_set_eq:NN \KV_split_key_value_current:w \KV_split_key_value_space_removal:w \KV_parse_no_sanitize_aux:n } \msg_kernel_new:nnnn { keyval } { misplaced-equals-sign } {Misplaced~equals~sign~in~key--value~input~\msg_line_context:} { I~am~trying~to~read~some~key--value~input~but~found~two~equals~ signs\\% without~a~comma~between~them. } %% %% %% End of file `l3keyval.sty'.