diff options
author | Karl Berry <karl@freefriends.org> | 2022-04-05 22:09:21 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-04-05 22:09:21 +0000 |
commit | 43498062297432f6e77404bad0ad54f0fb991a05 (patch) | |
tree | a16d938128be2ef4c2b27488257a1efa2c4f653f /Master/texmf-dist/tex/latex/cooking-units | |
parent | d61004134d68c79416fe08a3938ede2b3e4476ef (diff) |
cooking-units (27mar22)
git-svn-id: svn://tug.org/texlive/trunk@62938 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/cooking-units')
-rw-r--r-- | Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty | 144 |
1 files changed, 91 insertions, 53 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 8e2ca347148..923010ee9d3 100644 --- a/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty +++ b/Master/texmf-dist/tex/latex/cooking-units/cooking-units.sty @@ -5,7 +5,7 @@ %% The original source files were: %% %% cooking-units.dtx (with options: `package') -%% Copyright (C) 2016--2021 by Ben Vitecek (current Maintainer) +%% Copyright (C) 2016--2022 by Ben Vitecek (current Maintainer) %% %% This file may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either @@ -30,10 +30,10 @@ { \RequirePackage {expl3} } \ProvidesExplPackage {cooking-units} - {2021/05/16} - {2.00} + {2022/03/26} + {2.00a} {Ein Paket fuer Kocheinheiten} -\@ifpackagelater { expl3 } { 2021/05/07 } +\@ifpackagelater { expl3 } { 2022/02/24 } { } { \PackageError { cooking-units } { Support~package~expl3~too~old } @@ -47,7 +47,7 @@ \@ifpackageloaded { translations } { } { \RequirePackage { translations } } \@ifpackageloaded { xfrac } { } { \RequirePackage { xfrac } } \@ifpackageloaded { l3keys2e } { } { \RequirePackage { l3keys2e } } -\@ifpackagelater { translations } { 2021/01/17 } +\@ifpackagelater { translations } { 2022/02/05 } { } { \PackageError { cooking-units } { Support~package~translations~too~old } @@ -178,6 +178,8 @@ \tl_new:N \l__cookingunits_stored_units_tl \tl_new:N \l__cookingunits_stored_formula_tl \tl_new:N \l__cookingunits_base_tl +\tl_new:N \l_cookingunits_raw_amount_a_tl +\tl_new:N \l_cookingunits_raw_amount_b_tl \tl_new:N \l__cookingunits_cmd_hook_tl \tl_new:N \l__cookingunits_cunum_hook_tl \tl_new:N \l__cookingunits_cutext_hook_tl @@ -282,7 +284,8 @@ \bool_set_false:N \l__cookingunits_pckopt_cutext_keep_unit_bool \bool_set_eq:NN \l__cookingunits_pckopt_print_numeral_bool \g__cookingunits_opt_numeral_bool \quark_new:N \q__cookingunits_range -\quark_new:N \q__cookingunits_no_translation +\quark_new:N \q__cookingunits_no_translation_str +\str_const:Nn \c__cookingunits_no_translation_str { no-translation-sady-found-__cookingunits } \tl_new:N \l__cookingunits_scrap_tl \tl_new:N \l__cookingunits_tmpa_tl \tl_new:N \l__cookingunits_tmpb_tl @@ -1555,7 +1558,7 @@ \prg_new_conditional:Npnn \__cookingunits_culang_unitname_let:Nn #1#2 { TF, F , T } { \__cookingunits_culang_let:nnN { name } {#2} #1 - \tl_if_eq:NNTF #1 \q__cookingunits_no_translation + \tl_if_eq:NNTF #1 \c__cookingunits_no_translation_str { \prg_return_false: } { \prg_return_true: } } @@ -1591,14 +1594,14 @@ one (n) } \__cookingunits_culang_def_base:nnn { name } { decimal-mark } { . } -\__cookingunits_culang_def_base:nnn { name-pl } { decimal-mark } { \q__cookingunits_no_translation } +\__cookingunits_culang_def_base:nnn { name-pl } { decimal-mark } { \c__cookingunits_no_translation_str } \__cookingunits_culang_def_for:nnnn { German } { name-pl } { decimal-mark } { , } -\__cookingunits_culang_def_base:nnn { name } { one (m) } { \q__cookingunits_no_translation } -\__cookingunits_culang_def_base:nnn { name } { one (f) } { \q__cookingunits_no_translation } -\__cookingunits_culang_def_base:nnn { name } { one (n) } { \q__cookingunits_no_translation } -\__cookingunits_culang_def_base:nnn { name-pl } { one (m) } { \q__cookingunits_no_translation } -\__cookingunits_culang_def_base:nnn { name-pl } { one (f) } { \q__cookingunits_no_translation } -\__cookingunits_culang_def_base:nnn { name-pl } { one (n) } { \q__cookingunits_no_translation } +\__cookingunits_culang_def_base:nnn { name } { one (m) } { \c__cookingunits_no_translation_str } +\__cookingunits_culang_def_base:nnn { name } { one (f) } { \c__cookingunits_no_translation_str } +\__cookingunits_culang_def_base:nnn { name } { one (n) } { \c__cookingunits_no_translation_str } +\__cookingunits_culang_def_base:nnn { name-pl } { one (m) } { \c__cookingunits_no_translation_str } +\__cookingunits_culang_def_base:nnn { name-pl } { one (f) } { \c__cookingunits_no_translation_str } +\__cookingunits_culang_def_base:nnn { name-pl } { one (n) } { \c__cookingunits_no_translation_str } \__cookingunits_culang_def_for:nnnn { English } { name } { one (m) } { one } \__cookingunits_culang_def_for:nnnn { English } { name } { one (f) } { one } \__cookingunits_culang_def_for:nnnn { English } { name } { one (n) } { one } @@ -1606,7 +1609,7 @@ \__cookingunits_culang_def_for:nnnn { German } { name } { one (f) } { eine } \__cookingunits_culang_def_for:nnnn { German } { name } { one (n) } { ein } \__cookingunits_culang_def_base:nnn { name } { cutext-range-sign } { -- } -\__cookingunits_culang_def_base:nnn { name-pl } { cutext-range-sign } { \q__cookingunits_no_translation } +\__cookingunits_culang_def_base:nnn { name-pl } { cutext-range-sign } { \c__cookingunits_no_translation_str } \__cookingunits_culang_def_for:nnnn { German } { name } { cutext-range-sign } { ~bis~ } \__cookingunits_culang_def_for:nnnn { English } { name } { cutext-range-sign } { ~to~ } \cs_new:Npn \__cookingunits_def_new_type:nnn #1#2#3 @@ -1618,16 +1621,18 @@ } \cs_new:Npn \__cookingunits_def_new_type_aux:Nnn #1#2#3 { - \cs_new:cpn { __cookingunits_set_ #2 _to:n } ##1 + \cs_new_nopar:cpn { __cookingunits_set_ #2 _to:n } ##1 { - \tl_if_exist:cF { c__cookingunits_#2_ ##1 _tl } { \tl_show:n { ERROR-set-#2-##1 } } - \tl_set_eq:Nc #1 { c__cookingunits_#2_ ##1 _tl } + \tl_if_exist:cF { c__cookingunits_#2_ ##1 _tl } + { \msg_error:nnn {cooking-units } { internal-error } { Type } { ERROR-set-#2-##1 } } + \tl_set_eq:Nc #1 { c__cookingunits_#2_ ##1 _tl } } \tl_if_empty:nF {#3} { \prg_new_conditional:cpnn { __cookingunits_if_ #2 _equal:n } ##1 {#3} { - \tl_if_exist:cF { c__cookingunits_#2_ ##1 _tl } { \tl_show:n { ERROR-check-#2-##1 } } + \tl_if_exist:cF { c__cookingunits_#2_ ##1 _tl } + { \msg_error:nnnn {cooking-units } { internal-error } { Type-2 } { ERROR-set-#2-##1 } } \tl_if_eq:NcTF #1 { c__cookingunits_#2_ ##1 _tl } { \prg_return_true: } { \prg_return_false: } @@ -1656,7 +1661,6 @@ \cs_if_exist_use:c { exp_args:NN \l__cookingunits_expand_amount_tl } \__cookingunits_set_amount:Nn #1 {#2} } -\bool_new:N \l__cookingunits_skip_first_part_bool \cs_new:Npn \__cookingunits_do_the_stuff:nnnnnn #1#2#3#4#5#6 { \__cookingunits_initialice_accordingly:nnnn {#1} {#4} {#2} {#5} @@ -1904,7 +1908,11 @@ \cs_new:Npn \__cookingunits_new_print_unit_correctly: { \__cookingunits_if_state_equal:nTF { error } - { \__cookingunits_print_unit_in_case_of_error: } + { + \tl_case:NnF \l__cookingunits_cmd_type_tl + { \c__cookingunits_cmd_type_cuam_tl { } } + { \__cookingunits_print_unit_in_case_of_error: } + } { \tl_case:NnF \l__cookingunits_cmd_type_tl { @@ -1989,12 +1997,12 @@ } \cs_new:Npn \__cookingunits_create_internal_error:nN #1#2 { - \__cookingunits_set_case_to:n { error } + \__cookingunits_set_state_to:n { error } \msg_error:nnnV { cooking-units } { internal-error } {#1} #2 } \cs_new:Npn \__cookingunits_create_error:n #1 { - \__cookingunits_set_case_to:n { error } + \__cookingunits_set_state_to:n { error } \msg_error:nnV { cooking-units } {#1} \l__cookingunits_original_amount_tl } \cs_new:Npn \__cookingunits_create_error_and_stop:n #1 @@ -2004,7 +2012,7 @@ } \cs_new:Npn \__cookingunits_create_error:nn #1#2 { - \__cookingunits_set_case_to:n { error } + \__cookingunits_set_state_to:n { error } \msg_error:nnnV { cooking-units } {#1} {#2} \l__cookingunits_original_amount_tl } \cs_new:Npn \__cookingunits_parse_the_amount:n #1 @@ -2449,8 +2457,8 @@ } \cs_new:Npn \__cookingunits_cuam_post_process_input_phrases:NN #1#2 { - \__cookingunits_culang_let:nnN { phrase } { phrase-prop } \l__cookingunits_phrase_prop - \tl_if_eq:NNT \q__cookingunits_no_translation \l__cookingunits_phrase_prop + \__cookingunits_culang_get_phrase_prop:N \l__cookingunits_phrase_prop + \tl_if_eq:NNT \c__cookingunits_no_translation_str \l__cookingunits_phrase_prop { \use_none_delimit_by_q_stop:w } \prop_get:NnN \l__cookingunits_phrase_prop { seq } \l__cookingunits_phrase_numbers_seq \__cookingunits_cuam_post_process_input_phrases_aux:NNN @@ -2916,8 +2924,8 @@ \cs_generate_variant:Nn \__cookingunits_set_cooking_unit:nnn { nnV } \cs_new:Npn \__cookingunits_set_cooking_unit_base_translation:n #1 { - \__cookingunits_culang_def_base:nnn { name } {#1} \q__cookingunits_no_translation - \__cookingunits_culang_def_base:nnn { name-pl } {#1} \q__cookingunits_no_translation + \__cookingunits_culang_def_base:nnn { name } {#1} \c__cookingunits_no_translation_str + \__cookingunits_culang_def_base:nnn { name-pl } {#1} \c__cookingunits_no_translation_str \__cookingunits_culang_def_base:nnn { gender } {#1} { m } } \NewDocumentCommand \declarecookingderivatives { m m m m } @@ -3142,9 +3150,12 @@ \__cookingunits_error_if_unit_not_defined:nNT {#1} \l__cookingunits_curr_unit_tl { \__cookingunits_set_state_to:n { error } } } - \peek_meaning_ignore_spaces:NTF [ - { \__cookingunits_parse_definename_optional_unitsymbol:w } - { \__cookingunits_parse_definename_singular:n } + \peek_remove_spaces:n + { + \peek_meaning:NTF [ + { \__cookingunits_parse_definename_optional_unitsymbol:w } + { \__cookingunits_parse_definename_singular:n } + } } \cs_new:Npn \__cookingunits_parse_definename_optional_unitsymbol:w [#1] { @@ -3162,16 +3173,22 @@ \quark_if_recursion_tail_stop_do:nn {#1} { \msg_error:nn { cooking-units } { missing-argument } } \prop_put:Nnn \l__cookingunits_tmpa_prop { name } {#1} - \peek_meaning_ignore_spaces:NTF [ - { \__cookingunits_parse_definename_optional_plural:w } - { \__cookingunits_parse_definename_optional_plural:w [#1] } + \peek_remove_spaces:n + { + \peek_meaning:NTF [ + { \__cookingunits_parse_definename_optional_plural:w } + { \__cookingunits_parse_definename_optional_plural:w [#1] } + } } \cs_new:Npn \__cookingunits_parse_definename_optional_plural:w [#1] { \prop_put:Nnn \l__cookingunits_tmpa_prop { name-pl } {#1} - \peek_meaning_ignore_spaces:NTF < - { \__cookingunits_parse_definename_optional_gender:w } - { \__cookingunits_parse_definename_optional_gender:w <m> } + \peek_remove_spaces:n + { + \peek_meaning:NTF < + { \__cookingunits_parse_definename_optional_gender:w } + { \__cookingunits_parse_definename_optional_gender:w <m> } + } } \cs_new:Npn \__cookingunits_parse_definename_optional_gender:w <#1> { @@ -3212,7 +3229,21 @@ {#1} {#2} \__cookingunits_cuprint_define_printed_unit:nn } -\__cookingunits_culang_def_base:nnn { phrase } { phrase-prop } { \q__cookingunits_no_translation } +\__cookingunits_culang_def_base:nnn { phrase } { phrase-prop } { \c__cookingunits_no_translation_str } +\__cookingunits_culang_def_base:nnn { phrase } { phrase-lang } { Humphry-Drumphy } +\cs_new:Npn \__cookingunits_culang_get_phrase_prop:N #1 + { + \__cookingunits_culang_let:nnN { phrase } { phrase-lang } \l__cookingunits_language_tl + \prop_if_exist:cTF { l__cookingunits_ \l__cookingunits_language_tl _phrase_prop } + { + \prop_set_eq:Nc #1 { l__cookingunits_ \l__cookingunits_language_tl _phrase_prop } + } + { \tl_set_eq:NN #1 \c__cookingunits_no_translation_str } + } +\cs_new:Npn \__cookingunits_culang_get_phrase_prop_for:nN #1#2 + { + \prop_set_eq:Nc #2 { l__cookingunits_ #1 _phrase_prop } + } \NewDocumentCommand \cudefinephrase { m m } { \__cookingunits_new_cuphrase_add:nn {#1} {#2} @@ -3221,21 +3252,22 @@ { \tl_set:Nn \l__cookingunits_language_tl {#1} \__cookingunits_culang_if_translation_exists_for:VnnTF \l__cookingunits_language_tl - { phrase } { phrase-prop } + { phrase } { phrase-lang } { - \__cookingunits_culang_let_for:VnnN \l__cookingunits_language_tl { phrase } { phrase-prop } - \l__cookingunits_phrase_prop + \prop_set_eq:Nc \l__cookingunits_phrase_prop { l__cookingunits_ \l__cookingunits_language_tl _phrase_prop } \prop_get:NnN \l__cookingunits_phrase_prop { seq } \l__cookingunits_phrase_numbers_seq }{ + \prop_new:c { l__cookingunits_ \l__cookingunits_language_tl _phrase_prop } \prop_clear:N \l__cookingunits_phrase_prop \seq_clear:N \l__cookingunits_phrase_numbers_seq } - \__cookingunits_sanitize_arrows:n {#2} - \__cookingunits_parse_phrase:V \l__cookingunits_sanitise_tl - \__cookingunits_new_cuphrase_sort_sequence:N \l__cookingunits_phrase_numbers_seq - \prop_put:NnV \l__cookingunits_phrase_prop { seq } \l__cookingunits_phrase_numbers_seq - \__cookingunits_culang_def_for:VnnV - \l__cookingunits_language_tl { phrase } { phrase-prop } \l__cookingunits_phrase_prop + \__cookingunits_sanitize_arrows:n {#2} + \__cookingunits_parse_phrase:V \l__cookingunits_sanitise_tl + \__cookingunits_new_cuphrase_sort_sequence:N \l__cookingunits_phrase_numbers_seq + \prop_put:NnV \l__cookingunits_phrase_prop { seq } \l__cookingunits_phrase_numbers_seq + \prop_set_eq:cN { l__cookingunits_ \l__cookingunits_language_tl _phrase_prop } \l__cookingunits_phrase_prop + \__cookingunits_culang_def_for:VnnV + \l__cookingunits_language_tl { phrase } { phrase-lang } \l__cookingunits_language_tl } \cs_new:Npn \__cookingunits_parse_phrase:n #1 { @@ -3278,16 +3310,22 @@ } \cs_new:Npn \__cookingunits_parse_phrase_optionals:n #1 { - \peek_meaning_ignore_spaces:NTF [ - { \__cookingunits_parse_stuff_plural:w } - { \__cookingunits_parse_stuff_plural:w [#1] } + \peek_remove_spaces:n + { + \peek_meaning:NTF [ + { \__cookingunits_parse_stuff_plural:w } + { \__cookingunits_parse_stuff_plural:w [#1] } + } } \cs_new:Npn \__cookingunits_parse_stuff_plural:w [#1] { \prop_put:Nnn \l__cookingunits_tmpa_prop { -pl } {#1} - \peek_meaning_ignore_spaces:NTF < - { \__cookingunits_parse_stuff_gender:w } - { \__cookingunits_parse_stuff_gender:w <m> } + \peek_remove_spaces:n + { + \peek_meaning:NTF < + { \__cookingunits_parse_stuff_gender:w } + { \__cookingunits_parse_stuff_gender:w <m> } + } } \cs_new:Npn \__cookingunits_parse_stuff_gender:w <#1> { |