summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/crefthe/crefthe.sty
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-07-25 03:01:17 +0000
committerNorbert Preining <norbert@preining.info>2023-07-25 03:01:17 +0000
commitbe53973de38a7aa9a3a0a8c70fd92bdf893c1a35 (patch)
tree50d18c7e399afeaa37df77a57667580ba93fea0a /macros/latex/contrib/crefthe/crefthe.sty
parent19444d4440a66200b03e05b567996375d0404a46 (diff)
CTAN sync 202307250301
Diffstat (limited to 'macros/latex/contrib/crefthe/crefthe.sty')
-rw-r--r--macros/latex/contrib/crefthe/crefthe.sty121
1 files changed, 55 insertions, 66 deletions
diff --git a/macros/latex/contrib/crefthe/crefthe.sty b/macros/latex/contrib/crefthe/crefthe.sty
index 4097b0aefc..4f7b382e74 100644
--- a/macros/latex/contrib/crefthe/crefthe.sty
+++ b/macros/latex/contrib/crefthe/crefthe.sty
@@ -12,7 +12,7 @@
\NeedsTeXFormat{LaTeX2e}[2022-06-01]
\ProvidesExplPackage
{crefthe}
- {2023/07/23} {}
+ {2023/07/23a} {}
{Cross referencing with proper definite articles}
\keys_define:nn { crefthe }
@@ -93,36 +93,53 @@
\__crefthe_cref_general:NNNnnN \c_false_bool #1 #2 { #3 } { #4 } \crefthe_nameCrefs_original:w
}
-\keys_define:nn { crefthe-setting }
+\keys_define:nn { crefthe-command }
{
, noun .code:n = { \RenewDocumentCommand \crefthemark { m } {} }
, variant .tl_set:N = \l__crefthe_variant_tl
- % , nom .meta:n = { variant = Nominativ }
- % , nom. .meta:n = { variant = Nominativ }
- % , Nom .meta:n = { variant = Nominativ }
- % , Nom. .meta:n = { variant = Nominativ }
- % , gen .meta:n = { variant = Genitiv }
- % , gen. .meta:n = { variant = Genitiv }
- % , Gen .meta:n = { variant = Genitiv }
- % , Gen. .meta:n = { variant = Genitiv }
- % , dat .meta:n = { variant = Dativ }
- % , dat. .meta:n = { variant = Dativ }
- % , Dat .meta:n = { variant = Dativ }
- % , Dat. .meta:n = { variant = Dativ }
- % , akk .meta:n = { variant = Akkusativ }
- % , akk. .meta:n = { variant = Akkusativ }
- % , Akk .meta:n = { variant = Akkusativ }
- % , Akk. .meta:n = { variant = Akkusativ }
-
- % , unknown .code:n = {
- % \bool_gset_true:N \g__crefthe_has_prep_bool
- % \tl_set:No \l__crefthe_prep_tl { \l_keys_key_tl }
- % }
+ , abbr .bool_set:N = \l__crefthe_abbr_bool
+ , abbr. .bool_set:N = \l__crefthe_abbr_bool
, unknown .code:n = {}
}
+\clist_const:Nn \c__crefthe_command_known_keys_clist { noun, abbr, abbr. }
+
+\cs_new:Nn \__crefthe_command_key_parser:n
+ {
+ \bool_set_false:N \l__crefthe_variant_matched_bool
+ \clist_if_in:NnF \c__crefthe_command_known_keys_clist { #1 }
+ {
+ \str_if_eq:VnT \languagename { ngerman }
+ {
+ \str_case:nnT { #1 }
+ {
+ { nom } { \tl_set:Nn \l__crefthe_variant_tl { Nominativ } }
+ { nom. } { \tl_set:Nn \l__crefthe_variant_tl { Nominativ } }
+ { Nom } { \tl_set:Nn \l__crefthe_variant_tl { Nominativ } }
+ { Nom. } { \tl_set:Nn \l__crefthe_variant_tl { Nominativ } }
+ { gen } { \tl_set:Nn \l__crefthe_variant_tl { Genitiv } }
+ { gen. } { \tl_set:Nn \l__crefthe_variant_tl { Genitiv } }
+ { Gen } { \tl_set:Nn \l__crefthe_variant_tl { Genitiv } }
+ { Gen. } { \tl_set:Nn \l__crefthe_variant_tl { Genitiv } }
+ { dat } { \tl_set:Nn \l__crefthe_variant_tl { Dativ } }
+ { dat. } { \tl_set:Nn \l__crefthe_variant_tl { Dativ } }
+ { Dat } { \tl_set:Nn \l__crefthe_variant_tl { Dativ } }
+ { Dat. } { \tl_set:Nn \l__crefthe_variant_tl { Dativ } }
+ { akk } { \tl_set:Nn \l__crefthe_variant_tl { Akkusativ } }
+ { akk. } { \tl_set:Nn \l__crefthe_variant_tl { Akkusativ } }
+ { Akk } { \tl_set:Nn \l__crefthe_variant_tl { Akkusativ } }
+ { Akk. } { \tl_set:Nn \l__crefthe_variant_tl { Akkusativ } }
+ } { \bool_set_true:N \l__crefthe_variant_matched_bool }
+ }
+ \bool_if:NF \l__crefthe_variant_matched_bool
+ {
+ \bool_gset_true:N \g__crefthe_has_prep_bool
+ \tl_set:Nn \l__crefthe_prep_tl { #1 }
+ }
+ }
+ }
\bool_new:N \l__crefthe_variant_matched_bool
\cs_new_protected:Nn \__crefthe_cref_general:NNNnnN
@@ -136,50 +153,16 @@
\group_begin:
\tl_set:Nn \l__crefthe_variant_tl {}
+ \bool_set_false:N \l__crefthe_abbr_bool
+
\bool_gset_false:N \g__crefthe_has_prep_bool
\tl_set:Nn \l__crefthe_prep_tl {}
- \keys_set:nn { crefthe-setting } { #4 }
+ \keys_set:nn { crefthe-command } { #4 }
+ % Below is for getting the preposition
+ \keyval_parse:NNn \__crefthe_command_key_parser:n \use_none:nn { #4 }
- % This should actually be part of the keys parsing
- \clist_map_inline:nn { #4 }
- {
- \bool_set_false:N \l__crefthe_variant_matched_bool
- \str_if_in:nnF { ##1 } { = }
- {% for keys without values
- \str_case:nnT { ##1 }
- {
- { abbr } { \tl_set:Nn \l__crefthe_variant_tl { abbr. } }
- { abbr. } { \tl_set:Nn \l__crefthe_variant_tl { abbr. } }
- } { \bool_set_true:N \l__crefthe_variant_matched_bool }
- \str_if_eq:VnT \languagename { ngerman }
- {
- \str_case:nnT { ##1 }
- {
- { nom } { \tl_set:Nn \l__crefthe_variant_tl { Nominativ } }
- { nom. } { \tl_set:Nn \l__crefthe_variant_tl { Nominativ } }
- { Nom } { \tl_set:Nn \l__crefthe_variant_tl { Nominativ } }
- { Nom. } { \tl_set:Nn \l__crefthe_variant_tl { Nominativ } }
- { gen } { \tl_set:Nn \l__crefthe_variant_tl { Genitiv } }
- { gen. } { \tl_set:Nn \l__crefthe_variant_tl { Genitiv } }
- { Gen } { \tl_set:Nn \l__crefthe_variant_tl { Genitiv } }
- { Gen. } { \tl_set:Nn \l__crefthe_variant_tl { Genitiv } }
- { dat } { \tl_set:Nn \l__crefthe_variant_tl { Dativ } }
- { dat. } { \tl_set:Nn \l__crefthe_variant_tl { Dativ } }
- { Dat } { \tl_set:Nn \l__crefthe_variant_tl { Dativ } }
- { Dat. } { \tl_set:Nn \l__crefthe_variant_tl { Dativ } }
- { akk } { \tl_set:Nn \l__crefthe_variant_tl { Akkusativ } }
- { akk. } { \tl_set:Nn \l__crefthe_variant_tl { Akkusativ } }
- { Akk } { \tl_set:Nn \l__crefthe_variant_tl { Akkusativ } }
- { Akk. } { \tl_set:Nn \l__crefthe_variant_tl { Akkusativ } }
- } { \bool_set_true:N \l__crefthe_variant_matched_bool }
- }
- \bool_if:NF \l__crefthe_variant_matched_bool
- {
- \tl_set:Nn \l__crefthe_prep_tl { ##1 }
- }
- }
- }
+ \bool_if:NT \l__crefthe_abbr_bool { \tl_set:Nn \l__crefthe_variant_tl { abbr. } }
\bool_if:NTF #2
{ \tl_set:No \l__crefthe_prep_once_tl { \l__crefthe_prep_tl } }
@@ -286,6 +269,9 @@
\crefthe_pass_variant_to:n { \Crefthename { #1 } }
}
+\NewCommandCopy \setcrefname \crefthevariantname
+\NewCommandCopy \setCrefname \Crefthevariantname
+
\tl_new:N \l__crefthe_variant_noun_singular_tl
\tl_new:N \l__crefthe_variant_noun_plural_tl
\tl_new:N \l__crefthe_variant_article_singular_tl
@@ -326,7 +312,7 @@
\cs_new_protected:Npn \__crefthe_parse_variant_default:n #1
{
\bool_set_true:N \l__crefthe_variant_default_bool
- \__crefthe_variant_parser:w #1 \q_stop
+ \__crefthe_variant_parser:w #1 {} {} \q_stop
\tl_set:Nx \l__crefthe_variant_default_article_singular_tl
{ \tl_item:Nn \l__crefthe_parsed_tl { 1 } }
\tl_set:Nx \l__crefthe_variant_default_noun_singular_tl
@@ -338,7 +324,7 @@
}
\cs_new_protected:Npn \__crefthe_parse_variant_value:nn #1#2
{
- \__crefthe_variant_parser:w #2 \q_stop
+ \__crefthe_variant_parser:w #2 {} {} \q_stop
\tl_put_right:Nx \l__crefthe_variant_article_singular_tl
{ { \tl_to_str:n { #1 } } { \tl_item:Nn \l__crefthe_parsed_tl { 1 } } }
\tl_put_right:Nx \l__crefthe_variant_noun_singular_tl
@@ -509,7 +495,10 @@
{ De~les } { Des }
}
-\bool_if:NF \l__crefthe_disable_contractions_for_german_bool
+\bool_if:NTF \l__crefthe_disable_contractions_for_german_bool
+ {
+ \tl_const:Nn \c_crefthe_contraction_rule_ngerman_tl {}
+ }
{
\tl_const:Nn \c_crefthe_contraction_rule_ngerman_tl
{