| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% File: l3text-purify.dtx |
| 4 |
% |
| 5 |
% Copyright (C) 2020-2026 The LaTeX Project |
| 6 |
% |
| 7 |
% It may be distributed and/or modified under the conditions of the |
| 8 |
% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 9 |
% license or (at your option) any later version. The latest version |
| 10 |
% of this license is in the file |
| 11 |
% |
| 12 |
% https://www.latex-project.org/lppl.txt |
| 13 |
% |
| 14 |
% This file is part of the "l3kernel bundle" (The Work in LPPL) |
| 15 |
% and all files in that bundle must be distributed together. |
| 16 |
% |
| 17 |
% ----------------------------------------------------------------------- |
| 18 |
% |
| 19 |
% The development version of the bundle can be found at |
| 20 |
% |
| 21 |
% https://github.com/latex3/latex3 |
| 22 |
% |
| 23 |
% for those people who are interested. |
| 24 |
% |
| 25 |
%<*driver> |
| 26 |
\documentclass[full,kernel]{l3doc} |
| 27 |
\begin{document} |
| 28 |
\DocInput{\jobname.dtx} |
| 29 |
\end{document} |
| 30 |
%</driver> |
| 31 |
% \fi |
| 32 |
% |
| 33 |
% \title{^^A |
| 34 |
% The \pkg{l3text-purify} module\\ Text processing (purification)^^A |
| 35 |
% } |
| 36 |
% |
| 37 |
% \author{^^A |
| 38 |
% The \LaTeX{} Project\thanks |
| 39 |
% {^^A |
| 40 |
% E-mail: |
| 41 |
% \href{mailto:[email protected]} |
| 42 |
% {[email protected]}^^A |
| 43 |
% }^^A |
| 44 |
% } |
| 45 |
% |
| 46 |
% \date{Released 2026-05-15} |
| 47 |
% |
| 48 |
% \maketitle |
| 49 |
% |
| 50 |
% \begin{documentation} |
| 51 |
% |
| 52 |
% \end{documentation} |
| 53 |
% |
| 54 |
% \begin{implementation} |
| 55 |
% |
| 56 |
% \section{\pkg{l3text-purify} implementation} |
| 57 |
% |
| 58 |
% \begin{macrocode} |
| 59 |
%<*code> |
| 60 |
% \end{macrocode} |
| 61 |
% |
| 62 |
% \begin{macrocode} |
| 63 |
%<@@=text> |
| 64 |
% \end{macrocode} |
| 65 |
% |
| 66 |
% \subsection{Purifying text} |
| 67 |
% |
| 68 |
% \begin{macro}[EXP]{\@@_if_recursion_tail_stop:N} |
| 69 |
% Functions to query recursion quarks. |
| 70 |
% \begin{macrocode} |
| 71 |
\__kernel_quark_new_test:N \@@_if_recursion_tail_stop:N |
| 72 |
% \end{macrocode} |
| 73 |
% \end{macro} |
| 74 |
% |
| 75 |
% \begin{macro}[EXP]{\text_purify:n, \text_purify:V, \text_purify:v, \@@_purify:n} |
| 76 |
% \begin{macro}[EXP]{\@@_purify_store:n} |
| 77 |
% \begin{macro}[EXP]{\@@_purify_store:nw} |
| 78 |
% \begin{macro}[EXP]{\@@_purify_end:w} |
| 79 |
% \begin{macro}[EXP]{\@@_purify_loop:w} |
| 80 |
% \begin{macro}[EXP]{\@@_purify_group:n} |
| 81 |
% \begin{macro}[EXP]{\@@_purify_space:w} |
| 82 |
% \begin{macro}[EXP]{\@@_purify_N_type:N, \@@_purify_N_type_aux:N} |
| 83 |
% \begin{macro}[EXP]{\@@_purify_math_search:NNN} |
| 84 |
% \begin{macro}[EXP]{\@@_purify_math_start:NNw} |
| 85 |
% \begin{macro}[EXP]{\@@_purify_math_store:n} |
| 86 |
% \begin{macro}[EXP]{\@@_purify_math_store:nw} |
| 87 |
% \begin{macro}[EXP]{\@@_purify_math_end:w} |
| 88 |
% \begin{macro}[EXP]{\@@_purify_math_loop:NNw} |
| 89 |
% \begin{macro}[EXP]{\@@_purify_math_N_type:NNN} |
| 90 |
% \begin{macro}[EXP]{\@@_purify_math_group:NNn} |
| 91 |
% \begin{macro}[EXP]{\@@_purify_math_space:NNw} |
| 92 |
% \begin{macro}[EXP]{\@@_purify_math_cmd:N} |
| 93 |
% \begin{macro}[EXP]{\@@_purify_math_cmd:NN} |
| 94 |
% \begin{macro}[EXP]{\@@_purify_math_cmd:Nn} |
| 95 |
% \begin{macro}[EXP]{\@@_purify_replace:N} |
| 96 |
% \begin{macro}[EXP] |
| 97 |
% { |
| 98 |
% \@@_purify_replace_auxi:n , |
| 99 |
% \@@_purify_replace_auxi:v , |
| 100 |
% \@@_purify_replace_auxii:n |
| 101 |
% } |
| 102 |
% \begin{macro}[EXP]{\@@_purify_expand:N, \@@_purify_protect:N, \@@_purify_encoding:N} |
| 103 |
% \begin{macro}[EXP]{\@@_purify_encoding_escape:NN} |
| 104 |
% As in the other parts of the module, we start off with a standard |
| 105 |
% \enquote{action} loop, with expansion applied up-front. |
| 106 |
% \begin{macrocode} |
| 107 |
\cs_new:Npn \text_purify:n #1 |
| 108 |
{ |
| 109 |
\__kernel_exp_not:w \exp_after:wN |
| 110 |
{ |
| 111 |
\exp:w |
| 112 |
\exp_args:Ne \@@_purify:n |
| 113 |
{ \text_expand:n {#1} } |
| 114 |
} |
| 115 |
} |
| 116 |
\cs_generate_variant:Nn \text_purify:n { V , v } |
| 117 |
\cs_new:Npn \@@_purify:n #1 |
| 118 |
{ |
| 119 |
\group_align_safe_begin: |
| 120 |
\@@_purify_loop:w #1 |
| 121 |
\q_@@_recursion_tail \q_@@_recursion_stop |
| 122 |
\@@_purify_result:n { } |
| 123 |
} |
| 124 |
% \end{macrocode} |
| 125 |
% As for expansion, collect up the tokens for future use. |
| 126 |
% \begin{macrocode} |
| 127 |
\cs_new:Npn \@@_purify_store:n #1 |
| 128 |
{ \@@_purify_store:nw {#1} } |
| 129 |
\cs_new:Npn \@@_purify_store:nw #1#2 \@@_purify_result:n #3 |
| 130 |
{ #2 \@@_purify_result:n { #3 #1 } } |
| 131 |
\cs_new:Npn \@@_purify_end:w #1 \@@_purify_result:n #2 |
| 132 |
{ |
| 133 |
\group_align_safe_end: |
| 134 |
\exp_end: |
| 135 |
#2 |
| 136 |
} |
| 137 |
% \end{macrocode} |
| 138 |
% The main loop is a standard \enquote{tl action}. Unlike the expansion |
| 139 |
% or case changing, here any groups have to be run inline. Most of the |
| 140 |
% business end is as before in the \texttt{N}-type token processing. |
| 141 |
% \begin{macrocode} |
| 142 |
\cs_new:Npn \@@_purify_loop:w #1 \q_@@_recursion_stop |
| 143 |
{ |
| 144 |
\tl_if_head_is_N_type:nTF {#1} |
| 145 |
{ \@@_purify_N_type:N } |
| 146 |
{ |
| 147 |
\tl_if_head_is_group:nTF {#1} |
| 148 |
{ \@@_purify_group:n } |
| 149 |
{ \@@_purify_space:w } |
| 150 |
} |
| 151 |
#1 \q_@@_recursion_stop |
| 152 |
} |
| 153 |
\cs_new:Npn \@@_purify_group:n #1 { \@@_purify_loop:w #1 } |
| 154 |
\exp_last_unbraced:NNo \cs_new:Npn \@@_purify_space:w \c_space_tl |
| 155 |
{ |
| 156 |
\@@_purify_store:n { ~ } |
| 157 |
\@@_purify_loop:w |
| 158 |
} |
| 159 |
% \end{macrocode} |
| 160 |
% The first part of handling math mode is exactly the same as in the |
| 161 |
% other functions: look for a start-of-math mode token and if found start |
| 162 |
% a new loop tracking the closing token. |
| 163 |
% \begin{macrocode} |
| 164 |
\cs_new:Npn \@@_purify_N_type:N #1 |
| 165 |
{ |
| 166 |
\@@_if_q_recursion_tail_stop_do:Nn #1 { \@@_purify_end:w } |
| 167 |
\@@_purify_N_type_aux:N #1 |
| 168 |
} |
| 169 |
\cs_new:Npn \@@_purify_N_type_aux:N #1 |
| 170 |
{ |
| 171 |
\exp_after:wN \@@_purify_math_search:NNN |
| 172 |
\exp_after:wN #1 \l_text_math_delims_tl |
| 173 |
\q_@@_recursion_tail ? |
| 174 |
\q_@@_recursion_stop |
| 175 |
} |
| 176 |
\cs_new:Npn \@@_purify_math_search:NNN #1#2#3 |
| 177 |
{ |
| 178 |
\@@_if_q_recursion_tail_stop_do:Nn #2 |
| 179 |
{ \@@_purify_math_cmd:N #1 } |
| 180 |
\token_if_eq_meaning:NNTF #1 #2 |
| 181 |
{ |
| 182 |
\@@_use_i_delimit_by_q_recursion_stop:nw |
| 183 |
{ \@@_purify_math_start:NNw #2 #3 } |
| 184 |
} |
| 185 |
{ \@@_purify_math_search:NNN #1 } |
| 186 |
} |
| 187 |
\cs_new:Npn \@@_purify_math_start:NNw #1#2#3 \q_@@_recursion_stop |
| 188 |
{ |
| 189 |
\@@_purify_math_loop:NNw #1#2#3 \q_@@_recursion_stop |
| 190 |
\@@_purify_math_result:n { } |
| 191 |
} |
| 192 |
\cs_new:Npn \@@_purify_math_store:n #1 |
| 193 |
{ \@@_purify_math_store:nw {#1} } |
| 194 |
\cs_new:Npn \@@_purify_math_store:nw #1#2 \@@_purify_math_result:n #3 |
| 195 |
{ #2 \@@_purify_math_result:n { #3 #1 } } |
| 196 |
\cs_new:Npn \@@_purify_math_end:w #1 \@@_purify_math_result:n #2 |
| 197 |
{ |
| 198 |
\@@_purify_store:n { $ #2 $ } |
| 199 |
\@@_purify_loop:w #1 |
| 200 |
} |
| 201 |
\cs_new:Npn \@@_purify_math_stop:Nw #1 \@@_purify_math_result:n #2 |
| 202 |
{ |
| 203 |
\@@_purify_store:n {#1#2} |
| 204 |
\@@_purify_end:w |
| 205 |
} |
| 206 |
\cs_new:Npn \@@_purify_math_loop:NNw #1#2#3 \q_@@_recursion_stop |
| 207 |
{ |
| 208 |
\tl_if_head_is_N_type:nTF {#3} |
| 209 |
{ \@@_purify_math_N_type:NNN } |
| 210 |
{ |
| 211 |
\tl_if_head_is_group:nTF {#3} |
| 212 |
{ \@@_purify_math_group:NNn } |
| 213 |
{ \@@_purify_math_space:NNw } |
| 214 |
} |
| 215 |
#1#2#3 \q_@@_recursion_stop |
| 216 |
} |
| 217 |
\cs_new:Npn \@@_purify_math_N_type:NNN #1#2#3 |
| 218 |
{ |
| 219 |
\@@_if_q_recursion_tail_stop_do:Nn #3 |
| 220 |
{ \@@_purify_math_stop:Nw #1 } |
| 221 |
\token_if_eq_meaning:NNTF #3 #2 |
| 222 |
{ \@@_purify_math_end:w } |
| 223 |
{ |
| 224 |
\@@_purify_math_store:n {#3} |
| 225 |
\@@_purify_math_loop:NNw #1#2 |
| 226 |
} |
| 227 |
} |
| 228 |
\cs_new:Npn \@@_purify_math_group:NNn #1#2#3 |
| 229 |
{ |
| 230 |
\@@_purify_math_store:n { {#3} } |
| 231 |
\@@_purify_math_loop:NNw #1#2 |
| 232 |
} |
| 233 |
\exp_after:wN \cs_new:Npn \exp_after:wN \@@_purify_math_space:NNw |
| 234 |
\exp_after:wN # \exp_after:wN 1 |
| 235 |
\exp_after:wN # \exp_after:wN 2 \c_space_tl |
| 236 |
{ |
| 237 |
\@@_purify_math_store:n { ~ } |
| 238 |
\@@_purify_math_loop:NNw #1#2 |
| 239 |
} |
| 240 |
% \end{macrocode} |
| 241 |
% Then handle math mode as an argument: same outcomes, different input |
| 242 |
% syntax. |
| 243 |
% \begin{macrocode} |
| 244 |
\cs_new:Npn \@@_purify_math_cmd:N #1 |
| 245 |
{ |
| 246 |
\exp_after:wN \@@_purify_math_cmd:NN \exp_after:wN #1 |
| 247 |
\l_text_math_arg_tl \q_@@_recursion_tail \q_@@_recursion_stop |
| 248 |
} |
| 249 |
\cs_new:Npn \@@_purify_math_cmd:NN #1#2 |
| 250 |
{ |
| 251 |
\@@_if_q_recursion_tail_stop_do:Nn #2 |
| 252 |
{ \@@_purify_replace:N #1 } |
| 253 |
\cs_if_eq:NNTF #2 #1 |
| 254 |
{ |
| 255 |
\@@_use_i_delimit_by_q_recursion_stop:nw |
| 256 |
{ \@@_purify_math_cmd:n } |
| 257 |
} |
| 258 |
{ \@@_purify_math_cmd:NN #1 } |
| 259 |
} |
| 260 |
\cs_new:Npn \@@_purify_math_cmd:n #1 |
| 261 |
{ \@@_purify_math_end:w \@@_purify_math_result:n {#1} } |
| 262 |
% \end{macrocode} |
| 263 |
% For \texttt{N}-type tokens, we first look for a string-context replacement |
| 264 |
% before anything else: this can therefore cover anything. Assuming we don't |
| 265 |
% find one, check to see if we can expand control sequences: if not, they have |
| 266 |
% to be dropped. We also allow for \LaTeXe{} \tn{protect}: there's an |
| 267 |
% assumption that we don't have |\protect { \oops }| or similar, but that's |
| 268 |
% also in the expansion code and seems like a reasonable balance. Notice that |
| 269 |
% we filter out implicit begin/end group tokens to avoid issues. |
| 270 |
% \begin{macrocode} |
| 271 |
\cs_new:Npn \@@_purify_replace:N #1 |
| 272 |
{ |
| 273 |
\bool_lazy_and:nnTF |
| 274 |
{ \cs_if_exist_p:c { l_@@_purify_ \token_to_str:N #1 _tl } } |
| 275 |
{ |
| 276 |
\bool_lazy_or_p:nn |
| 277 |
{ \token_if_cs_p:N #1 } |
| 278 |
{ \token_if_active_p:N #1 } |
| 279 |
} |
| 280 |
{ |
| 281 |
\@@_purify_replace_auxi:v |
| 282 |
{ l_@@_purify_ \token_to_str:N #1 _tl } |
| 283 |
} |
| 284 |
{ |
| 285 |
\bool_lazy_or:nnTF |
| 286 |
{ \token_if_group_begin_p:N #1 } |
| 287 |
{ \token_if_group_end_p:N #1 } |
| 288 |
{ \@@_purify_loop:w } |
| 289 |
{ |
| 290 |
\exp_args:Ne \@@_purify_replace_auxii:n |
| 291 |
{ \@@_token_to_explicit:N #1 } |
| 292 |
} |
| 293 |
} |
| 294 |
} |
| 295 |
\cs_new:Npn \@@_purify_replace_auxi:n #1 { \@@_purify_loop:w #1 } |
| 296 |
\cs_generate_variant:Nn \@@_purify_replace_auxi:n { v } |
| 297 |
\cs_new:Npn \@@_purify_replace_auxii:n #1 |
| 298 |
{ |
| 299 |
\token_if_cs:NTF #1 |
| 300 |
{ \@@_purify_expand:N #1 } |
| 301 |
{ |
| 302 |
\@@_purify_store:n {#1} |
| 303 |
\@@_purify_loop:w |
| 304 |
} |
| 305 |
} |
| 306 |
\cs_new:Npn \@@_purify_expand:N #1 |
| 307 |
{ |
| 308 |
\str_if_eq:nnTF {#1} { \protect } |
| 309 |
{ \@@_purify_protect:N } |
| 310 |
{ \@@_purify_encoding:N #1 } |
| 311 |
} |
| 312 |
% \end{macrocode} |
| 313 |
% We grab the token immediately after a \cs{protect} with the expectation |
| 314 |
% that it is \texttt{N}-type. Whilst it shouldn't happen, this could be |
| 315 |
% end-of-loop so there's a safety test for that. If there is some purification |
| 316 |
% equivalent, we use it, but otherwise simply drop the token. |
| 317 |
% \begin{macrocode} |
| 318 |
\cs_new:Npn \@@_purify_protect:N #1 |
| 319 |
{ |
| 320 |
\@@_if_q_recursion_tail_stop_do:Nn #1 { \@@_purify_end:w } |
| 321 |
\cs_if_exist:cTF { l_@@_purify_ \token_to_str:N #1 _tl } |
| 322 |
{ |
| 323 |
\@@_purify_replace_auxi:v |
| 324 |
{ l_@@_purify_ \token_to_str:N #1 _tl } |
| 325 |
} |
| 326 |
{ \@@_purify_loop:w } |
| 327 |
} |
| 328 |
% \end{macrocode} |
| 329 |
% Handle encoding commands, as detailed for expansion. |
| 330 |
% \begin{macrocode} |
| 331 |
\cs_new:Npn \@@_purify_encoding:N #1 |
| 332 |
{ |
| 333 |
\bool_lazy_or:nnTF |
| 334 |
{ \cs_if_eq_p:NN #1 \@current@cmd } |
| 335 |
{ \cs_if_eq_p:NN #1 \@changed@cmd } |
| 336 |
{ \@@_purify_encoding_escape:NN } |
| 337 |
{ |
| 338 |
\@@_if_expandable:NTF #1 |
| 339 |
{ \exp_after:wN \@@_purify_loop:w #1 } |
| 340 |
{ \@@_purify_loop:w } |
| 341 |
} |
| 342 |
} |
| 343 |
\cs_new:Npn \@@_purify_encoding_escape:NN #1#2 |
| 344 |
{ |
| 345 |
\@@_purify_store:n {#1} |
| 346 |
\@@_purify_loop:w |
| 347 |
} |
| 348 |
% \end{macrocode} |
| 349 |
% \end{macro} |
| 350 |
% \end{macro} |
| 351 |
% \end{macro} |
| 352 |
% \end{macro} |
| 353 |
% \end{macro} |
| 354 |
% \end{macro} |
| 355 |
% \end{macro} |
| 356 |
% \end{macro} |
| 357 |
% \end{macro} |
| 358 |
% \end{macro} |
| 359 |
% \end{macro} |
| 360 |
% \end{macro} |
| 361 |
% \end{macro} |
| 362 |
% \end{macro} |
| 363 |
% \end{macro} |
| 364 |
% \end{macro} |
| 365 |
% \end{macro} |
| 366 |
% \end{macro} |
| 367 |
% \end{macro} |
| 368 |
% \end{macro} |
| 369 |
% \end{macro} |
| 370 |
% \end{macro} |
| 371 |
% \end{macro} |
| 372 |
% \end{macro} |
| 373 |
% |
| 374 |
% \begin{macro} |
| 375 |
% { |
| 376 |
% \text_declare_purify_equivalent:Nn, |
| 377 |
% \text_declare_purify_equivalent:Ne |
| 378 |
% } |
| 379 |
% \begin{macrocode} |
| 380 |
\cs_new_protected:Npn \text_declare_purify_equivalent:Nn #1#2 |
| 381 |
{ |
| 382 |
\tl_clear_new:c { l_@@_purify_ \token_to_str:N #1 _tl } |
| 383 |
\tl_set:cn { l_@@_purify_ \token_to_str:N #1 _tl } {#2} |
| 384 |
} |
| 385 |
\cs_generate_variant:Nn \text_declare_purify_equivalent:Nn { Ne } |
| 386 |
% \end{macrocode} |
| 387 |
% \end{macro} |
| 388 |
% |
| 389 |
% Now pre-define a range of standard commands that need dedicated definitions |
| 390 |
% in purified text. First handle font-related stuff: all of this needs to be |
| 391 |
% disabled. |
| 392 |
% \begin{macrocode} |
| 393 |
\tl_map_inline:nn |
| 394 |
{ |
| 395 |
\fontencoding |
| 396 |
\fontfamily |
| 397 |
\fontseries |
| 398 |
\fontshape |
| 399 |
} |
| 400 |
{ \text_declare_purify_equivalent:Nn #1 { \use_none:n } } |
| 401 |
\text_declare_purify_equivalent:Nn \fontsize { \use_none:nn } |
| 402 |
\text_declare_purify_equivalent:Nn \selectfont { } |
| 403 |
\text_declare_purify_equivalent:Nn \usefont { \use_none:nnnn } |
| 404 |
\exp_args:Nc \text_declare_purify_equivalent:Nn |
| 405 |
{ @protected@testopt } { \use_none:nnn } |
| 406 |
% \end{macrocode} |
| 407 |
% Environments have to be handled by pure expansion. |
| 408 |
% |
| 409 |
% \begin{macro}{\@@_end_env:n} |
| 410 |
% \begin{macrocode} |
| 411 |
\text_declare_purify_equivalent:Nn \begin { \use:c } |
| 412 |
\text_declare_purify_equivalent:Nn \end { \@@_end_env:n } |
| 413 |
\cs_new:Npn \@@_end_env:n #1 { \cs:w end #1 \cs_end: } |
| 414 |
% \end{macrocode} |
| 415 |
% \end{macro} |
| 416 |
% |
| 417 |
% Some common symbols and similar ideas. |
| 418 |
% \begin{macrocode} |
| 419 |
\text_declare_purify_equivalent:Nn \\ { } |
| 420 |
\tl_map_inline:nn |
| 421 |
{ \{ \} \# \$ \% \_ } |
| 422 |
{ \text_declare_purify_equivalent:Ne #1 { \cs_to_str:N #1 } } |
| 423 |
% \end{macrocode} |
| 424 |
% Cross-referencing. |
| 425 |
% \begin{macrocode} |
| 426 |
\text_declare_purify_equivalent:Nn \label { \use_none:n } |
| 427 |
% \end{macrocode} |
| 428 |
% Spaces. |
| 429 |
% \begin{macrocode} |
| 430 |
\group_begin: |
| 431 |
\char_set_catcode_active:N \~ |
| 432 |
\use:n |
| 433 |
{ |
| 434 |
\group_end: |
| 435 |
\text_declare_purify_equivalent:Ne ~ { \c_space_tl } |
| 436 |
} |
| 437 |
\text_declare_purify_equivalent:Nn \nobreakspace { ~ } |
| 438 |
\text_declare_purify_equivalent:Nn \ { ~ } |
| 439 |
\text_declare_purify_equivalent:Nn \, { ~ } |
| 440 |
% \end{macrocode} |
| 441 |
% |
| 442 |
% \subsection{Accent and letter-like data for purifying text} |
| 443 |
% |
| 444 |
% In contrast to case changing, both $8$-bit and Unicode engines need |
| 445 |
% information for text purification to handle accents and letter-like |
| 446 |
% functions: these all need to be removed. However, the results are |
| 447 |
% of course engine-dependent. |
| 448 |
% |
| 449 |
% For the letter-like commands, life is relatively easy: they are all |
| 450 |
% simply added as standard exceptions. The only oddity is \tn{SS}, which |
| 451 |
% gets converted to two letters. (At some stage an alternative version |
| 452 |
% can presumably be added to \pkg{babel} or similar.) |
| 453 |
% \begin{macrocode} |
| 454 |
\cs_set_protected:Npn \@@_loop:Nn #1#2 |
| 455 |
{ |
| 456 |
\quark_if_recursion_tail_stop:N #1 |
| 457 |
\text_declare_purify_equivalent:Ne #1 |
| 458 |
{ |
| 459 |
\codepoint_generate:nn {"#2} |
| 460 |
{ \char_value_catcode:n {"#2} } |
| 461 |
} |
| 462 |
\@@_loop:Nn |
| 463 |
} |
| 464 |
\@@_loop:Nn |
| 465 |
\AA { 00C5 } |
| 466 |
\AE { 00C6 } |
| 467 |
\DH { 00D0 } |
| 468 |
\DJ { 0110 } |
| 469 |
\IJ { 0132 } |
| 470 |
\L { 0141 } |
| 471 |
\NG { 014A } |
| 472 |
\O { 00D8 } |
| 473 |
\OE { 0152 } |
| 474 |
\TH { 00DE } |
| 475 |
\aa { 00E5 } |
| 476 |
\ae { 00E6 } |
| 477 |
\dh { 00F0 } |
| 478 |
\dj { 0111 } |
| 479 |
\i { 0131 } |
| 480 |
\j { 0237 } |
| 481 |
\ij { 0132 } |
| 482 |
\l { 0142 } |
| 483 |
\ng { 014B } |
| 484 |
\o { 00F8 } |
| 485 |
\oe { 0153 } |
| 486 |
\ss { 00DF } |
| 487 |
\th { 00FE } |
| 488 |
\q_recursion_tail ? |
| 489 |
\q_recursion_stop |
| 490 |
\text_declare_purify_equivalent:Nn \SS { SS } |
| 491 |
% \end{macrocode} |
| 492 |
% |
| 493 |
% \begin{macro}[rEXP]{\@@_purify_accent:NN} |
| 494 |
% Accent \textsc{licr} handling is a little more complex. Accents may exist |
| 495 |
% as pre-composed codepoints or as independent glyphs. The former are all |
| 496 |
% saved as single token lists, whilst for the latter the combining accent |
| 497 |
% needs to be re-ordered compared to the character it applies to. |
| 498 |
% \begin{macrocode} |
| 499 |
\cs_new:Npn \@@_purify_accent:NN #1#2 |
| 500 |
{ |
| 501 |
\cs_if_exist:cTF |
| 502 |
{ c_@@_purify_ \token_to_str:N #1 _ \token_to_str:N #2 _tl } |
| 503 |
{ |
| 504 |
\exp_not:v |
| 505 |
{ c_@@_purify_ \token_to_str:N #1 _ \token_to_str:N #2 _tl } |
| 506 |
} |
| 507 |
{ |
| 508 |
\exp_not:n {#2} |
| 509 |
\exp_not:v { c_@@_purify_ \token_to_str:N #1 _tl } |
| 510 |
} |
| 511 |
} |
| 512 |
\tl_map_inline:nn { \` \' \^ \~ \= \u \. \" \r \H \v \d \c \k \b \t } |
| 513 |
{ \text_declare_purify_equivalent:Nn #1 { \@@_purify_accent:NN #1 } } |
| 514 |
% \end{macrocode} |
| 515 |
% First set up the combining accents. |
| 516 |
% \begin{macrocode} |
| 517 |
\group_begin: |
| 518 |
\cs_set_protected:Npn \@@_loop:Nn #1#2 |
| 519 |
{ |
| 520 |
\quark_if_recursion_tail_stop:N #1 |
| 521 |
\tl_const:ce { c_@@_purify_ \token_to_str:N #1 _tl } |
| 522 |
{ \codepoint_generate:nn {"#2} { \char_value_catcode:n { "#2 } } } |
| 523 |
\@@_loop:Nn |
| 524 |
} |
| 525 |
\@@_loop:Nn |
| 526 |
\` { 0300 } |
| 527 |
\' { 0301 } |
| 528 |
\^ { 0302 } |
| 529 |
\~ { 0303 } |
| 530 |
\= { 0304 } |
| 531 |
\u { 0306 } |
| 532 |
\. { 0307 } |
| 533 |
\" { 0308 } |
| 534 |
\r { 030A } |
| 535 |
\H { 030B } |
| 536 |
\v { 030C } |
| 537 |
\d { 0323 } |
| 538 |
\c { 0327 } |
| 539 |
\k { 0328 } |
| 540 |
\b { 0331 } |
| 541 |
\t { 0361 } |
| 542 |
\q_recursion_tail { } |
| 543 |
\q_recursion_stop |
| 544 |
% \end{macrocode} |
| 545 |
% Now we handle the pre-composed accents: the list here is taken from |
| 546 |
% \texttt{puenc.def}. All of the precomposed cases take a single letter |
| 547 |
% as their second argument. We do not try to cover the case where an accent |
| 548 |
% is added to a \enquote{real} dotless-i or -j, or a \ae/\AE. Rather, we |
| 549 |
% assume that if the \textsc{utf}-8 character is used, it will have the |
| 550 |
% real accent character too. |
| 551 |
% \begin{macrocode} |
| 552 |
\cs_set_protected:Npn \@@_loop:NNn #1#2#3 |
| 553 |
{ |
| 554 |
\quark_if_recursion_tail_stop:N #1 |
| 555 |
\tl_const:ce |
| 556 |
{ c_@@_purify_ \token_to_str:N #1 _ \token_to_str:N #2 _tl } |
| 557 |
{ \codepoint_generate:nn {"#3} { \char_value_catcode:n { "#3 } } } |
| 558 |
\@@_loop:NNn |
| 559 |
} |
| 560 |
\@@_loop:NNn |
| 561 |
\` A { 00C0 } |
| 562 |
\' A { 00C1 } |
| 563 |
\^ A { 00C2 } |
| 564 |
\~ A { 00C3 } |
| 565 |
\" A { 00C4 } |
| 566 |
\r A { 00C5 } |
| 567 |
\c C { 00C7 } |
| 568 |
\` E { 00C8 } |
| 569 |
\' E { 00C9 } |
| 570 |
\^ E { 00CA } |
| 571 |
\" E { 00CB } |
| 572 |
\` I { 00CC } |
| 573 |
\' I { 00CD } |
| 574 |
\^ I { 00CE } |
| 575 |
\" I { 00CF } |
| 576 |
\~ N { 00D1 } |
| 577 |
\` O { 00D2 } |
| 578 |
\' O { 00D3 } |
| 579 |
\^ O { 00D4 } |
| 580 |
\~ O { 00D5 } |
| 581 |
\" O { 00D6 } |
| 582 |
\` U { 00D9 } |
| 583 |
\' U { 00DA } |
| 584 |
\^ U { 00DB } |
| 585 |
\" U { 00DC } |
| 586 |
\' Y { 00DD } |
| 587 |
\` a { 00E0 } |
| 588 |
\' a { 00E1 } |
| 589 |
\^ a { 00E2 } |
| 590 |
\~ a { 00E3 } |
| 591 |
\" a { 00E4 } |
| 592 |
\r a { 00E5 } |
| 593 |
\c c { 00E7 } |
| 594 |
\` e { 00E8 } |
| 595 |
\' e { 00E9 } |
| 596 |
\^ e { 00EA } |
| 597 |
\" e { 00EB } |
| 598 |
\` i { 00EC } |
| 599 |
\` \i { 00EC } |
| 600 |
\' i { 00ED } |
| 601 |
\' \i { 00ED } |
| 602 |
\^ i { 00EE } |
| 603 |
\^ \i { 00EE } |
| 604 |
\" i { 00EF } |
| 605 |
\" \i { 00EF } |
| 606 |
\~ n { 00F1 } |
| 607 |
\` o { 00F2 } |
| 608 |
\' o { 00F3 } |
| 609 |
\^ o { 00F4 } |
| 610 |
\~ o { 00F5 } |
| 611 |
\" o { 00F6 } |
| 612 |
\` u { 00F9 } |
| 613 |
\' u { 00FA } |
| 614 |
\^ u { 00FB } |
| 615 |
\" u { 00FC } |
| 616 |
\' y { 00FD } |
| 617 |
\" y { 00FF } |
| 618 |
\= A { 0100 } |
| 619 |
\= a { 0101 } |
| 620 |
\u A { 0102 } |
| 621 |
\u a { 0103 } |
| 622 |
\k A { 0104 } |
| 623 |
\k a { 0105 } |
| 624 |
\' C { 0106 } |
| 625 |
\' c { 0107 } |
| 626 |
\^ C { 0108 } |
| 627 |
\^ c { 0109 } |
| 628 |
\. C { 010A } |
| 629 |
\. c { 010B } |
| 630 |
\v C { 010C } |
| 631 |
\v c { 010D } |
| 632 |
\v D { 010E } |
| 633 |
\v d { 010F } |
| 634 |
\= E { 0112 } |
| 635 |
\= e { 0113 } |
| 636 |
\u E { 0114 } |
| 637 |
\u e { 0115 } |
| 638 |
\. E { 0116 } |
| 639 |
\. e { 0117 } |
| 640 |
\k E { 0118 } |
| 641 |
\k e { 0119 } |
| 642 |
\v E { 011A } |
| 643 |
\v e { 011B } |
| 644 |
\^ G { 011C } |
| 645 |
\^ g { 011D } |
| 646 |
\u G { 011E } |
| 647 |
\u g { 011F } |
| 648 |
\. G { 0120 } |
| 649 |
\. g { 0121 } |
| 650 |
\c G { 0122 } |
| 651 |
\c g { 0123 } |
| 652 |
\^ H { 0124 } |
| 653 |
\^ h { 0125 } |
| 654 |
\~ I { 0128 } |
| 655 |
\~ i { 0129 } |
| 656 |
\~ \i { 0129 } |
| 657 |
\= I { 012A } |
| 658 |
\= i { 012B } |
| 659 |
\= \i { 012B } |
| 660 |
\u I { 012C } |
| 661 |
\u i { 012D } |
| 662 |
\u \i { 012D } |
| 663 |
\k I { 012E } |
| 664 |
\k i { 012F } |
| 665 |
\k \i { 012F } |
| 666 |
\. I { 0130 } |
| 667 |
\^ J { 0134 } |
| 668 |
\^ j { 0135 } |
| 669 |
\^ \j { 0135 } |
| 670 |
\c K { 0136 } |
| 671 |
\c k { 0137 } |
| 672 |
\' L { 0139 } |
| 673 |
\' l { 013A } |
| 674 |
\c L { 013B } |
| 675 |
\c l { 013C } |
| 676 |
\v L { 013D } |
| 677 |
\v l { 013E } |
| 678 |
\. L { 013F } |
| 679 |
\. l { 0140 } |
| 680 |
\' N { 0143 } |
| 681 |
\' n { 0144 } |
| 682 |
\c N { 0145 } |
| 683 |
\c n { 0146 } |
| 684 |
\v N { 0147 } |
| 685 |
\v n { 0148 } |
| 686 |
\= O { 014C } |
| 687 |
\= o { 014D } |
| 688 |
\u O { 014E } |
| 689 |
\u o { 014F } |
| 690 |
\H O { 0150 } |
| 691 |
\H o { 0151 } |
| 692 |
\' R { 0154 } |
| 693 |
\' r { 0155 } |
| 694 |
\c R { 0156 } |
| 695 |
\c r { 0157 } |
| 696 |
\v R { 0158 } |
| 697 |
\v r { 0159 } |
| 698 |
\' S { 015A } |
| 699 |
\' s { 015B } |
| 700 |
\^ S { 015C } |
| 701 |
\^ s { 015D } |
| 702 |
\c S { 015E } |
| 703 |
\c s { 015F } |
| 704 |
\v S { 0160 } |
| 705 |
\v s { 0161 } |
| 706 |
\c T { 0162 } |
| 707 |
\c t { 0163 } |
| 708 |
\v T { 0164 } |
| 709 |
\v t { 0165 } |
| 710 |
\~ U { 0168 } |
| 711 |
\~ u { 0169 } |
| 712 |
\= U { 016A } |
| 713 |
\= u { 016B } |
| 714 |
\u U { 016C } |
| 715 |
\u u { 016D } |
| 716 |
\r U { 016E } |
| 717 |
\r u { 016F } |
| 718 |
\H U { 0170 } |
| 719 |
\H u { 0171 } |
| 720 |
\k U { 0172 } |
| 721 |
\k u { 0173 } |
| 722 |
\^ W { 0174 } |
| 723 |
\^ w { 0175 } |
| 724 |
\^ Y { 0176 } |
| 725 |
\^ y { 0177 } |
| 726 |
\" Y { 0178 } |
| 727 |
\' Z { 0179 } |
| 728 |
\' z { 017A } |
| 729 |
\. Z { 017B } |
| 730 |
\. z { 017C } |
| 731 |
\v Z { 017D } |
| 732 |
\v z { 017E } |
| 733 |
\v A { 01CD } |
| 734 |
\v a { 01CE } |
| 735 |
\v I { 01CF } |
| 736 |
\v \i { 01D0 } |
| 737 |
\v i { 01D0 } |
| 738 |
\v O { 01D1 } |
| 739 |
\v o { 01D2 } |
| 740 |
\v U { 01D3 } |
| 741 |
\v u { 01D4 } |
| 742 |
\v G { 01E6 } |
| 743 |
\v g { 01E7 } |
| 744 |
\v K { 01E8 } |
| 745 |
\v k { 01E9 } |
| 746 |
\k O { 01EA } |
| 747 |
\k o { 01EB } |
| 748 |
\v \j { 01F0 } |
| 749 |
\v j { 01F0 } |
| 750 |
\' G { 01F4 } |
| 751 |
\' g { 01F5 } |
| 752 |
\` N { 01F8 } |
| 753 |
\` n { 01F9 } |
| 754 |
\' \AE { 01FC } |
| 755 |
\' \ae { 01FD } |
| 756 |
\' \O { 01FE } |
| 757 |
\' \o { 01FF } |
| 758 |
\v H { 021E } |
| 759 |
\v h { 021F } |
| 760 |
\. A { 0226 } |
| 761 |
\. a { 0227 } |
| 762 |
\c E { 0228 } |
| 763 |
\c e { 0229 } |
| 764 |
\. O { 022E } |
| 765 |
\. o { 022F } |
| 766 |
\= Y { 0232 } |
| 767 |
\= y { 0233 } |
| 768 |
\q_recursion_tail ? { } |
| 769 |
\q_recursion_stop |
| 770 |
\group_end: |
| 771 |
% \end{macrocode} |
| 772 |
% \end{macro} |
| 773 |
% |
| 774 |
% \begin{macrocode} |
| 775 |
%</code> |
| 776 |
% \end{macrocode} |
| 777 |
% |
| 778 |
% \end{implementation} |
| 779 |
% |
| 780 |
% \PrintIndex |