From 501719bfed98b8d0f17c48707c4e58999f742f0f Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 11 Nov 2023 21:12:10 +0000 Subject: babel (11nov23) git-svn-id: svn://tug.org/texlive/trunk@68816 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/source/latex/babel/babel.dtx | 240 ++++++++++++++++++++-- Master/texmf-dist/source/latex/babel/babel.ins | 2 +- Master/texmf-dist/source/latex/babel/bbcompat.dtx | 2 +- Master/texmf-dist/source/latex/babel/locale.zip | Bin 1033891 -> 1036974 bytes 4 files changed, 225 insertions(+), 19 deletions(-) (limited to 'Master/texmf-dist/source/latex/babel') diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx index 8346f33f4bb..4345b09198a 100644 --- a/Master/texmf-dist/source/latex/babel/babel.dtx +++ b/Master/texmf-dist/source/latex/babel/babel.dtx @@ -32,7 +32,7 @@ % % \iffalse %<*filedriver> -\ProvidesFile{babel.dtx}[2023/10/25 v3.96 The Babel package] +\ProvidesFile{babel.dtx}[2023/11/11 v3.97 The Babel package] \documentclass{ltxdoc} \GetFileInfo{babel.dtx} \usepackage{fontspec} @@ -271,10 +271,11 @@ are also some notes on its use with e-Plain and pdf-Plain \TeX. \item[\sffamily\color{messages}What if I’m interested only in the latest changes?] Changes and new features with relation to version 3.8 -are highlighted with \New{X.XX}\hspace{-.5em}, and there are some notes -for the latest versions in -\href{https://latex3.github.io/babel/}{the -\babel{} site}. The most recent features can be still unstable. +are highlighted with \New{X.XX}\hspace{-.5em} +(\raisebox{.15ex}{$\oplus$} is a link to the \babel{} site), and there +are some notes for the latest versions in +\href{https://latex3.github.io/babel/}{the \babel{} site}. The most +recent features can be still unstable. \item[\sffamily\color{messages}Can I help?] Sure! If you are interested in the \TeX{} multilingual support, please join the @@ -2852,7 +2853,6 @@ languages. They are (from \textsf{interface3.pdf}): \makebox[\linewidth][c]{*\qquad*\qquad*} \smallskip - A few options (only \luatex) set some properties of the writing system used by the language. These properties are \textit{always} applied to the script, no matter which language is active. Although somewhat @@ -3772,6 +3772,73 @@ This feature is activated with the first |\babelposthyphenation| or \New{3.85} Enables and disables the transform with the given label in the current language. +\subsection{Support for \xetex{} interchar} + +\New{3.97} A few macros are provided to deal with locale dependent +inter-character rules (aka ‘interchar’). + +\Describe{\babelcharclass}{\marg{locale}\marg{name}\marg{char-list}} + +Declares a new character class, which is assigned to the characters in +\marg{char-list}, entered either as characters or in macro form +(eg,~|\}|). If you need to enter them by their numeric value, use the +\TeX{} |^|-notation (eg,~|^^^^1fa0|). Ranges are allowed, with a +hyphen (eg,~|.,;a-zA-Z|). If you need the hyphen to be assigned a +class, write it at the very beginning of the list. + +There are several predefined ‘global’ classes, namely +|default|, |cjkideogram|, |cjkleftpunctuation|, |cjkrightpunctuation|, +|boundary|, and |ignore|, which are described in the \xetex{} manual +(currently CJK classes are ‘empty’, but they will be assigned in a +future release). + +\Describe{\babelinterchar}{\oarg{options}\marg{locale} + \marg{class-first}\marg{class-second}\marg{code}} + +\marg{class-first} and \marg{class-second} can be comma separated lists +of char classes, and all combinations are defined (so that 2 first +classes with 2 second classes, define 4 combinations). In the +\marg{options} field a key named |label| is available, which allows to +enable or to disable the rule with the following two commands. Like +prehyphenation transforms in \luatex{}, interchars are not applied if the +current hyphenation rules are |nohyphenation|. + +\Describe{\enablelocaleinterchar}{\marg{label}} +\DescribeOther{\disablelocaleinterchar}{\marg{label}} + +Enable or disable the interchar rules with the given label for the +current language. + +\begin{example} + Not very useful, but illustrative (taken from the unfortunately + obsolete \textsf{interchar} package, by Zou Ho), to colorize the + letters ‘x’ and ‘y’ (this way to group text is usually not a + good idea, however). +\begin{verbatim} +\usepackage{color} +\babelcharclass{english}{colored}{xy} +\babelinterchar{english}{default, boundary}{colored}{\bgroup\color{red}} +\babelinterchar{english}{colored}{default, boundary}{\egroup} +\end{verbatim} + A more realistic example follows, which inserts a thin space + between a digit and a percent sign. Note the former is entered as a + range, and the latter in command form: +\begin{verbatim} +\babelcharclass{english}{digit}{0-9} +\babelcharclass{english}{percent}{\%} +\babelinterchar[label=percent]{english}{digit}{percent}{\,} +\end{verbatim} +\end{example} + +\begin{warning} + Keep in mind two points: (1) a character can be assigned a single + class; this is a limitation in the interchar mechanims that often + leads to incompatibilities; (2) since the character classes set with + |\babelcharclass| are saved (so that they can be restored), there is a + limit in the number of characters in the \marg{char-list} (which, + however, must be large enough for many uses). +\end{warning} + \subsection{Selection based on BCP 47 tags} \label{bcp47} @@ -4462,7 +4529,7 @@ ibygreek, bgreek, serbianc, frenchle, ethiop} and \textsf{friulan}. (\textsf{portuguese}), \textsf{brazil} (\textsf{brazilian}), \textsf{russianb} (\textsf{russian}), \textsf{usorbian} (\textsf{uppersorbian}), \textsf{vietnam} (\textsf{vietnamese}), - \textsf{northernsami} (\textsf{samin}), \textsf{ukraineb} + \textsf{samin} (\textsf{northernsami}), \textsf{ukraineb} (\textsf{ukrainian}). Deprecated names come in many cases from the times when they had to be shortened to 8 characters. \end{note} @@ -5563,8 +5630,8 @@ wouldn’t exist. % \section{Tools} % % \begin{macrocode} -%<> -%<> +%<> +%<> % \end{macrocode} % % \textbf{Do not use the following macros in \texttt{ldf} files. They @@ -5757,7 +5824,7 @@ wouldn’t exist. \bbl@trim{\expandafter\bbl@kvcmd\expandafter{\bbl@forkv@a}}{#2}{#4}} % \end{macrocode} % -% A \textit{for} loop. Each item (trimmed), is |#1|. It cannot be +% A \textit{for} loop. Each item (trimmed) is |#1|. It cannot be % nested (it's doable, but we don't need it). % % \begin{macrocode} @@ -13626,9 +13693,9 @@ wouldn’t exist. % % \subsection{XeTeX} % -% Unfortunately, the current encoding cannot be retrieved and -% therefore it is reset always to |utf8|, which seems a sensible -% default. +% Unfortunately, the current encoding cannot be retrieved and +% therefore it is reset always to |utf8|, which seems a sensible +% default. % % \begin{macrocode} %<<*Footnote changes>> @@ -13747,6 +13814,145 @@ wouldn’t exist. \DisableBabelHook{babel-fontspec} <@Font selection@> \def\bbl@provide@extra#1{} +% \end{macrocode} +% +% \section{Support for interchar} +% +% \xetex{} reserves some values for CJK (although they are not set in +% \textsc{xelatex}), so we make sure they are skipped. Define some user +% names for the global classes, too. +% +% \begin{macrocode} +\ifnum\xe@alloc@intercharclass<\thr@@ + \xe@alloc@intercharclass\thr@@ +\fi +\chardef\bbl@xeclass@default@=\z@ +\chardef\bbl@xeclass@cjkideogram@=\@ne +\chardef\bbl@xeclass@cjkleftpunctuation@=\tw@ +\chardef\bbl@xeclass@cjkrightpunctuation@=\thr@@ +\chardef\bbl@xeclass@boundary@=4095 +\chardef\bbl@xeclass@ignore@=4096 +% \end{macrocode} +% +% The machinery is activated with a hook (enabled only if actually +% used). Here |\bbl@tempc| is pre-set with |\bbl@usingxeclass|, defined +% below. The standard mechanism based on |\originalTeX| to save, set +% and restore values is used. |\count@| stores the previous char to be +% set, except at the beginning (0) and after |\bbl@upto|, which is the +% previous char negated, as a flag to mark a range. +% +% \begin{macrocode} +\AddBabelHook{babel-interchar}{beforeextras}{% + \@nameuse{bbl@xechars@\languagename}} +\DisableBabelHook{babel-interchar} +\protected\def\bbl@charclass#1{% + \ifnum\count@<\z@ + \count@-\count@ + \loop + \bbl@exp{% + \\\babel@savevariable{\XeTeXcharclass`\Uchar\count@}}% + \XeTeXcharclass\count@ \bbl@tempc + \ifnum\count@<`#1\relax + \advance\count@\@ne + \repeat + \else + \babel@savevariable{\XeTeXcharclass`#1}% + \XeTeXcharclass`#1 \bbl@tempc + \fi + \count@`#1\relax} +% \end{macrocode} +% +% Now the two user macros. Char classes are declared implicitly, and +% then the macro to be executed at the |babel-interchar| hook is +% created. The list of chars to be handled by the hook defined above +% has internally the form +% |\bbl@usingxeclass\bbl@xeclass@punct@english||\bbl@charclass{.}|% +% |\bbl@charclass{,}| (etc.), where |\bbl@usingxeclass| stores the class to be +% applied to the subsequent characters. The \cs{ifcat} part deals with +% the alternative way to enter characters as macros (eg, |\}|). As a +% special case, hyphens are stored as |\bbl@upto|, to deal with ranges. +% +% \begin{macrocode} +\newcommand\babelcharclass[3]{% + \EnableBabelHook{babel-interchar}% + \bbl@csarg\newXeTeXintercharclass{xeclass@#2@#1}% + \def\bbl@tempb##1{% + \ifx##1\@empty\else + \ifx##1-% + \bbl@upto + \else + \bbl@charclass{% + \ifcat\noexpand##1\relax\bbl@stripslash##1\else\string##1\fi}% + \fi + \expandafter\bbl@tempb + \fi}% + \bbl@ifunset{bbl@xechars@#1}% + {\toks@{% + \babel@savevariable\XeTeXinterchartokenstate + \XeTeXinterchartokenstate\@ne + }}% + {\toks@\expandafter\expandafter\expandafter{% + \csname bbl@xechars@#1\endcsname}}% + \bbl@csarg\edef{xechars@#1}{% + \the\toks@ + \bbl@usingxeclass\csname bbl@xeclass@#2@#1\endcsname + \bbl@tempb#3\@empty}} +\protected\def\bbl@usingxeclass#1{\count@\z@ \let\bbl@tempc#1} +\protected\def\bbl@upto{% + \ifnum\count@>\z@ + \advance\count@\@ne + \count@-\count@ + \else\ifnum\count@=\z@ + \bbl@charclass{-}% + \else + \bbl@error{Double hyphens aren't allowed in \string\babelcharclass\\% + because it's potentially ambiguous}% + {See the manual for further info}% + \fi\fi} +% \end{macrocode} +% +% And finally, the command with the code to be inserted. If the language +% doesn’t define a class, then use the global one, as defined above. +% For the definition there is a intermediate macro, which can be +% ‘disabled’ with |\bbl@ic@