summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-06-06 20:50:49 +0000
committerKarl Berry <karl@freefriends.org>2018-06-06 20:50:49 +0000
commite0b44a591ea65a8c11f15d8e4c0cfb50a6058782 (patch)
treeb600ee10570f565158fed6ca0495e80d40bc13ec /Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
parent8bcdad0a3fc9ea77205f11c711a7cfe2f95d1940 (diff)
cooking-units (6jun18)
git-svn-id: svn://tug.org/texlive/trunk@47943 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty')
-rw-r--r--Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty546
1 files changed, 296 insertions, 250 deletions
diff --git a/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty b/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
index 7e53a0129f6..e22bc6dd37d 100644
--- a/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
+++ b/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty
@@ -30,10 +30,10 @@
{ \RequirePackage {expl3} }
\ProvidesExplPackage
{cooking-units}
- {2018/04/20}
- {1.30}
+ {2018/06/05}
+ {1.40}
{Ein Paket fuer Kocheinheiten}
-\@ifpackagelater { expl3 } { 2018/02/21 }
+\@ifpackagelater { expl3 } { 2018/06/01 }
{ }
{
\PackageError { cooking-units } { Support~package~expl3~too~old }
@@ -73,8 +73,8 @@
use-numerals .code:n = { \msg_error:nnn { cooking-units } { load-time-option } { fmtcount } } ,
}
\cs_generate_variant:Nn \tl_replace_all:Nnn { NVn }
-\cs_generate_variant:Nn \tl_replace_once:Nnn { NnV, NVn }
-\cs_generate_variant:Nn \tl_if_in:nnTF { nV , xn }
+\cs_generate_variant:Nn \tl_replace_once:Nnn { NVn }
+\cs_generate_variant:Nn \tl_if_in:nnTF { nV }
\cs_generate_variant:Nn \tl_if_in:NnTF { NVTF }
\cs_generate_variant:Nn \tl_if_in:NnT { NVT }
\cs_generate_variant:Nn \fp_compare:nNnT { vNnT }
@@ -82,6 +82,7 @@
\cs_generate_variant:Nn \tl_set_rescan:Nnn { NnV }
\cs_generate_variant:Nn \msg_error:nnnn { nnnV }
\cs_generate_variant:Nn \msg_error:nnn { nnV }
+\cs_generate_variant:Nn \msg_warning:nnn { nnV }
\cs_new:Npn \__cooking_units_dim_horizontal:N #1 { \tex_kern:D #1 }
\cs_new_eq:NN \__cooking_units_frac:nn \sfrac
\cs_new_eq:NN \__cooking_units_set_amount:Nn \tl_set:Nn
@@ -174,8 +175,8 @@
\int_new:N \l__cooking_units_phrase_number_tl
\seq_new:N \l__cooking_units_list_of_defined_keys_seq
\seq_new:N \g__cooking_units_list_of_defined_units_seq
-\clist_new:N \g__cooking_units_allowed_special_keys_clist
-\clist_new:N \l__cooking_units_phrase_numbers_clist
+\seq_new:N \g__cooking_units_allowed_special_keys_seq
+\seq_new:N \l__cooking_units_phrase_numbers_seq
\seq_new:N \l__cooking_units_temperatures_to_check_seq
\seq_new:N \l__cooking_units_curef_do_not_change_seq
\prop_new:N \l__cooking_units_phrase_prop
@@ -198,7 +199,7 @@
\bool_new:N \l__cooking_units_lokal_persons_bool
\bool_new:N \l__cooking_units_cutext_to_cunum_bool
\bool_new:N \l__cooking_units_cutext_old_bool
-\bool_new:N \l__cooking_units_cutext_change_unit_bool
+\bool_new:N \l__cooking_units_cutext_keep_unit_bool
\bool_new:N \l__cooking_units_round_commercial_bool
\bool_new:N \l__cooking_units_use_phrases_bool
\bool_new:N \l__cooking_units_lokal_phrase_bool
@@ -206,18 +207,19 @@
\bool_new:N \l__cooking_units_lokal_numeral_bool
\bool_new:N \l__cooking_units_round_precision_positive_bool
\bool_new:N \l__cooking_units_fourty_two_bool
+\bool_new:N \l__cooking_units_phrase_negative_bool
\bool_new:N \l__cooking_units_range_in_input_bool
\bool_new:N \l__cooking_units_lokal_fraction_bool
\bool_new:N \l__cooking_units_print_fraction_bool
\bool_new:N \l__cooking_units_lokal_mixed_fraction_bool
-\bool_new:N \l__cooking_units_decimal_in_input_bool
-\bool_set_true:N \l__cooking_units_cutext_change_unit_bool
+\bool_new:N \l__cooking_units_check_decimal_bool
+\bool_set_false:N \l__cooking_units_cutext_keep_unit_bool
\bool_set_eq:NN \l__cooking_units_print_numeral_bool \g__cooking_units_opt_numeral_bool
\quark_new:N \q__cooking_units_range
\quark_new:N \q__cooking_units_no_translation
\quark_new:N \q__cooking_units_decimal
-\quark_new:N \q__cooking_units_frac
-\quark_new:N \q__cooking_units_mixed_frac
+\quark_new:N \q__cooking_units_fraction
+\quark_new:N \q__cooking_units_mixed_fraction
\fp_new:N \l__cooking_units_tmpa_fp
\clist_new:N \l__cooking_units_tmpa_clist
\prop_new:N \l__cooking_units_tmpa_prop
@@ -268,8 +270,9 @@
cutext-to-cunum .bool_set:N = \l__cooking_units_cutext_to_cunum_bool ,
cutext-to-cunum .default:n = { false } ,
cutext-to-cunum .groups:n = { change-command } ,
- cutext-change-unit .bool_set:N = \l__cooking_units_cutext_change_unit_bool ,
+ cutext-change-unit .bool_set_inverse:N = \l__cooking_units_cutext_keep_unit_bool ,
cutext-change-unit .default:n = { true } ,
+ cutext-change-unit .groups:n = { change-unit } ,
cuam-version .choices:nn =
{ new , old }
{
@@ -340,7 +343,7 @@
\msg_redirect_name:nnn { cooking-units } { amount-not-known }
{ \l_keys_choice_tl }
} ,
- set-unknown-message .default:n = { set-cutext-translation-message } ,
+ set-unknown-message .default:n = { warning } ,
set-cutext-translation-message .choices:nn =
{ error , warning , none }
{
@@ -404,20 +407,11 @@
recalculate-amount .default:n = { false } ,
set-number-of-persons .int_set:N = \l__cooking_units_wanted_number_of_persons_int ,
set-number-of-persons .default:n = { 4 } ,
- label .code:n =
- {
- \__cooking_units_label_and_persons:n {#1}
- } ,
+ label .code:n = \__cooking_units_label_and_persons:n {#1} ,
label .value_required:n = { true } ,
- get-label .code:n =
- {
- \__cooking_units_curef:n {#1}
- } ,
+ get-label .code:n = \__cooking_units_curef:n {#1} ,
label .value_required:n = { true } ,
- ref .code:n =
- {
- \__cooking_units_reference_label_and_persons:n {#1}
- } ,
+ ref .code:n = \__cooking_units_reference_label_and_persons:n {#1} ,
ref .value_required:n = { true } ,
check-temperature .bool_set:N = \l__cooking_units_check_temperature_bool ,
check-temperature .default:n = { true } ,
@@ -427,7 +421,7 @@
\__cooking_units_temperature_to_check_print_error:n
\__cooking_units_temperatures_to_check_define:nn
{#1}
- },
+ } ,
temperature-to-check .value_required:n = { true } ,
convert-to-eV .bool_set:N = \l__cooking_units_convert_to_eV_bool ,
convert-to-eV .default:n = { true } ,
@@ -457,6 +451,11 @@
cutext-add-hook .code:n = { \tl_put_right:Nn \l__cooking_units_cutext_hook_tl {#1} } ,
Cutext-add-hook .code:n = { \tl_put_right:Nn \l__cooking_units_Cutext_hook_tl {#1} } ,
cuam-add-hook .code:n = { \tl_put_right:Nn \l__cooking_units_cuam_hook_tl {#1} } ,
+ curef-do-not-change .code:n =
+ {
+ \seq_if_in:NnF \l__cooking_units_curef_do_not_change_seq {#1}
+ {\seq_put_right:Nn \l__cooking_units_curef_do_not_change_seq {#1} }
+ } ,
}
\msg_new:nnnn { cooking-units } { fraction-not-allowed-with-range }
{
@@ -584,7 +583,7 @@
}
\msg_new:nnnn { cooking-units } { amount-not-known }
{
- The \ amount \ of \ #1 \ is \ not \ known \ at \ line \
+ The \ amount \ '#1' \ is \ not \ known \ at \ line \
\msg_line_number: .
}
{
@@ -670,7 +669,7 @@
}
\msg_new:nnnn { cooking-units } { label-not-defined }
{
- The \ label \ is \ not \ defined. \ Please \ note \ that \ a \ label
+ The \ label \ '#1' \ is \ not \ defined. \ Please \ note \ that \ a \ label
\ has \ to \ defined \ before \ it \ is \ referenced.
}{
Define \ the \ label \ before \ using \ it.
@@ -798,26 +797,26 @@
}
\cs_new:Npn \__cooking_units_define_unit_group:nn #1#2
{
- \clist_new:c { l__cooking_units_group_ #1 _clist }
- \clist_set:cn { l__cooking_units_group_ #1 _clist } {#2}
+ \seq_new:c { l__cooking_units_group_ #1 _seq }
+ \seq_set_from_clist:cn { l__cooking_units_group_ #1 _seq } {#2}
\keys_define:nn { cooking-units }
{
#1 .code:n = { \__cooking_units_unit_group_convert_units:nn {#1} {##1} } ,
- #1 .groups:n = { change-unit }
+ #1 .groups:n = { change-unit } ,
}
}
\cs_new:Npn \__cooking_units_error_if_group_not_defined:n #1
{
- \clist_if_exist:cF { l__cooking_units_group_ #1 _clist }
+ \seq_if_exist:cF { l__cooking_units_group_ #1 _seq }
{ \msg_error:nn { cooking-units} { group-key-unknown } }
}
\cs_new:Npn \__cooking_units_unit_group_convert_units:nn #1#2
{
\__cooking_units_error_if_group_not_defined:n {#1}
\__cooking_units_error_if_unit_not_defined:n {#2}
- \clist_if_in:cnTF { l__cooking_units_group_ #1 _clist } {#2}
+ \seq_if_in:cnTF { l__cooking_units_group_ #1 _seq } {#2}
{
- \clist_map_inline:cn { l__cooking_units_group_ #1 _clist }
+ \seq_map_inline:cn { l__cooking_units_group_ #1 _seq }
{ \__cooking_units_keys_set:nnn { cooking-units } {##1} {#2} }
}{
\msg_error:nnxxx
@@ -825,7 +824,7 @@
{ group-choice-not-allowed }
{#1}
{#2}
- { \clist_use:cnnn { l__cooking_units_group_ #1 _clist } { ',~ ' } { ',~ ' } { ' ~ and ~ ' } }
+ { \seq_use:cnnn { l__cooking_units_group_ #1 _seq } { ',~ ' } { ',~ ' } { ' ~ and ~ ' } }
}
}
\__cooking_units_define_unit_group:nn { weight } { kg , dag, g, oz, lb, stick }
@@ -844,13 +843,13 @@
\clist_map_inline:nn {#2}
{
\__cooking_units_error_if_unit_not_defined:n {##1}
- \clist_if_in:cnF { l__cooking_units_group_ #1 _clist } {##1}
- { \clist_put_right:cn { l__cooking_units_group_ #1 _clist } {##1} }
+ \seq_if_in:cnF { l__cooking_units_group_ #1 _seq } {##1}
+ { \seq_put_right:cn { l__cooking_units_group_ #1 _seq } {##1} }
}
}
\seq_new:N \g__cooking_units_natural_units_seq
\prop_new:N \g__cooking_units_convert_to_eV_remember_prop
-\seq_set_split:Nnn \g__cooking_units_natural_units_seq { , }
+\seq_set_from_clist:Nn \g__cooking_units_natural_units_seq
{
eV ,
eVc-2 ,
@@ -1060,7 +1059,7 @@
{
\SaveTranslationFor {#2} {#1} { #3 #4 }
}
-\cs_generate_variant:Nn \__cooking_units_translate:nn { xx }
+\cs_generate_variant:Nn \__cooking_units_translate:nn { xx , VV }
\cs_generate_variant:Nn \__cooking_units_translate_let:Nnn { Nxx }
\cs_generate_variant:Nn \__cooking_units_translate_let:nNnn { VNxx, nNxx }
\prg_new_conditional:Npnn \__cooking_units_unitname_get:Nn #1#2 { F }
@@ -1071,7 +1070,7 @@
{ \prg_return_true: }
}
\cs_generate_variant:Nn \__cooking_units_unitname_get:NnF { Nx }
-\cs_new:Npn \__cooking_units_translate_one_to_and_check_existance:Nx #1#2
+\cs_new:Npn \__cooking_units_translate_one_and_check_existance:Nn #1#2
{
\__cooking_units_translate_let:Nxx #1 {#2} \c__cooking_units_postfix_gender_tl
\__cooking_units_unitname_get:NxF #1 { one (#1) }
@@ -1080,7 +1079,8 @@
\msg_error:nnn { cooking-units } { Translation-not-available } { one (#1) }
}
}
-\clist_gset:Nn \g__cooking_units_allowed_special_keys_clist
+\cs_generate_variant:Nn \__cooking_units_translate_one_and_check_existance:Nn { Nx }
+\seq_gset_from_clist:Nn \g__cooking_units_allowed_special_keys_seq
{
decimal-mark ,
one (m) ,
@@ -1102,6 +1102,10 @@
\__cooking_units_newtranslation_to:nnVn { German } { one (m) } \c__cooking_units_postfix_unitname_tl { ein }
\__cooking_units_newtranslation_to:nnVn { German } { one (f) } \c__cooking_units_postfix_unitname_tl { eine }
\__cooking_units_newtranslation_to:nnVn { German } { one (n) } \c__cooking_units_postfix_unitname_tl { ein }
+\__cooking_units_newtranslation_base:nVn { range-sign } \c__cooking_units_postfix_unitname_tl { -- }
+\__cooking_units_newtranslation_base:nVn { range-sign } \c__cooking_units_postfix_unitname_pl_tl { \q__cooking_units_no_translation }
+\__cooking_units_newtranslation_to:nnVn { German } { range-sign } \c__cooking_units_postfix_unitname_tl { ~bis~ }
+\__cooking_units_newtranslation_to:nnVn { English } { range-sign } \c__cooking_units_postfix_unitname_tl { ~to~ }
\cs_new_protected:Npn \__cooking_units_initialise_default:n #1
{
\__cooking_units_set_unit:Nn \l__cooking_units_given_unit_tl {#1}
@@ -1115,14 +1119,11 @@
\cs_new_protected:Npn \__cooking_units_initialise_unit_change:n #1
{
\tl_if_empty:nF {#1}
- {
- \keys_set_groups:nnn { cooking-units } { change-unit } {#1}
- }
- \bool_if:NT \l__cooking_units_convert_to_eV_bool { \__cooking_units_convert_to_eV: }
+ { \keys_set_groups:nnn { cooking-units } { change-unit } {#1} }
+ \bool_if:NT \l__cooking_units_convert_to_eV_bool
+ { \__cooking_units_convert_to_eV: }
\prop_get:NVNF \l__cooking_units_change_unit_prop \l__cooking_units_given_unit_tl \l__cooking_units_option_unit_tl
- {
- \tl_set_eq:NN \l__cooking_units_option_unit_tl \l__cooking_units_given_unit_tl
- }
+ { \tl_set_eq:NN \l__cooking_units_option_unit_tl \l__cooking_units_given_unit_tl }
}
\cs_new_protected:Npn \__cooking_units_initialise_after_unit_change:nn #1#2
{
@@ -1193,12 +1194,39 @@
}
\__cooking_units_frac:nn {#2} {#3}
}
+\cs_new:Npn \__cooking_units_print_ranges:NN #1#2
+ {
+ \__cooking_units_print_input:N #1
+ \bool_if:NTF \l__cooking_units_using_cutext_bool
+ {
+ \tl_use:N \l__cooking_units_cutext_range_sign_tl
+ \bool_set_false:N \l__cooking_units_cutext_uppercase_word_bool
+ }
+ { \tl_use:N \l__cooking_units_cunum_range_sign_tl }
+ \__cooking_units_print_input:N #2
+ }
+\cs_new:Npn \__cooking_units_create_error:n #1
+ {
+ \bool_set_true:N \l__cooking_units_error_bool
+ \msg_error:nnV { cooking-units } {#1} \l__cooking_units_given_amount_tl
+ }
+\cs_new:Npn \__cooking_units_create_error_and_stop:n #1
+ {
+ \bool_set_true:N \l__cooking_units_error_bool
+ \msg_error:nnV { cooking-units } {#1} \l__cooking_units_given_amount_tl
+ \use_none_delimit_by_q_nil:w
+ }
+\cs_new:Npn \__cooking_units_create_error:nn #1#2
+ {
+ \bool_set_true:N \l__cooking_units_error_bool
+ \msg_error:nnnV { cooking-units } {#1} {#2} \l__cooking_units_given_amount_tl
+ }
\cs_new:Npn \__cooking_units_parse_input:n #1
{
\bool_if:NTF \l__cooking_units_fourty_two_bool
{ \tl_clear:N \l__cooking_units_given_amount_tl }
{ \__cooking_units_set_amount:Nn \l__cooking_units_given_amount_tl {#1} }
- \tl_set_rescan:NnV \l__cooking_units_tmpa_tl
+ \tl_set_rescan:NnV \l__cooking_units_given_amount_tl
{
\char_set_catcode_letter:N \_ %
\char_set_catcode_ignore:N \ %
@@ -1206,55 +1234,116 @@
} \l__cooking_units_given_amount_tl
\bool_lazy_or:nnTF
{ \l__cooking_units_draft_bool }
- { \tl_if_empty_p:N \l__cooking_units_tmpa_tl }
+ { \tl_if_empty_p:N \l__cooking_units_given_amount_tl }
{
\bool_if:NTF \l__cooking_units_fourty_two_bool
{ 42 }
- { \l__cooking_units_tmpa_tl }
+ { \l__cooking_units_given_amount_tl }
}{
- \tl_if_in:NVT \l__cooking_units_tmpa_tl \l__cooking_units_input_range_sign_tl
- {
- \tl_replace_once:NVn \l__cooking_units_tmpa_tl \l__cooking_units_input_range_sign_tl { \q__cooking_units_range }
- \bool_set_true:N \l__cooking_units_range_in_input_bool
- }
- \__cooking_units_parsing_amount_input:V \l__cooking_units_tmpa_tl
- \__cooking_units_split_input:
+ \tl_set_eq:NN \l__cooking_units_tmpa_tl \l__cooking_units_given_amount_tl
+ \__cooking_units_split_input:N \l__cooking_units_tmpa_tl
+ \__cooking_units_process_and_print_input:
}
}
-\cs_new:Npn \__cooking_units_parsing_amount_input:n #1
+\cs_new:Npn \__cooking_units_split_input:N #1
{
- \cs_set_eq:NN \__cooking_units_parse:N \__cooking_units_start_loop:N
- \tl_map_function:nN {#1} \__cooking_units_parse:N
+ \tl_if_in:NVT #1 \l__cooking_units_input_range_sign_tl
+ {
+ \tl_replace_once:NVn #1 \l__cooking_units_input_range_sign_tl { \q__cooking_units_range }
+ \bool_set_true:N \l__cooking_units_range_in_input_bool
+ }
+ \tl_if_in:NnT #1 { / }
+ {
+ \bool_set_true:N \l__cooking_units_lokal_fraction_bool
+ \bool_if:NT \l__cooking_units_range_in_input_bool
+ { \__cooking_units_create_error_and_stop:n { fraction-not-allowed-with-range } }
+ }
+ \tl_if_in:NnT #1 { _ }
+ {
+ \bool_set_true:N \l__cooking_units_lokal_mixed_fraction_bool
+ \bool_if:NF \l__cooking_units_lokal_fraction_bool
+ { \__cooking_units_create_error_and_stop:n { missing-slash } }
+ }
+ \__cooking_units_split:N #1
+ \use_none_delimit_by_q_nil:w \q_nil
+ }
+\cs_new:Npn \__cooking_units_process_tmp: { }
+\cs_new:Npn \__cooking_units_process_and_print_input:
+ {
+ \bool_if:NTF \l__cooking_units_error_bool
+ { \l__cooking_units_given_amount_tl }
+ { \__cooking_units_process_tmp: }
}
-\cs_generate_variant:Nn \__cooking_units_parsing_amount_input:n { V }
-\cs_new:Npn \__cooking_units_split_input:
+\cs_new:Npn \__cooking_units_split:N #1
{
\bool_if:NTF \l__cooking_units_lokal_fraction_bool
+ { \__cooking_units_split_fraction:V }
{
- \tl_set_eq:NN \l__cooking_units_number_tmpb_tl \l__cooking_units_tmpa_tl
- \bool_lazy_or:nnT
- { \l__cooking_units_lokal_persons_bool }{ \l__cooking_units_eval_fractions_bool }
- { \bool_set_false:N \l__cooking_units_lokal_fraction_bool }
- \bool_if:NTF \l__cooking_units_lokal_mixed_fraction_bool
- { \__cooking_units_parse_mixed_fraction_in_input: }
- { \__cooking_units_parse_fraction_in_input: }
- }{
- \bool_if:NT \l__cooking_units_lokal_mixed_fraction_bool
- { \msg_error:nnV { cooking-units } { missing-slash } \l__cooking_units_given_amount_tl }
\bool_if:NTF \l__cooking_units_range_in_input_bool
- {
- \tl_set_eq:NN \l__cooking_units_number_tmpb_tl \l__cooking_units_tmpa_tl
- \__cooking_units_parse_range_in_input:
- }{
- \tl_set_eq:NN \l__cooking_units_number_tmpa_tl \l__cooking_units_tmpa_tl
- \__cooking_units_parse_number_in_input:
- }
+ { \__cooking_units_split_range:V }
+ { \__cooking_units_split_number:V }
}
+ #1
}
-\cs_new:Npn \__cooking_units_start_loop:N #1
+\cs_new:Npn \__cooking_units_split_number:n #1
+ {
+ \cs_set_eq:NN \__cooking_units_process_tmp: \__cooking_units_process_number_in_input:
+ \__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_number_tmpa_tl
+ }
+\cs_new:Npn \__cooking_units_split_range:n #1
+ {
+ \cs_set_eq:NN \__cooking_units_process_tmp: \__cooking_units_process_range_in_input:
+ \__cooking_units_split_range_aux:ww #1 \q_stop
+ }
+\cs_new:Npn \__cooking_units_split_range_aux:ww #1 \q__cooking_units_range #2 \q_stop
+ {
+ \__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_number_tmpa_tl
+ \__cooking_units_parse_input_and_safe_in:nN {#2} \l__cooking_units_number_tmpb_tl
+ }
+\cs_new:Npn \__cooking_units_split_fraction:n #1
+ {
+ \bool_if:NTF \l__cooking_units_lokal_mixed_fraction_bool
+ {
+ \cs_set_eq:NN \__cooking_units_process_tmp: \__cooking_units_process_mixed_fraction_in_input:
+ \__cooking_units_split_fraction_mixed:ww
+ }{
+ \cs_set_eq:NN \__cooking_units_process_tmp: \__cooking_units_process_fraction_in_input:
+ \__cooking_units_split_fraction_frac:ww
+ }
+ #1 \q_stop / \q_recursion_tail \q_stop
+ \q_recursion_stop
+ \bool_lazy_or:nnT
+ { \l__cooking_units_lokal_persons_bool }{ \l__cooking_units_eval_fractions_bool }
+ { \bool_set_false:N \l__cooking_units_lokal_fraction_bool }
+ }
+\cs_new:Npn \__cooking_units_split_fraction_frac:ww #1 / #2 \q_stop
+ {
+ \quark_if_recursion_tail_stop_do:nn {#2}
+ { \__cooking_units_create_error:n { fraction-wrong-order } }
+ \__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_number_tmpa_tl
+ \__cooking_units_parse_input_and_safe_in:nN {#2} \l__cooking_units_number_tmpb_tl
+ \use_none_delimit_by_q_recursion_stop:w
+ }
+\cs_new:Npn \__cooking_units_split_fraction_mixed:ww #1 _ #2 \q_stop
+ {
+ \__cooking_units_parse_input_and_safe_in:nN {#1} \l__cooking_units_mixed_fraction_tl
+ \__cooking_units_split_fraction_frac:ww #2 \q_stop
+ }
+\cs_generate_variant:Nn \__cooking_units_split_number:n { V }
+\cs_generate_variant:Nn \__cooking_units_split_range:n { V }
+\cs_generate_variant:Nn \__cooking_units_split_fraction:n { V }
+\cs_new:Npn \__cooking_units_parse_input_and_safe_in:nN #1 #2
{
\tl_clear:N \l__cooking_units_tmpa_tl
- \bool_set_false:N \l__cooking_units_decimal_in_input_bool
+ \bool_set_false:N \l__cooking_units_check_decimal_bool
+ \cs_set_eq:NN \__cooking_units_parse:N \__cooking_units_start_loop:N
+ \tl_map_function:nN {#1} \__cooking_units_parse:N
+ \bool_if:NTF \l__cooking_units_error_bool
+ { \use_none_delimit_by_q_nil:w }
+ { \tl_set_eq:NN #2 \l__cooking_units_tmpa_tl }
+ }
+\cs_new:Npn \__cooking_units_start_loop:N #1
+ {
\cs_set_eq:NN \__cooking_units_parse:N \__cooking_units_parse_input_loop_aux:N
\tl_if_in:NnTF \l__cooking_units_input_value_signs_tl {#1}
{ \tl_put_right:Nn \l__cooking_units_tmpa_tl {#1} }
@@ -1269,9 +1358,7 @@
{
\tl_if_in:NnTF \l__cooking_units_input_decimal_mark_tl {#1}
{
- \__cooking_units_check_repitition:NN
- \q__cooking_units_decimal
- \l__cooking_units_decimal_in_input_bool
+ \__cooking_units_check_repitition:N \l__cooking_units_check_decimal_bool
\tl_put_right:Nn \l__cooking_units_tmpa_tl { . }
}{
\tl_if_in:NnTF \l__cooking_units_input_allowed_special_signs_tl {#1}
@@ -1279,71 +1366,29 @@
\bool_set_true:N \l__cooking_units_special_sign_bool
\tl_put_right:Nn \l__cooking_units_tmpa_tl {#1}
}{
- \bool_if:NTF \l__cooking_units_range_in_input_bool
- {
- \tl_if_eq:nnTF \q__cooking_units_range {#1}
- {
- \tl_set_eq:NN \l__cooking_units_number_tmpa_tl \l__cooking_units_tmpa_tl
- \cs_set_eq:NN \__cooking_units_parse:N \__cooking_units_start_loop:N
- }{
- \tl_if_in:xnTF
- {
- \exp_not:V \l__cooking_units_input_fraction_sign_tl
- \exp_not:V \l__cooking_units_input_mixed_fraction_sign_tl
- } {#1}
- { \msg_error:nnV { cooking-units } { fraction-not-allowed-with-range } \l__cooking_units_given_amount_tl }
- { \msg_error:nnnV { cooking-units } { Token-not-allowed } {#1} \l__cooking_units_given_amount_tl }
- \bool_set_true:N \l__cooking_units_error_bool
- \tl_map_break:
- }
- }{
- \tl_if_in:NnTF \l__cooking_units_input_fraction_sign_tl {#1}
- {
- \__cooking_units_check_repitition:NN
- \q__cooking_units_frac
- \l__cooking_units_lokal_fraction_bool
- \tl_set_eq:NN \l__cooking_units_number_tmpa_tl \l__cooking_units_tmpa_tl
- \cs_set_eq:NN \__cooking_units_parse:N \__cooking_units_start_loop:N
- }{
- \tl_if_in:NnTF \l__cooking_units_input_mixed_fraction_sign_tl {#1}
- {
- \__cooking_units_check_repitition:NN
- \q__cooking_units_mixed_frac
- \l__cooking_units_lokal_mixed_fraction_bool
- \bool_if:NT \l__cooking_units_lokal_fraction_bool
- { \msg_error:nnV { cooking-units } { fraction-wrong-order } \l__cooking_units_given_amount_tl }
- \tl_set_eq:NN \l__cooking_units_mixed_fraction_tl \l__cooking_units_tmpa_tl
- \cs_set_eq:NN \__cooking_units_parse:N \__cooking_units_start_loop:N
- }{
- \msg_error:nnnV { cooking-units } { Token-not-allowed } {#1} \l__cooking_units_given_amount_tl
- \bool_set_true:N \l__cooking_units_error_bool
- \tl_map_break:
- }
- }
- }
+ \bool_set_true:N \l__cooking_units_error_bool
+ \__cooking_units_check_error:n {#1}
}
}
}
}
-\cs_new:Npn \__cooking_units_check_repitition:NN #1#2
+\cs_new:Npn \__cooking_units_check_error:n #1
{
- \bool_if:NTF #2
+ \tl_if_in:NnTF \l__cooking_units_input_fraction_sign_tl {#1}
+ { \__cooking_units_create_error:n { Second-fraction-sign-not-allowed } }
{
- \tl_case:NnTF #1
- {
- \q__cooking_units_decimal
- { \msg_error:nnV { cooking-units } { Second-decimal-sign-not-allowed } \l__cooking_units_given_amount_tl }
- \q__cooking_units_frac
- { \msg_error:nnV { cooking-units } { Second-fraction-sign-not-allowed } \l__cooking_units_given_amount_tl }
- \q__cooking_units_mixed_frac
- { \msg_error:nnV { cooking-units } { Second-mixed-fraction-sign-not-allowed } \l__cooking_units_given_amount_tl }
- }
- { \bool_set_true:N \l__cooking_units_error_bool }
- { \msg_error:nn { cooking-units } { internal-error } }
+ \tl_if_in:NnTF \l__cooking_units_input_mixed_fraction_sign_tl {#1}
+ { \__cooking_units_create_error:n { Second-mixed-fraction-sign-not-allowed } }
+ { \__cooking_units_create_error:nn { Token-not-allowed } {#1} }
}
- { \bool_set_true:N #2 }
}
-\cs_new:Npn \__cooking_units_parse_number_in_input:
+\cs_new:Npn \__cooking_units_check_repitition:N #1
+ {
+ \bool_if:NTF #1
+ { \__cooking_units_create_error:n { Second-decimal-sign-not-allowed } }
+ { \bool_set_true:N #1 }
+ }
+\cs_new:Npn \__cooking_units_process_number_in_input:
{
\__cooking_units_process_and_print_number_in_input:N \l__cooking_units_number_tmpa_tl
}
@@ -1354,19 +1399,15 @@
\__cooking_units_post_process_input:NN #1 \q_no_value
\__cooking_units_print_input:N #1
}
-\cs_new:Npn \__cooking_units_parse_range_in_input:
+\cs_new:Npn \__cooking_units_process_range_in_input:
{
\__cooking_units_pre_process_input:NN \l__cooking_units_number_tmpa_tl \l__cooking_units_number_tmpb_tl
\__cooking_units_calculate_and_store_in:N \l__cooking_units_number_tmpa_tl
\__cooking_units_calculate_and_store_in:N \l__cooking_units_number_tmpb_tl
\__cooking_units_post_process_input:NN \l__cooking_units_number_tmpa_tl \l__cooking_units_number_tmpb_tl
- \__cooking_units_print_input:N \l__cooking_units_number_tmpa_tl
- \bool_if:NTF \l__cooking_units_using_cutext_bool
- { \tl_use:N \l__cooking_units_cutext_range_sign_tl }
- { \tl_use:N \l__cooking_units_cunum_range_sign_tl }
- \__cooking_units_print_input:N \l__cooking_units_number_tmpb_tl
+ \__cooking_units_print_ranges:NN \l__cooking_units_number_tmpa_tl \l__cooking_units_number_tmpb_tl
}
-\cs_new:Npn \__cooking_units_parse_fraction_in_input:
+\cs_new:Npn \__cooking_units_process_fraction_in_input:
{
\bool_lazy_or:nnTF
{ \l__cooking_units_lokal_fraction_bool }
@@ -1386,7 +1427,7 @@
\__cooking_units_process_and_print_number_in_input:N \l__cooking_units_number_tmpa_tl
}
}
-\cs_new:Npn \__cooking_units_parse_mixed_fraction_in_input:
+\cs_new:Npn \__cooking_units_process_mixed_fraction_in_input:
{
\__cooking_units_tl_if_in_remove_and_set_bool:NnN \l__cooking_units_mixed_fraction_tl { - } \l__cooking_units_minus_bool
\__cooking_units_tl_if_in_remove_and_reverse_bool:NnN \l__cooking_units_number_tmpa_tl { - } \l__cooking_units_minus_bool
@@ -1414,54 +1455,57 @@
}
\cs_new:Npn \__cooking_units_calculate_and_store_in:N #1
{
- \bool_if:NF \l__cooking_units_error_bool
+ \bool_if:NTF \l__cooking_units_special_sign_bool
{
- \bool_if:NTF \l__cooking_units_special_sign_bool
- {
- \tl_set_eq:NN \l__cooking_units_tmpa_tl #1
- \msg_warning:nnx { cooking-units } { amount-not-known } \l__cooking_units_tmpa_tl
- }{
- \bool_lazy_and:nnTF
- { \l__cooking_units_using_cutext_bool } { ! \l__cooking_units_cutext_change_unit_bool }
- { \tl_set_eq:NN \l__cooking_units_tmpa_tl #1 }
- { \__cooking_units_calculate_input_and_store_in:nN {#1} \l__cooking_units_tmpa_tl }
- \bool_if:NT \l__cooking_units_lokal_persons_bool
- {
- \__cooking_units_calc_for_number_of_persons_and_store_in:NN
- \l__cooking_units_tmpa_tl \l__cooking_units_tmpa_tl
- }
- \__cooking_units_round_calculated_input:NV \l__cooking_units_tmpa_tl \l__cooking_units_tmpa_tl
- \__cooking_units_check_temperature_limit:N \l__cooking_units_tmpa_tl
- }
+ \msg_warning:nnV { cooking-units } { amount-not-known } #1
+ }{
+ \bool_lazy_and:nnTF
+ { \l__cooking_units_using_cutext_bool } { \l__cooking_units_cutext_keep_unit_bool }
+ { \tl_set_eq:NN \l__cooking_units_tmpa_tl #1 }
+ { \__cooking_units_calculate_input_and_store_in:nN {#1} \l__cooking_units_tmpa_tl }
+ \__cooking_units_calc_references:NN \l__cooking_units_tmpa_tl \l__cooking_units_tmpa_tl
+ \__cooking_units_round_calculated_input:NV \l__cooking_units_tmpa_tl \l__cooking_units_tmpa_tl
+ \__cooking_units_check_temperature_limit:N \l__cooking_units_tmpa_tl
\tl_set_eq:NN #1 \l__cooking_units_tmpa_tl
}
}
\cs_new:Npn \__cooking_units_calculate_input_and_store_in:nN #1#2
{
\fp_set:Nn \l__cooking_units_tmpa_fp {#1}
- \tl_if_in:cnTF { l__cooking_units_tmpa_ \l__cooking_units_given_unit_tl _ tl } { \l__cooking_units_tmpa_fp }
+ \tl_if_in:cnTF { l__cooking_units_unit_change_ \l__cooking_units_given_unit_tl _tl } { \l__cooking_units_tmpa_fp }
{
- \__cooking_units_tl_eval:Nv #2 { l__cooking_units_tmpa_ \l__cooking_units_given_unit_tl _ tl }
+ \__cooking_units_tl_eval:Nv #2 { l__cooking_units_unit_change_ \l__cooking_units_given_unit_tl _tl }
}{
\__cooking_units_tl_eval:Nn #2
- { \l__cooking_units_tmpa_fp * \tl_use:c { l__cooking_units_tmpa_ \l__cooking_units_given_unit_tl _ tl } }
+ { \l__cooking_units_tmpa_fp * \tl_use:c { l__cooking_units_unit_change_ \l__cooking_units_given_unit_tl _tl } }
}
}
-\cs_new:Npn \__cooking_units_calc_for_number_of_persons_and_store_in:NN #1#2
+\cs_new:Npn \__cooking_units_calc_references:NN #1#2
{
- \int_compare:nNnF
- { \l__cooking_units_wanted_number_of_persons_int }
- =
- { \l__cooking_units_local_number_of_persons_int }
+ \bool_if:NT \l__cooking_units_lokal_persons_bool
{
- \__cooking_units_tl_eval:Nn #1
+ \int_compare:nNnF
+ { \l__cooking_units_wanted_number_of_persons_int }
+ =
+ { \l__cooking_units_local_number_of_persons_int }
{
- \l__cooking_units_wanted_number_of_persons_int /
- \l__cooking_units_local_number_of_persons_int *
- #2
+ \__cooking_units_change_unit:TF
+ { \tl_set_eq:NN \l__cooking_units_tmpb_tl \l__cooking_units_option_unit_tl }
+ { \tl_set_eq:NN \l__cooking_units_tmpb_tl \l__cooking_units_given_unit_tl }
+ \seq_if_in:NVF \l__cooking_units_curef_do_not_change_seq \l__cooking_units_tmpb_tl
+ { \__cooking_units_calc_references_aux:NN #1 #2 }
}
}
}
+\cs_new:Npn \__cooking_units_calc_references_aux:NN #1#2
+ {
+ \__cooking_units_tl_eval:Nn #1
+ {
+ #2 *
+ \l__cooking_units_wanted_number_of_persons_int /
+ \l__cooking_units_local_number_of_persons_int
+ }
+ }
\cs_new:Npn \__cooking_units_check_number_for_rounding:n #1
{
\bool_set_false:N \l__cooking_units_round_number_bool
@@ -1490,12 +1534,9 @@
\cs_new:Npn \__cooking_units_round_calculated_input:Nn #1#2
{
\__cooking_units_check_number_for_rounding:n {#2}
- \tl_set:Nf #1
- {
- \bool_if:NTF \l__cooking_units_round_number_bool
- { \fp_eval:n { round ( \__cooking_units_rounding_function:n {#2} ) } }
- {#2}
- }
+ \bool_if:NTF \l__cooking_units_round_number_bool
+ { \__cooking_units_tl_eval:Nn #1 { round ( \__cooking_units_rounding_function:n {#2} ) } }
+ { \tl_set:Nn #1 {#2} }
}
\cs_generate_variant:Nn \__cooking_units_round_calculated_input:Nn { NV }
\cs_new:Npn \__cooking_units_check_temperature_limit:N #1
@@ -1610,8 +1651,8 @@
\bool_set_true:N \l__cooking_units_using_cutext_bool
\__cooking_units_set_process_and_print_for_cutext:
\__cooking_units_initialise_default:n {#3}
- \bool_if:NTF \l__cooking_units_cutext_change_unit_bool
- { \__cooking_units_initialise_unit_change:n {#2} }
+ \__cooking_units_initialise_unit_change:n {#2}
+ \bool_if:NT \l__cooking_units_cutext_keep_unit_bool
{ \tl_set_eq:NN \l__cooking_units_option_unit_tl \l__cooking_units_given_unit_tl }
\__cooking_units_initialise_after_unit_change:nn {#1} {#2}
\bool_if:NT \l__cooking_units_fourty_two_bool
@@ -1634,7 +1675,7 @@
{
\__cooking_units_int_if_equal_one:nTF {#1}
{
- \__cooking_units_translate_one_to_and_check_existance:Nx \l__cooking_units_translation_tmpa_tl {#2}
+ \__cooking_units_translate_one_and_check_existance:Nx \l__cooking_units_translation_tmpa_tl {#2}
\bool_if:NTF \l__cooking_units_cutext_uppercase_word_bool
{
\exp_args:Nx \tl_upper_case:n { \tl_head:V \l__cooking_units_translation_tmpa_tl }
@@ -1691,7 +1732,6 @@
}
\cs_new:Npn \__cooking_units_cutext_post_process_input_aux:NN #1#2
{
- \__cooking_units_bool_set_if_integers:NNN \l__cooking_units_tmpa_bool #1 #2
\bool_if:NTF \l__cooking_units_range_in_input_bool
{ \tl_set_eq:NN \l__cooking_units_cutext_last_value_tl #2 }
{ \tl_set_eq:NN \l__cooking_units_cutext_last_value_tl #1 }
@@ -1700,6 +1740,7 @@
}
\cs_new:Npn \__cooking_units_cutext_post_process_input_numerals:NN #1#2
{
+ \__cooking_units_bool_set_if_integers:NNN \l__cooking_units_tmpa_bool #1 #2
\bool_if:NTF \l__cooking_units_tmpa_bool
{
\bool_if:NTF \l__cooking_units_range_in_input_bool
@@ -1716,8 +1757,8 @@
{ \bool_set_false:N \l__cooking_units_lokal_numeral_bool }
}
\tl_const:Nn \c__cooking_units_cuam_marker_tl { __cooking_units_cunum }
-\tl_new:c { l__cooking_units_tmpa_ \c__cooking_units_cuam_marker_tl _ tl }
-\tl_set:cn { l__cooking_units_tmpa_ \c__cooking_units_cuam_marker_tl _ tl } { 1.0 }
+\tl_new:c { l__cooking_units_unit_change_ \c__cooking_units_cuam_marker_tl _tl }
+\tl_set:cn { l__cooking_units_unit_change_ \c__cooking_units_cuam_marker_tl _tl } { 1.0 }
\clist_new:c { l__cooking_units_predefined_option_ \c__cooking_units_cuam_marker_tl _clist }
\NewDocumentCommand \cuam { d<> O{} m }
{
@@ -1725,20 +1766,20 @@
{ \cuam }
{
\group_begin:
- \__cooking_units_cuam_initialise:nn {#1} {#2}
- \l__cooking_units_cuam_hook_tl
- \__cooking_units_cuam:n {#3}
+ \__cooking_units_cuam:nnn {#1} {#2} {#3}
\group_end:
}
}
-\cs_new:Npn \__cooking_units_cuam:n #1
+\cs_new:Npn \__cooking_units_cuam:nnn #1#2#3
{
+ \__cooking_units_cuam_initialise:nn {#1} {#2}
+ \l__cooking_units_cuam_hook_tl
\bool_if:NTF \l__cooking_units_cuam_old_bool
- { \__cooking_units_cuam_old:n {#1} }
- {
- \__cooking_units_parse_input:n {#1}
- \__cooking_units_print_correct_unit:
- }
+ { \__cooking_units_cuam_old:n {#3} }
+ {
+ \__cooking_units_parse_input:n {#3}
+ \__cooking_units_print_correct_unit:
+ }
}
\cs_new_protected:Npn \__cooking_units_cuam_initialise:nn #1#2
{
@@ -1758,19 +1799,15 @@
\__cooking_units_bool_set_if_integers:NNN \l__cooking_units_tmpa_bool #1 #2
\bool_lazy_and:nnT
{ \l__cooking_units_use_phrases_bool } { \l__cooking_units_tmpa_bool }
- {
- \__cooking_units_cuam_post_process_input_phrases:NN #1#2
- }
+ { \__cooking_units_cuam_post_process_input_phrases:NN #1#2 }
\bool_if:NT \l__cooking_units_lokal_numeral_bool
- {
- \__cooking_units_cuam_post_process_input_numerals:NN #1#2
- }
+ { \__cooking_units_cuam_post_process_input_numerals:NN #1#2 }
}
\cs_new:Npn \__cooking_units_cuam_post_process_input_phrases:NN #1#2
{
\__cooking_units_get_phrase_for_current_langauge:NNT
\l__cooking_units_phrase_prop
- \l__cooking_units_phrase_numbers_clist
+ \l__cooking_units_phrase_numbers_seq
{
\__cooking_units_cuam_post_process_input_phrases_aux:NNN
#1 \l__cooking_units_tmpa_int \l__cooking_units_phrase_number_tl
@@ -1778,18 +1815,17 @@
{
\bool_if:NTF \l__cooking_units_range_in_input_bool
{
- \__cooking_units_cuam_post_process_input_phrases_aux:NNN
- #2 \l__cooking_units_tmpb_int \l__cooking_units_tmpb_tl
- \bool_lazy_and:nnF
- { \l__cooking_units_lokal_phrase_bool }
- { \tl_if_eq_p:NN \l__cooking_units_phrase_number_tl \l__cooking_units_tmpb_tl }
- { \bool_set_false:N \l__cooking_units_lokal_phrase_bool }
- \bool_if:NT \l__cooking_units_lokal_phrase_bool
+ \bool_if:NF \l__cooking_units_phrase_negative_bool
{
- \tl_set:NV #1 \l__cooking_units_tmpa_int
- \tl_set:NV #2 \l__cooking_units_tmpb_int
- \__cooking_units_cuam_get_phrase_name:NVN
- \l__cooking_units_phrase_phrase_tl \l__cooking_units_phrase_number_tl \l__cooking_units_tmpb_int
+ \__cooking_units_cuam_post_process_input_phrases_range:NN
+ #2 \l__cooking_units_tmpb_int
+ \bool_if:NT \l__cooking_units_lokal_phrase_bool
+ {
+ \tl_set:NV #1 \l__cooking_units_tmpa_int
+ \tl_set:NV #2 \l__cooking_units_tmpb_int
+ \__cooking_units_cuam_get_phrase_name:NVN
+ \l__cooking_units_phrase_phrase_tl \l__cooking_units_phrase_number_tl \l__cooking_units_tmpb_int
+ }
}
}{
\tl_set:NV #1 \l__cooking_units_tmpa_int
@@ -1802,23 +1838,37 @@
\cs_new:Npn \__cooking_units_cuam_post_process_input_phrases_aux:NNN #1#2#3
{
\bool_set_false:N \l__cooking_units_lokal_phrase_bool
- \clist_map_inline:Nn \l__cooking_units_phrase_numbers_clist
+ \seq_map_inline:Nn \l__cooking_units_phrase_numbers_seq
{
\int_compare:nNnF { \int_abs:n {##1} } > {#1}
{
\int_compare:nNnTF {##1} < { 0 }
- { \int_set:Nn \l_tmpa_int { 1 } }
+ {
+ \bool_set_true:N \l__cooking_units_phrase_negative_bool
+ \int_set:Nn \l_tmpa_int { 1 }
+ }
{ \int_set:Nn \l_tmpa_int { \int_div_truncate:nn {#1} {##1} } }
\int_compare:nNnT { \int_abs:n {##1} * \l_tmpa_int } = {#1}
{
\int_set_eq:NN #2 \l_tmpa_int
\tl_set:Nn #3 {##1}
\bool_set_true:N \l__cooking_units_lokal_phrase_bool
- \clist_map_break:
+ \seq_map_break:
}
}
}
}
+\cs_new:Npn \__cooking_units_cuam_post_process_input_phrases_range:NN #1#2
+ {
+ \int_set:Nn \l_tmpa_int { \int_div_truncate:nn {#1} { \l__cooking_units_phrase_number_tl } }
+ \int_compare:nNnTF { \l__cooking_units_phrase_number_tl * \l_tmpa_int } = {#1}
+ {
+ \int_set_eq:NN #2 \l_tmpa_int
+ \bool_set_true:N \l__cooking_units_lokal_phrase_bool
+ }{
+ \bool_set_false:N \l__cooking_units_lokal_phrase_bool
+ }
+ }
\cs_new:Npn \__cooking_units_cuam_get_phrase_name:NnN #1#2#3
{
\__cooking_units_int_if_equal_one:nTF {#3}
@@ -1851,7 +1901,8 @@
{
\__cooking_units_int_if_equal_one:nTF {#1}
{
- \__cooking_units_translate_one_to_and_check_existance:Nx \l__cooking_units_translation_tmpa_tl
+ \__cooking_units_translate_one_and_check_existance:Nx
+ \l__cooking_units_translation_tmpa_tl
{ \l__cooking_units_phrase_number_tl -phrase-gender }
\l__cooking_units_translation_tmpa_tl
}
@@ -1923,7 +1974,7 @@
\seq_map_inline:Nn \l__cooking_units_tmpa_seq
{
\prop_set_eq:cN { l__cooking_units_cukeys_ ##1 _prop } \l__cooking_units_tmpb_prop
- \tl_set:cn { l__cooking_units_tmpa_ ##1 _tl } { 1.0 }
+ \tl_set:cn { l__cooking_units_unit_change_ ##1 _tl } { 1.0 }
\seq_map_inline:Nn \l__cooking_units_tmpa_seq
{
\prop_put:cnx { l__cooking_units_cukeys_ ##1 _prop }
@@ -1972,7 +2023,7 @@
\prop_get:cVc
{ l__cooking_units_cukeys_#1_prop }
\l_keys_choice_tl
- { l__cooking_units_tmpa_ #1_tl }
+ { l__cooking_units_unit_change_ #1_tl }
\prop_put:NnV \l__cooking_units_change_unit_prop {#1} \l_keys_choice_tl
}
\cs_new:Npn \__cooking_units_cukeys_parse_and_create_single_key:nn #1#2
@@ -2007,7 +2058,7 @@
}
\cs_new:Npn \__cooking_units_cusinglekeys_create_key_prop:n #1
{
- \tl_set:cn { l__cooking_units_tmpa_ #1 _tl } { 1.0 }
+ \tl_set:cn { l__cooking_units_unit_change_ #1 _tl } { 1.0 }
\prop_set_eq:cN { l__cooking_units_cukeys_ #1 _prop } \l__cooking_units_tmpa_prop
\prop_put:cnn { l__cooking_units_cukeys_ #1 _prop } { Erstes Ding } {#1}
\prop_put:cnV { l__cooking_units_cukeys_ #1 _prop } { Liste } \l__cooking_units_tmpa_seq
@@ -2016,7 +2067,7 @@
\cs_new:Npn \__cooking_units_cukeys_define_singlekey:nn #1#2
{
\seq_if_in:NnF \l__cooking_units_list_of_defined_keys_seq {#1}
- { \seq_put_right:Nn \l__cooking_units_list_of_defined_keys_seq {#1} }
+ { \seq_put_right:Nn \l__cooking_units_list_of_defined_keys_seq {#1} }
\keys_define:nn { cooking-units }
{
#1 .choices:Vn =
@@ -2042,23 +2093,18 @@
\NewDocumentCommand \cuaddkeys { m m }
{
\bool_set_false:N \l__cooking_units_single_key_bool
- \tl_set:Nn \l__cooking_units_tmpa_tl {#1}
- \tl_set:Nn \l__cooking_units_tmpb_tl {#2}
- \__cooking_units_cukeys_add_keys_or_single_keys:VV \l__cooking_units_tmpa_tl \l__cooking_units_tmpb_tl
+ \__cooking_units_cukeys_add_keys_or_single_keys:nn {#1} {#2}
}
\NewDocumentCommand \cuaddsinglekeys { m m }
{
\bool_set_true:N \l__cooking_units_single_key_bool
- \tl_set:Nn \l__cooking_units_tmpa_tl {#1}
- \tl_set:Nn \l__cooking_units_tmpb_tl {#2}
- \__cooking_units_cukeys_add_keys_or_single_keys:VV \l__cooking_units_tmpa_tl \l__cooking_units_tmpb_tl
+ \__cooking_units_cukeys_add_keys_or_single_keys:nn {#1} {#2}
}
\NewDocumentCommand \cuaddtokeys { m m m }
{
\bool_set_false:N \l__cooking_units_single_key_bool
- \tl_set:Nn \l__cooking_units_tmpa_tl {#1}
\tl_set:Nn \l__cooking_units_tmpb_tl { {#2} { \fp_eval:n { 1.0 / (#3) } } }
- \__cooking_units_cukeys_add_keys_or_single_keys:VV \l__cooking_units_tmpa_tl \l__cooking_units_tmpb_tl
+ \__cooking_units_cukeys_add_keys_or_single_keys:nV {#1} \l__cooking_units_tmpb_tl
}
\cs_new:Npn \__cooking_units_cukeys_add_keys_or_single_keys:nn #1#2
{
@@ -2073,7 +2119,7 @@
{ \__cooking_units_cukeys_parse_and_create_keys:nn {#1} {#2} }
}
}
-\cs_generate_variant:Nn \__cooking_units_cukeys_add_keys_or_single_keys:nn { VV }
+\cs_generate_variant:Nn \__cooking_units_cukeys_add_keys_or_single_keys:nn { nV }
\cs_new:Npn \__cooking_units_cukeys_add_keys_and_single_key_aux:n #1
{
\prop_get:cnN { l__cooking_units_cukeys_ #1 _prop } { Liste } \l__cooking_units_tmpa_seq
@@ -2112,8 +2158,8 @@
{ \msg_error:nnn { cooking-units } { character-not-allowed } {#2} }
}
\seq_put_right:Nn \g__cooking_units_list_of_defined_units_seq {#2}
- \tl_new:c { l__cooking_units_tmpa_ #2 _tl }
- \tl_set:cn { l__cooking_units_tmpa_ #2 _tl } { 1.0 }
+ \tl_new:c { l__cooking_units_unit_change_ #2 _tl }
+ \tl_set:cn { l__cooking_units_unit_change_ #2 _tl } { 1.0 }
\clist_new:c { l__cooking_units_predefined_option_#2_clist }
\keys_define:nn { cooking-units }
{
@@ -2214,7 +2260,7 @@
{
\__cooking_units_cuname_parse_unit_symbol:nw {#1}
}{
- \clist_if_in:NnTF \g__cooking_units_allowed_special_keys_clist {#1}
+ \seq_if_in:NnTF \g__cooking_units_allowed_special_keys_seq {#1}
{ \__cooking_units_cuname_parse_input_aux:nn {#1} }
{ \__cooking_units_cuname_parse_unit_symbol:nw {#1} [ \q_no_value ] }
}
@@ -2243,7 +2289,7 @@
\quark_if_recursion_tail_stop:n {#1}
\quark_if_recursion_tail_stop_do:nn {#2}
{ \msg_error:nn { cooking-units } { missing-argument } }
- \clist_if_in:NnF \g__cooking_units_allowed_special_keys_clist {#1}
+ \seq_if_in:NnF \g__cooking_units_allowed_special_keys_seq {#1}
{ \__cooking_units_error_if_unit_not_defined:n {#1} }
\__cooking_units_deftranslation_to:Vxxn
\l__cooking_units_language_tl {#1}
@@ -2254,7 +2300,7 @@
}
\cs_new:Npn \__cooking_units_cuname_parse_bracket:nw #1 [#2]
{
- \clist_if_in:NnF \g__cooking_units_allowed_special_keys_clist {#1}
+ \seq_if_in:NnF \g__cooking_units_allowed_special_keys_seq {#1}
{
\__cooking_units_deftranslation_to:Vxxn \l__cooking_units_language_tl {#1}
\c__cooking_units_postfix_unitname_pl_tl {#2}
@@ -2282,7 +2328,7 @@
\quark_if_recursion_tail_stop:n {#1}
\quark_if_recursion_tail_stop_do:nn {#2}
{ \msg_error:nn { cooking-units } { missing-argument } }
- \clist_if_in:NnTF \g__cooking_units_allowed_special_keys_clist {#1}
+ \seq_if_in:NnTF \g__cooking_units_allowed_special_keys_seq {#1}
{
\__cooking_units_deftranslation_to:Vxxn \l__cooking_units_language_tl {#1}
\c__cooking_units_postfix_unitname_tl {#2}
@@ -2321,17 +2367,17 @@
\tl_set:Nn \l__cooking_units_language_tl {#1}
\__cooking_units_phrase_list_get_for:NNTF \l__cooking_units_phrase_prop \l__cooking_units_language_tl
{
- \__cooking_units_translate_let:VNxx \l__cooking_units_language_tl \l__cooking_units_phrase_numbers_clist
+ \__cooking_units_translate_let:VNxx \l__cooking_units_language_tl \l__cooking_units_phrase_numbers_seq
{ phrase-clist } \c__cooking_units_postfix_phrase_tl
}{
\prop_clear:N \l__cooking_units_phrase_prop
- \clist_clear:N \l__cooking_units_phrase_numbers_clist
+ \seq_clear:N \l__cooking_units_phrase_numbers_seq
}
\__cooking_units_sanitize_arrows:n {#2}
\exp_last_unbraced:NV
\__cooking_units_cuphrase_parse:n \l__cooking_units_sanitise_tl
\q_recursion_tail \q_recursion_tail \q_recursion_stop
- \clist_sort:Nn \l__cooking_units_phrase_numbers_clist
+ \seq_sort:Nn \l__cooking_units_phrase_numbers_seq
{
\int_compare:nNnTF { \int_abs:n {##1} } < { \int_abs:n {##2} }
{ \sort_return_swapped: }
@@ -2350,7 +2396,7 @@
\l__cooking_units_phrase_prop
\__cooking_units_deftranslation_to:VxxV
\l__cooking_units_language_tl { phrase-clist }
- \c__cooking_units_postfix_phrase_tl \l__cooking_units_phrase_numbers_clist
+ \c__cooking_units_postfix_phrase_tl \l__cooking_units_phrase_numbers_seq
}
\cs_new:Npn \__cooking_units_cuphrase_parse:n #1
{
@@ -2371,8 +2417,8 @@
\quark_if_recursion_tail_stop_do:nn {#2}
{ \msg_error:nn { cooking-units } { missing-argument } }
\prop_put:Nnn \l__cooking_units_phrase_prop {#1} {#2}
- \clist_if_in:NnF \l__cooking_units_phrase_numbers_clist {#1}
- { \clist_put_right:Nn \l__cooking_units_phrase_numbers_clist {#1} }
+ \seq_if_in:NnF \l__cooking_units_phrase_numbers_seq {#1}
+ { \seq_push:Nn \l__cooking_units_phrase_numbers_seq {#1} }
\peek_meaning_ignore_spaces:NTF [
{
\__cooking_units_chuphrase_parse_plural:nw {#1}
@@ -2426,7 +2472,7 @@
{
\__cooking_units_int_if_equal_one:nTF {#1}
{
- \__cooking_units_translate_one_to_and_check_existance:Nx \l__cooking_units_translation_tmpa_tl {#2}
+ \__cooking_units_translate_one_and_check_existance:Nx \l__cooking_units_translation_tmpa_tl {#2}
\bool_if:NTF \l__cooking_units_cutext_uppercase_word_bool
{
\exp_args:Nx \tl_upper_case:n { \tl_head:V \l__cooking_units_translation_tmpa_tl }