summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/babel/babel.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-10-25 20:01:44 +0000
committerKarl Berry <karl@freefriends.org>2023-10-25 20:01:44 +0000
commit90b0791424b391b8f14ebf841df203c160fd5d31 (patch)
tree7f9d5eab48f8b71f824782ee2d9826fc30382c0d /Master/texmf-dist/source/latex/babel/babel.dtx
parentbdfd3e10292fbde581e71feb6e4057a05c6786e6 (diff)
babel (25oct23)
git-svn-id: svn://tug.org/texlive/trunk@68651 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/babel/babel.dtx')
-rw-r--r--Master/texmf-dist/source/latex/babel/babel.dtx127
1 files changed, 83 insertions, 44 deletions
diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx
index d59e7655aa0..8346f33f4bb 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/09/29 v3.95 The Babel package]
+\ProvidesFile{babel.dtx}[2023/10/25 v3.96 The Babel package]
\documentclass{ltxdoc}
\GetFileInfo{babel.dtx}
\usepackage{fontspec}
@@ -82,22 +82,33 @@
\usepackage{color,colortbl}
\usepackage[linkcolor=blue,urlcolor=blue,colorlinks=true]{hyperref}
\hypersetup{%
- pdfsubject={LaTeX Multilingual documents and localization for pdfTeX, LuaTex and
- XeTeX.},
- pdfauthor={Johannes Braams, Javier Bezos},
+ pdfsubject={LaTeX Multilingual documents and localization for pdfTeX,
+ LuaTeX and XeTeX.},
+ pdfauthor={Javier Bezos, Johannes Braams},
pdftitle={Babel},
pdfkeywords={TeX, LaTeX, pdfTeX, LuaTeX, XeTeX, internationalization,
- localization}}
+ localization}}
+\ExplSyntaxOn
\newcommand\New[1]{%
- \colorbox[rgb]{.92, .86, .73}{New #1}\enspace\ignorespaces}
-\definecolor{thered} {rgb}{0.65,0.04,0.07}
-\definecolor{thegrey} {gray}{0.8}
+ \regex_extract_once:nnN{(\d\d?)\.(\d\d)}{#1}\bbltempa
+ \seq_pop_right:NN\bbltempa\bbltempb
+ \seq_pop_right:NN\bbltempa\bbltempa
+ \colorbox[rgb]{.92, .86, .73}%
+ {New~#1%
+ \quark_if_no_value:NTF\bbltempb{}%
+ {~\ifnum\bbltempa>2 \ifnum\bbltempb>34
+ \href{https://latex3.github.io/babel/news/%
+ whats-new-in-babel-\bbltempa.\bbltempb.html}%
+ {\raisebox{.15ex}{$\oplus$}}%
+ \fi\fi}}\enspace\ignorespaces}
+\ExplSyntaxOff
+\definecolor{thered}{rgb}{0.65,0.04,0.07}
+\definecolor{thegrey}{gray}{0.8}
\definecolor{shadecolor}{rgb}{1,1,0.97}
\definecolor{messages}{rgb}{.66,.13,.27}
\makeatletter
\def\@begintheorem#1#2{%
\list{}{}%
- % \small
\global\advance\@listdepth\m@ne
\item[{\sffamily\bfseries\color{messages}\hspace*{1.3em}%
\MakeUppercase{#1}}]}%
@@ -2618,7 +2629,7 @@ with \babel. They are the equivalent of |\DeclareUppercaseMapping| and
twofold: (1) a user-friendly way to declare them, because
often BCP 47 tags are not known (and sometimes can be complex);
(2) if for some reason the tag changes (eg, you decide to tag
-`english` as `en-001` instead of `en-US`), the new mappings will be
+|english| as |en-001| instead of |en-US|), the new mappings will be
still assigned to that language.
\begin{example} For Classical Latin (no need to know the tag is
@@ -2631,7 +2642,7 @@ still assigned to that language.
\begin{note}
There are still some rough edges when declaring a mapping with the
|x| extension, or when two \babel{} languages share the same BCP 47
- tag. These issues will be sorted out in future releases.
+ tag. These issues are expected be sorted out in future releases.
\end{note}
\subsection{Creating a language}
@@ -2932,7 +2943,8 @@ It’s still somewhat experimental. Again, there is an explanation in the
{\babel\ site}.
\Describe{linebreaking=}{}
-\New{3.59} Just a synonymous for \texttt{justification}.
+\New{3.59} Just a synonymous for \texttt{justification}. Depending on
+the language, this name can make more sense.
\begin{note}
(1) If you need shorthands, you can define them with |\useshorthands|
@@ -3261,6 +3273,12 @@ expandable, and the available fields are:
\New{3.75}
\end{description}
+\begin{note}
+ Currently, |x| is used for two separate functions, namely,
+ identifying a \babel{} locale without a BCP47 tag and setting an
+ alternative set of rules for casing.
+\end{note}
+
\begin{warning}
\New{3.46} As of version 3.46 |tag.bcp47| returns the full BCP 47
tag. Formerly it returned just the language subtag, which was clearly
@@ -3538,7 +3556,7 @@ devised by Yannis Haralambous for \textsf{dad} (simple and
recommended way to make these transformations (the best way is with
OTF features), but it can get you out of a hurry.}
-\trans{Czech, Polish, Portuguese, Slovak,
+\trans{Croatian, Czech, Polish, Portuguese, Slovak,
Spanish}{hyphen.repeat}{Explicit hyphens behave like
|\string\babelhyphen|\allowbreak|\{repeat\}|.}
@@ -3859,7 +3877,7 @@ backwards compatibility.}
LICR-savvy encoding in the ASCII range. It is used to redefine |\TeX|
and |\LaTeX| so that they are correctly typeset even with |LGR| or
|X2| (the complete list is stored in |\BabelNonASCII|, which by default
-is |LGR|, |X2|, |OT2|, |OT3|, |OT6|, |LHE|, |LWN|, |LMA|, |LMC|,
+is |LGR|, |LGI|, |X2|, |OT2|, |OT3|, |OT6|, |LHE|, |LWN|, |LMA|, |LMC|,
|LMS|, |LMU|, but you can modify it). So, in some sense it fixes the
bug described in the previous paragraph.
@@ -5545,8 +5563,8 @@ wouldn’t exist.
% \section{Tools}
%
% \begin{macrocode}
-%<<version=3.95>>
-%<<date=2023/09/29>>
+%<<version=3.96>>
+%<<date=2023/10/25>>
% \end{macrocode}
%
% \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -10262,9 +10280,7 @@ wouldn’t exist.
% TODO - error/warning if no script
\directlua{
if Babel.script_blocks['\bbl@cl{sbcp}'] then
- Babel.loc_to_scr[\the\localeid] =
- Babel.script_blocks['\bbl@cl{sbcp}']
- Babel.locale_props[\the\localeid].lc = \the\localeid\space
+ Babel.loc_to_scr[\the\localeid] = Babel.script_blocks['\bbl@cl{sbcp}']
Babel.locale_props[\the\localeid].lg = \the\@nameuse{l@\languagename}\space
end
}%
@@ -10458,6 +10474,7 @@ wouldn’t exist.
\let\BabelBeforeIni\@gobbletwo
\chardef\atcatcode=\catcode`\@
\catcode`\@=11\relax
+ \def\CurrentOption{#2}%
\bbl@input@texini{\bbl@cs{rqtex@\languagename}}%
\catcode`\@=\atcatcode
\let\atcatcode\relax
@@ -10907,6 +10924,11 @@ wouldn’t exist.
\ifbbl@bcptoname
\bbl@csarg\xdef{bcp@map@\bbl@cl{tbcp}}{\languagename}%
\fi
+ \ifcase\bbl@engine\or
+ \directlua{%
+ Babel.locale_props[\the\bbl@cs{id@@\languagename}].script
+ = '\bbl@cl{sbcp}'}%
+ \fi
% Conditional
\ifnum#1>\z@ % 0 = only info, 1, 2 = basic, (re)new
\bbl@exportkey{calpr}{date.calendar.preferred}{}%
@@ -12291,11 +12313,12 @@ wouldn’t exist.
%
% \begin{macrocode}
\bbl@trace{Encoding and fonts}
-\newcommand\BabelNonASCII{LGR,X2,OT2,OT3,OT6,LHE,LWN,LMA,LMC,LMS,LMU}
+\newcommand\BabelNonASCII{LGR,LGI,X2,OT2,OT3,OT6,LHE,LWN,LMA,LMC,LMS,LMU}
\newcommand\BabelNonText{TS1,T3,TS3}
\let\org@TeX\TeX
\let\org@LaTeX\LaTeX
\let\ensureascii\@firstofone
+\let\asciiencoding\@empty
\AtBeginDocument{%
\def\@elt#1{,#1,}%
\edef\bbl@tempa{\expandafter\@gobbletwo\@fontenc@load@list}%
@@ -12305,10 +12328,10 @@ wouldn’t exist.
\bbl@foreach\BabelNonASCII{% LGR loaded in a non-standard way
\bbl@ifunset{T@#1}{}{\def\bbl@tempb{#1}}}%
\bbl@foreach\bbl@tempa{%
- \bbl@xin@{#1}{\BabelNonASCII}%
+ \bbl@xin@{,#1,}{,\BabelNonASCII,}%
\ifin@
\def\bbl@tempb{#1}% Store last non-ascii
- \else\bbl@xin@{#1}{\BabelNonText}% Pass
+ \else\bbl@xin@{,#1,}{,\BabelNonText,}% Pass
\ifin@\else
\def\bbl@tempc{#1}% Store last ascii
\fi
@@ -12318,8 +12341,9 @@ wouldn’t exist.
\ifin@\else
\edef\bbl@tempc{\cf@encoding}% The default if ascii wins
\fi
- \edef\ensureascii#1{%
- {\noexpand\fontencoding{\bbl@tempc}\noexpand\selectfont#1}}%
+ \let\asciiencoding\bbl@tempc
+ \renewcommand\ensureascii[1]{%
+ {\fontencoding{\asciiencoding}\selectfont#1}}%
\DeclareTextCommandDefault{\TeX}{\ensureascii{\org@TeX}}%
\DeclareTextCommandDefault{\LaTeX}{\ensureascii{\org@LaTeX}}%
\fi}
@@ -14829,15 +14853,17 @@ end
% \subsection{Automatic fonts and ids switching}
%
% After defining the blocks for a number of scripts (must be extended
-% and very likely fine tuned), we define a short function which just
-% traverse the node list to carry out the replacements. The table
-% |loc_to_scr| gets the locale form a script range (note the locale is
-% the key, and that there is an intermediate table built on the fly for
-% optimization). This locale is then used to get the |\language| and
-% the |\localeid| as stored in |locale_props|, as well as the font (as
-% requested). In the latter table a key starting with |/| maps the font
-% from the global one (the key) to the local one (the value). Maths are
-% skipped and discretionaries are handled in a special way.
+% and very likely fine tuned), we define a the function
+% |Babel.locale_map|, which just traverse the node list to carry out
+% the replacements. The table |loc_to_scr| stores the script range for
+% each locale (whose id is the key), copied from this table (so that it
+% can be modified on a locale basis); there is an intermediate table
+% named |chr_to_loc| built on the fly for optimization, which maps a
+% char to the locale. This locale is then used to get the |\language|
+% as stored in |locale_props|, as well as the font (as requested). In
+% the latter table a key starting with |/| maps the font from the
+% global one (the key) to the local one (the value). Maths are skipped
+% and discretionaries are handled in a special way.
%
% \begin{macrocode}
% TODO - to a lua file
@@ -14919,31 +14945,44 @@ function Babel.locale_map(head)
end
end
end
+ % Treat composite chars in a different fashion, because they
+ % 'inherit' the previous locale.
+ if (item.char >= 0x0300 and item.char <= 0x036F) or
+ (item.char >= 0x1AB0 and item.char <= 0x1AFF) or
+ (item.char >= 0x1DC0 and item.char <= 0x1DFF) then
+ Babel.chr_to_loc[item.char] = -2000
+ toloc = -2000
+ end
+ if not toloc then
+ Babel.chr_to_loc[item.char] = -1000
+ end
end
- % Now, take action, but treat composite chars in a different
- % fashion, because they 'inherit' the previous locale. Not yet
- % optimized.
- if not toloc and
- (item.char >= 0x0300 and item.char <= 0x036F) or
- (item.char >= 0x1AB0 and item.char <= 0x1AFF) or
- (item.char >= 0x1DC0 and item.char <= 0x1DFF) then
+ if toloc == -2000 then
toloc = toloc_save
+ elseif toloc == -1000 then
+ toloc = nil
end
if toloc and Babel.locale_props[toloc] and
Babel.locale_props[toloc].letters and
tex.getcatcode(item.char) \string~= 11 then
toloc = nil
end
- if toloc and toloc > -1 then
+ if toloc and Babel.locale_props[toloc].script
+ and Babel.locale_props[node.get_attribute(item, LOCALE)].script
+ and Babel.locale_props[toloc].script ==
+ Babel.locale_props[node.get_attribute(item, LOCALE)].script then
+ toloc = nil
+ end
+ if toloc then
if Babel.locale_props[toloc].lg then
item.lang = Babel.locale_props[toloc].lg
node.set_attribute(item, LOCALE, toloc)
- end
+ end
if Babel.locale_props[toloc]['/'..item.font] then
item.font = Babel.locale_props[toloc]['/'..item.font]
end
- toloc_save = toloc
end
+ toloc_save = toloc
elseif not inmath and item.id == 7 then % Apply recursively
item.replace = item.replace and Babel.locale_map(item.replace)
item.pre = item.pre and Babel.locale_map(item.pre)
@@ -23648,7 +23687,7 @@ Babel.cjk_breaks = {
\@namedef{bbl@esname@nil}{Latin}
\@namedef{bbl@sname@nil}{Latin}
\@namedef{bbl@sbcp@nil}{Latn}
-\@namedef{bbl@sotf@nil}{Latn}
+\@namedef{bbl@sotf@nil}{latn}
% \end{macrocode}
%
% The macro |\ldf@finish| takes care of looking for a