summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/l3kernel/l3text-case.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/l3kernel/l3text-case.dtx')
-rw-r--r--macros/latex/contrib/l3kernel/l3text-case.dtx156
1 files changed, 128 insertions, 28 deletions
diff --git a/macros/latex/contrib/l3kernel/l3text-case.dtx b/macros/latex/contrib/l3kernel/l3text-case.dtx
index 9ffd8a140a..887071e393 100644
--- a/macros/latex/contrib/l3kernel/l3text-case.dtx
+++ b/macros/latex/contrib/l3kernel/l3text-case.dtx
@@ -43,7 +43,7 @@
% }^^A
% }
%
-% \date{Released 2022-04-20}
+% \date{Released 2022-04-29}
%
% \maketitle
%
@@ -732,15 +732,15 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}[EXP]{\@@_change_case_upper_de-alt:nnnN}
-% \begin{macro}[EXP]{\@@_change_case_upper_de-alt:nnnNN}
+% \begin{macro}[EXP]{\@@_change_case_upper_de-xeszett:nnnN, \@@_change_case_upper_de-alt:nnnN}
+% \begin{macro}[EXP]{\@@_change_case_upper_de-xeszett:nnnNN}
% A simple alternative version for German.
% \begin{macrocode}
\bool_lazy_or:nnTF
{ \sys_if_engine_luatex_p: }
{ \sys_if_engine_xetex_p: }
{
- \cs_new:cpn { @@_change_case_upper_de-alt:nnnN } #1#2#3#4
+ \cs_new:cpn { @@_change_case_upper_de-xeszett:nnnN } #1#2#3#4
{
\int_compare:nNnTF { `#4 } = { "00DF }
{
@@ -753,16 +753,16 @@
}
}
{
- \cs_new:cpx { @@_change_case_upper_de-alt:nnnN } #1#2#3#4
+ \cs_new:cpx { @@_change_case_upper_de-xeszett:nnnN } #1#2#3#4
{
\exp_not:N \int_compare:nNnTF { `#4 } = { "00C3 }
{
- \exp_not:c { @@_change_case_upper_de-alt:nnnNN }
+ \exp_not:c { @@_change_case_upper_de-xeszett:nnnNN }
{#1} {#2} {#3} #4
}
{ \exp_not:N \@@_change_case_char:nnnN {#1} {#2} {#3} #4 }
}
- \cs_new:cpn { @@_change_case_upper_de-alt:nnnNN } #1#2#3#4#5
+ \cs_new:cpn { @@_change_case_upper_de-xeszett:nnnNN } #1#2#3#4#5
{
\int_compare:nNnTF { `#5 } = { "009F }
{
@@ -772,14 +772,21 @@
{ \@@_change_case_char:nnnN {#1} {#2} {#3} #4#5 }
}
}
+\cs_new_eq:cc { @@_change_case_upper_de-alt:nnnN }
+ { @@_change_case_upper_de-xeszett:nnnN }
% \end{macrocode}
% \end{macro}
% \end{macro}
%
-% \begin{macro}[EXP]{\@@_change_case_upper_el:nnnN}
+% \begin{macro}[EXP]
+% {\@@_change_case_upper_el:nnnN, \@@_change_case_upper_el-xiota:nnnN}
+% \begin{macro}[EXP]
+% {\@@_change_case_upper_el:N, \@@_change_case_upper_el-xiota:N}
% \begin{macro}[EXP]{\@@_change_case_upper_el:nnn}
% \begin{macro}[EXP]{\@@_change_case_upper_el:nnNw}
% \begin{macro}[EXP]{\@@_change_case_upper_el:NnnN}
+% \begin{macro}[EXP]{\@@_change_case_upper_el_ypogegrammeni:Nnnnnw}
+% \begin{macro}[EXP]{\@@_change_case_upper_el_ypogegrammeni:NnnnnN}
% \begin{macro}[EXP]{\@@_change_case_upper_el_dialytika:nnN}
% \begin{macro}[EXP]{\@@_change_case_upper_el_dialytika:N}
% \begin{macro}[EXP]{\@@_change_case_upper_el_hiatus:nnNw}
@@ -791,14 +798,17 @@
% \begin{macro}[EXP,pTF]{\@@_change_case_if_greek_accent:n}
% \begin{macro}[EXP,pTF]{\@@_change_case_if_greek_diacritic:n}
% \begin{macro}[EXP,TF]{\@@_change_case_if_takes_dialytika:n}
+% \begin{macro}[EXP,TF]{\@@_change_case_if_takes_ypogegrammeni:n}
% For Greek uppercasing, we need to know if characters \emph{in the Greek
% range} have accents. That means doing a \textsc{nfd} conversion first, then
% starting a search. As described by the Unicode \textsc{cldr}, Greek accents
% need to be found \emph{after} any U+0308 (diaeresis) and are done in two
% groups to allow for the canonical ordering. The implementation here follows
-% the data and examples from ICU
-% (\url{https://sites.google.com/site/icusite/design/case/greek-upper}),
-% although necessarily the implementation is somewhat different.
+% the data and examples from \textsc{icu}
+% (\url{https://icu.unicode.org/design/case/greek-upper}),
+% although necessarily the implementation is somewhat different. The
+% \emph{ypogegrammeni} is filtered out here as it is not actually in the
+% Greek range, so gets lost if we leave until later.
% \begin{macrocode}
\bool_lazy_or:nnT
{ \sys_if_engine_luatex_p: }
@@ -811,8 +821,27 @@
\exp_args:Ne \@@_change_case_upper_el:nnn
{ \char_to_nfd:N #4 } {#2} {#3}
}
- { \@@_change_case_char:nnnN {#1} {#2} {#3} #4 }
+ {
+ \int_compare:nNnTF { `#4 } = { "0345 }
+ {
+ \@@_change_case_store:e
+ {
+ \use:c { @@_change_case_upper_ #3 :N } #4
+ }
+ \@@_change_case_loop:nnw {#2} {#3}
+ }
+ { \@@_change_case_char:nnnN {#1} {#2} {#3} #4 }
+ }
+ }
+ \cs_new_eq:cN { @@_change_case_upper_el-xiota:nnnN }
+ \@@_change_case_upper_el:nnnN
+ \cs_new:Npn \@@_change_case_upper_el:N #1
+ {
+ \char_generate:nn { "0399 }
+ { \char_value_catcode:n { "0399 } }
}
+ \cs_new:cpn { @@_change_case_upper_el-xiota:N } #1
+ { \exp_not:n {#1} }
\cs_new:Npn \@@_change_case_upper_el:nnn #1#2#3
{ \@@_change_case_upper_el:nnNw {#2} {#3} #1 }
% \end{macrocode}
@@ -833,7 +862,10 @@
% \end{macrocode}
% Now, we check the detail of the next codepoint: again we filter out the
% not-a-char cases, before checking if it's an dialytika, accent or diacritic.
-% (The latter do not have the same hiatus behavior as accents.)
+% (The latter do not have the same hiatus behavior as accents.) There is
+% additional work if the codepoint can take a ypogegrammeni: there, we need
+% to move any ypogegrammeni to after accents (in case the input is not
+% normalised). The ypogegrammeni itself is handled separately.
% \begin{macrocode}
\cs_new:Npn \@@_change_case_upper_el:NnnN #1#2#3#4
{
@@ -843,21 +875,65 @@
\@@_change_case_loop:nnw {#2} {#3} #4
}
{
- \int_compare:nNnTF { `#4 } = { "0308 }
- { \@@_change_case_upper_el_dialytika:nnN {#2} {#3} #1 }
+ \@@_change_case_if_takes_ypogegrammeni:nTF { `#1 }
{
- \@@_change_case_if_greek_accent:nTF { `#4 }
- { \@@_change_case_upper_el_hiatus:nnNw {#2} {#3} #1 }
+ \@@_change_case_upper_el_ypogegrammeni:Nnnnnw
+ #1 {#2} {#3} { } { } #4
+ }
+ { \@@_change_case_upper_el_aux:NnnN #1 {#2} {#3} #4 }
+ }
+ }
+ \cs_new:Npn \@@_change_case_upper_el_ypogegrammeni:Nnnnnw
+ #1#2#3#4#5#6 \q_@@_recursion_stop
+ {
+ \tl_if_head_is_N_type:nTF {#6}
+ {
+ \@@_change_case_upper_el_ypogegrammeni:NnnnnN
+ #1 {#2} {#3} {#4} {#5}
+ }
+ { \@@_change_case_upper_el_aux:NnnN #1 {#2} {#3} #4#5 }
+ #6 \q_@@_recursion_stop
+ }
+ \cs_new:Npn \@@_change_case_upper_el_ypogegrammeni:NnnnnN #1#2#3#4#5#6
+ {
+ \token_if_cs:NTF #6
+ { \@@_change_case_upper_el_aux:NnnN #1 {#2} {#3} #4#5 #6 }
+ {
+ \int_compare:nNnTF { `#6 } = { "0345 }
+ {
+ \@@_change_case_upper_el_ypogegrammeni:Nnnnnw
+ #1 {#2} {#3} {#4} {#6}
+ }
+ {
+ \bool_lazy_or:nnTF
+ { \@@_change_case_if_greek_accent_p:n { `#6 } }
+ { \@@_change_case_if_greek_diacritic_p:n { `#6 } }
{
- \@@_change_case_if_greek_diacritic:nTF { `#4 }
- {
- \@@_change_case_store:e { \char_uppercase:N #1 }
- \@@_change_case_loop:nnw {#2} {#3}
- }
- {
- \@@_change_case_store:e { \char_uppercase:N #1 }
- \@@_change_case_loop:nnw {#2} {#3} #4
- }
+ \@@_change_case_upper_el_ypogegrammeni:Nnnnnw
+ #1 {#2} {#3} {#4#6} {#5}
+ }
+ { \@@_change_case_upper_el_aux:NnnN #1 {#2} {#3} #4#5 #6 }
+ }
+ }
+ }
+ \cs_new:Npn \@@_change_case_upper_el_aux:NnnN #1#2#3#4
+ {
+ \int_compare:nNnTF { `#4 } = { "0308 }
+ { \@@_change_case_upper_el_dialytika:nnN {#2} {#3} #1 }
+ {
+ \@@_change_case_if_greek_accent:nTF { `#4 }
+ { \@@_change_case_upper_el_hiatus:nnNw {#2} {#3} #1 }
+ {
+ \@@_change_case_if_greek_diacritic:nTF { `#4 }
+ {
+ \@@_change_case_store:e { \char_uppercase:N #1 }
+ \@@_change_case_loop:nnw {#2} {#3}
+ }
+ {
+ \int_compare:nNnTF { `#4 } = { "0345 }
+ { \@@_change_case_store:e { [XXX] } }
+ { \@@_change_case_store:e { \char_uppercase:N #1 } }
+ \@@_change_case_loop:nnw {#2} {#3} #4
}
}
}
@@ -949,7 +1025,11 @@
\prg_return_false:
\else:
\if_int_compare:w #1 > "1FFF \exp_stop_f:
- \prg_return_false:
+ \if_int_compare:w #1 = "2126 \exp_stop_f:
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
\else:
\prg_return_true:
\fi:
@@ -1034,7 +1114,23 @@
\fi:
\fi:
\fi:
- }
+ }
+\prg_new_conditional:Npnn \@@_change_case_if_takes_ypogegrammeni:n #1 { TF }
+ {
+ \if_int_compare:w #1 = "03B1 \exp_stop_f:
+ \prg_return_true:
+ \else:
+ \if_int_compare:w #1 = "03B7 \exp_stop_f:
+ \prg_return_true:
+ \else:
+ \if_int_compare:w #1 = "03C9 \exp_stop_f:
+ \prg_return_true:
+ \else:
+ \prg_return_false:
+ \fi:
+ \fi:
+ \fi:
+ }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -1051,6 +1147,10 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
% \begin{macro}[EXP]{\@@_change_case_boundary_upper_el:Nnnw}
% \begin{macro}[EXP]{\@@_change_case_boundary_upper_el:nnN}
% \begin{macro}[EXP]{\@@_change_case_boundary_upper_el:nnNw}