summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex-dev/base/ltfinal.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2022-11-02 22:00:49 +0000
committerKarl Berry <karl@freefriends.org>2022-11-02 22:00:49 +0000
commit3f1026bdc52825d68d83555c8d4cdc31a41f7687 (patch)
tree199f5a2a890795c71d60f3f33d3869d3eb714ba4 /Master/texmf-dist/source/latex-dev/base/ltfinal.dtx
parent263850a3c1c53d9e6c691c7046923b77f46aa465 (diff)
latex-dev 2022-11 (2nov22)
git-svn-id: svn://tug.org/texlive/trunk@64899 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex-dev/base/ltfinal.dtx')
-rw-r--r--Master/texmf-dist/source/latex-dev/base/ltfinal.dtx60
1 files changed, 53 insertions, 7 deletions
diff --git a/Master/texmf-dist/source/latex-dev/base/ltfinal.dtx b/Master/texmf-dist/source/latex-dev/base/ltfinal.dtx
index 69ea7bc942a..7f4bef3bcc1 100644
--- a/Master/texmf-dist/source/latex-dev/base/ltfinal.dtx
+++ b/Master/texmf-dist/source/latex-dev/base/ltfinal.dtx
@@ -33,7 +33,7 @@
%<*driver>
% \fi
\ProvidesFile{ltfinal.dtx}
- [2022/08/29 v2.2w LaTeX Kernel (Final Settings)]
+ [2022/10/26 v2.2x LaTeX Kernel (Final Settings)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltfinal.dtx}
@@ -1085,6 +1085,9 @@
% \changes{v2.2t}{2022/04/21}{Support \cs{noexpand} in argument of \cs{@expl@text@uppercase@@n}}
% \changes{v2.2v}{2022/06/30}{Just use \cs{text_lowercase:n} without \cs{protectd@edf} gh/881x}%
% \changes{v2.2w}{2022/07/04}{Introduced \cs{CaseSwitch}, \cs{DeclareCaseChangeEquivalent} and \cs{MakeTitlecase} to support hooking into case changing gh/889}%
+% \changes{v2.2x}{2022/10/26}{Introduce optional argument for case-changing commands}
+% \changes{v2.2x}{2022/10/26}{Make case changing commands language-aware}
+% \changes{v2.2x}{2022/10/26}{Auto-detect \pkg{babel} locale}
% Wrappers around the L3 case changing functions.
% |\protected| to make them mostly safe as replacements for |uppercase|
% and |\lowercase|.
@@ -1109,12 +1112,55 @@
% functions.
% \begin{macrocode}
\ExplSyntaxOn
-\cs_new_protected_nopar:cpn{MakeUppercase~}{\text_uppercase:n}
-\cs_set_nopar:Npx\MakeUppercase#1{\use:c{MakeUppercase~}{#1}}
-\cs_new_protected_nopar:cpn{MakeLowercase~}{\text_lowercase:n}
-\cs_set_nopar:Npx\MakeLowercase#1{\use:c{MakeLowercase~}{#1}}
-\cs_new_protected_nopar:cpn{MakeTitlecase~}{\text_titlecase:n}
-\cs_set_nopar:Npx\MakeTitlecase#1{\use:c{MakeTitlecase~}{#1}}
+\keys_define:nn { __kernel }
+ {
+ lang .str_set:N = \reserved@a ,
+ locale .str_set:N = \reserved@a
+ }
+\cs_new_protected:Npn \@@text@case@aux #1#2#3
+ {
+ \cs_set_nopar:Npn \reserved@a { }
+ \tl_if_blank:nTF {#2}
+ { \@@text@case@aux@ }
+ { \keys_set:nn { __kernel } {#2} }
+ \use:c { text_ #1 case:Vn } \reserved@a {#3}
+ }
+\cs_new_protected:Npn \@@text@case@aux@ { }
+\tl_gput_right:Nn \@kernel@after@begindocument
+ {
+ \@ifpackageloaded { babel }
+ {
+ \@ifpackagelater { babel } { 2020-01-15 }
+ {
+ \cs_gset_protected:Npn \@@text@case@aux@
+ {
+ \str_set:Nx \reserved@a
+ { \localeinfo* { tag.bcp47 } }
+ }
+ }
+ { }
+ }
+ { }
+ }
+\exp_args_generate:n { cnx }
+% \end{macrocode}
+% The odd use of \emph{three} spaces here is needed as \pkg{ltcmd} uses the
+% name with one and two spaces to give a `friendly' error message for a runaway
+% argument: that means we can't use it here.
+% \begin{macrocode}
+\cs_set_protected:Npn \reserved@a #1
+ {
+ \cs_generate_variant:cn { text_ \str_lowercase:n {#1} case:nn } { V }
+ \cs_new_protected:cpx { Make#1case \c_space_tl \c_space_tl \c_space_tl } [##1] ##2
+ { \exp_not:N \@@text@case@aux { \str_lowercase:n {#1} } {##1} {##2} }
+ \ExpandArgs { cnx } \NewExpandableDocumentCommand
+ { Make#1case }
+ { O{} +m }
+ { \exp_not:c { Make#1case \c_space_tl \c_space_tl \c_space_tl } [####1] {####2} }
+ }
+\reserved@a { Upper }
+\reserved@a { Lower }
+\reserved@a { Title }
% \end{macrocode}
%
% \changes{v2.2u}{2022/06/02}{Add \cs{NoCaseChange}}