summaryrefslogtreecommitdiff
path: root/macros/latex/required/babel/base/babel.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-12-29 03:01:06 +0000
committerNorbert Preining <norbert@preining.info>2021-12-29 03:01:06 +0000
commitdce1a2a6ecd9971433b4ee24c9d36b124cc1280e (patch)
tree051072f1ec49fbe350e7f88309ab293d1806e121 /macros/latex/required/babel/base/babel.dtx
parentecdf859b6ce481abfd530425dcf6f0f764bd0001 (diff)
CTAN sync 202112290301
Diffstat (limited to 'macros/latex/required/babel/base/babel.dtx')
-rw-r--r--macros/latex/required/babel/base/babel.dtx273
1 files changed, 135 insertions, 138 deletions
diff --git a/macros/latex/required/babel/base/babel.dtx b/macros/latex/required/babel/base/babel.dtx
index 666c1b1eef..1c08c96668 100644
--- a/macros/latex/required/babel/base/babel.dtx
+++ b/macros/latex/required/babel/base/babel.dtx
@@ -32,7 +32,7 @@
%
% \iffalse
%<*filedriver>
-\ProvidesFile{babel.dtx}[2021/11/29 v3.67 The Babel package]
+\ProvidesFile{babel.dtx}[2021/12/28 v3.68 The Babel package]
\documentclass{ltxdoc}
\GetFileInfo{babel.dtx}
\usepackage{fontspec}
@@ -5118,8 +5118,8 @@ help from Bernd Raichle, for which I am grateful.
% \section{Tools}
%
% \begin{macrocode}
-%<<version=3.67>>
-%<<date=2021/11/29>>
+%<<version=3.68>>
+%<<date=2021/12/28>>
% \end{macrocode}
%
% \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -5196,10 +5196,11 @@ help from Bernd Raichle, for which I am grateful.
%
% Now, just syntactical sugar, but it makes partial expansion of
% some code a lot more simple and readable. Here |\\| stands for
-% |\noexpand| and |\<..>| for |\noexpand| applied to a built macro
-% name (the latter does not define the macro if undefined to
-% |\relax|, because it is created locally). The result may be
-% followed by extra arguments, if necessary.
+% |\noexpand|, |\<..>| for |\noexpand| applied to a built macro
+% name (which does not define the macro if undefined to
+% |\relax|, because it is created locally), and |\[..]| for one-level
+% expansion (where |..| is the macro name without the backslash). The
+% result may be followed by extra arguments, if necessary.
%
% \begin{macrocode}
\def\bbl@exp#1{%
@@ -5896,16 +5897,6 @@ help from Bernd Raichle, for which I am grateful.
\fi
% \end{macrocode}
%
-% Make sure the language set with `main` is the last one.
-%
-% \begin{macrocode}
-\ifx\bbl@opt@main\@nnil\else
- \edef\bbl@language@opts{%
- \ifx\bbl@language@opts\@empty\else\bbl@language@opts,\fi
- \bbl@opt@main}
-\fi
-% \end{macrocode}
-%
% For |layout| an auxiliary macro is provided, available for packages
% and language styles. Optimization: if there is no |layout|, just do
% nothing.
@@ -10213,8 +10204,8 @@ help from Bernd Raichle, for which I am grateful.
\ifeof\bbl@readstream
\bbl@error
{There is no ini file for the requested language\\%
- (#1). Perhaps you misspelled it or your installation\\%
- is not complete.}%
+ (#1: \languagename). Perhaps you misspelled it or your\\%
+ installation is not complete.}%
{Fix the name or reinstall babel.}%
\else
% == Store ini data in \bbl@inidata ==
@@ -12133,103 +12124,84 @@ help from Bernd Raichle, for which I am grateful.
\fi
% \end{macrocode}
%
-%
% Recognizing global options in packages not having a closed set of
-% them is not trivial, as for them to be processed they must be
-% defined explicitly. So, package options not yet taken into
-% account and stored in |bbl@language@opts| are assumed to be
-% languages (note this list also contains the language given with
-% |main|). If not declared above, the names of the option and the
-% file are the same.
+% them is not trivial, as for them to be processed they must be defined
+% explicitly. So, package options not yet taken into account and stored
+% in |bbl@language@opts| are assumed to be languages. If not declared
+% above, the names of the option and the file are the same. We first
+% pre-process the class and package options to determine the main
+% language, which is processed in the third ‘main’ pass,
+% \textit{except} if all files are ldf \textit{and} there is no |main|
+% key. In the latter case (|\bbl@opt@main| is still |\@nnil|), the
+% traditional way to set the main language is kept — the last loaded is
+% the main language.
%
% \begin{macrocode}
-\let\bbl@tempc\relax
-\bbl@foreach\bbl@language@opts{%
- \ifcase\bbl@iniflag % Default
- \bbl@ifunset{ds@#1}%
- {\DeclareOption{#1}{\bbl@load@language{#1}}}%
- {}%
- \or % provide=*
- \@gobble % case 2 same as 1
- \or % provide+=*
- \bbl@ifunset{ds@#1}%
- {\IfFileExists{#1.ldf}{}%
- {\IfFileExists{babel-#1.tex}{}{\@namedef{ds@#1}{}}}}%
- {}%
- \bbl@ifunset{ds@#1}%
- {\def\bbl@tempc{#1}%
- \DeclareOption{#1}{%
- \ifnum\bbl@iniflag>\@ne
- \bbl@ldfinit
- \babelprovide[import]{#1}%
- \bbl@afterldf{}%
- \else
- \bbl@load@language{#1}%
- \fi}}%
- {}%
- \or % provide*=*
- \def\bbl@tempc{#1}%
- \bbl@ifunset{ds@#1}%
- {\DeclareOption{#1}{%
- \bbl@ldfinit
- \babelprovide[import]{#1}%
- \bbl@afterldf{}}}%
- {}%
- \fi}
+\ifx\bbl@opt@main\@nnil
+ \ifnum\bbl@iniflag>\z@ % if all ldf's: set implicitly, no main pass
+ \let\bbl@tempb\@empty
+ \edef\bbl@tempa{\@classoptionslist,\bbl@language@opts}%
+ \bbl@foreach\bbl@tempa{\edef\bbl@tempb{#1,\bbl@tempb}}%
+ \bbl@foreach\bbl@tempb{% \bbl@tempb is a reversed list
+ \ifx\bbl@opt@main\@nnil % ie, if not yet assigned
+ \ifodd\bbl@iniflag % = *=
+ \IfFileExists{babel-#1.tex}{\def\bbl@opt@main{#1}}{}%
+ \else % n +=
+ \IfFileExists{#1.ldf}{\def\bbl@opt@main{#1}}{}%
+ \fi
+ \fi}%
+ \fi
+\fi
% \end{macrocode}
%
-% Now, we make sure an option is explicitly declared for any language
-% set as global option, by checking if an |ldf| exists. The previous
-% step was, in fact, somewhat redundant, but that way we minimize
-% accessing the file system just to see if the option could be a
-% language.
+% A few languages are still defined explicitly. They are stored in case
+% they are needed in the ‘main’ pass (the value can be |\relax|).
%
% \begin{macrocode}
-\let\bbl@tempb\@nnil
-\let\bbl@clsoptlst\@classoptionslist
-\bbl@foreach\@classoptionslist{%
- \bbl@ifunset{ds@#1}%
- {\IfFileExists{#1.ldf}%
- {\def\bbl@tempb{#1}%
- \DeclareOption{#1}{%
- \ifnum\bbl@iniflag>\@ne
- \bbl@ldfinit
- \babelprovide[import]{#1}%
- \bbl@afterldf{}%
- \else
- \bbl@load@language{#1}%
- \fi}}%
- {\IfFileExists{babel-#1.tex}%
- {\def\bbl@tempb{#1}%
- \ifnum\bbl@iniflag>\z@
- \DeclareOption{#1}{%
- \ifnum\bbl@iniflag>\@ne
- \bbl@ldfinit
- \babelprovide[import]{#1}%
- \bbl@afterldf{}%
- \fi}%
- \fi}%
- {}}}%
- {}}
+\ifx\bbl@opt@main\@nnil\else
+ \bbl@csarg\let{loadmain\expandafter}\csname ds@\bbl@opt@main\endcsname
+ \expandafter\let\csname ds@\bbl@opt@main\endcsname\relax
+\fi
% \end{macrocode}
%
-% If a main language has been set, store it for the third pass.
+% Now define the corresponding loaders. With package options, assume
+% the language exists. With class options, check if the option is a
+% language by checking if the correspondin file exists.
+%
%
% \begin{macrocode}
-\ifnum\bbl@iniflag=\z@\else
- \ifx\bbl@opt@main\@nnil
- \ifx\bbl@tempc\relax
- \let\bbl@opt@main\bbl@tempb
- \else
- \let\bbl@opt@main\bbl@tempc
- \fi
- \fi
-\fi
-\ifx\bbl@opt@main\@nnil\else
- \expandafter
- \let\expandafter\bbl@loadmain\csname ds@\bbl@opt@main\endcsname
- \expandafter\let\csname ds@\bbl@opt@main\endcsname\@empty
-\fi
+\bbl@foreach\bbl@language@opts{%
+ \def\bbl@tempa{#1}%
+ \ifx\bbl@tempa\bbl@opt@main\else
+ \bbl@ifunset{ds@#1}%
+ {\ifnum\bbl@iniflag<\tw@ % 0 ø (other = ldf)
+ \DeclareOption{#1}{\bbl@load@language{#1}}%
+ \else % + * (other = ini)
+ \DeclareOption{#1}{%
+ \bbl@ldfinit
+ \babelprovide[import]{#1}%
+ \bbl@afterldf{}}%
+ \fi}%
+ {}%
+ \fi}
+\bbl@foreach\@classoptionslist{%
+ \def\bbl@tempa{#1}%
+ \ifx\bbl@tempa\bbl@opt@main\else
+ \bbl@ifunset{ds@#1}%
+ {\ifnum\bbl@iniflag<\tw@ % 0 ø (other = ldf)
+ \IfFileExists{#1.ldf}%
+ {\DeclareOption{#1}{\bbl@load@language{#1}}}%
+ {}%
+ \else % + * (other = ini)
+ \IfFileExists{babel-#1.tex}%
+ {\DeclareOption{#1}{%
+ \bbl@ldfinit
+ \babelprovide[import]{#1}%
+ \bbl@afterldf{}}}%
+ {}%
+ \fi}%
+ {}%
+ \fi}
% \end{macrocode}
%
% And we are done, because all options for this pass has been
@@ -12237,8 +12209,7 @@ help from Bernd Raichle, for which I am grateful.
% ignored.
%
% The options have to be processed in the order in which the user
-% specified them (except, of course, global options, which \LaTeX{}
-% processes before):
+% specified them (but remember class options are processes before):
%
% \begin{macrocode}
\def\AfterBabelLanguage#1{%
@@ -12247,12 +12218,14 @@ help from Bernd Raichle, for which I am grateful.
\ProcessOptions*
% \end{macrocode}
%
-% This finished the second pass. Now the third one begins, which
-% loads the main language set with the key |main|. A warning is
-% raised if the main language is not the same as the last named
-% one, or if the value of the key |main| is not a language. Then
-% execute directly the option (because it could be used only in
-% |main|). After loading all languages, we deactivate
+% This finished the second pass. Now the third one begins, which loads
+% the main language set with the key |main|. A warning is raised if the
+% main language is not the same as the last named one, or if the value
+% of the key |main| is not a language. With some options in |provide|,
+% the package |luatexbase| is loaded (and immediately used), and
+% therefore |\babelprovide| can’t go inside a |\DeclareOption|; this
+% explains why it’s executed directly, with a dummy declaration. Then
+% all languages have been loaded, so we deactivate
% |\AfterBabelLanguage|.
%
% \begin{macrocode}
@@ -12271,32 +12244,27 @@ help from Bernd Raichle, for which I am grateful.
but the last processed one was '\bbl@tempb'.\\%
The main language can't be set as both a global\\%
and a package option. Use 'main=\bbl@tempc' as\\%
- option. Reported}%
+ option. Reported}
\fi
\else
- \ifodd\bbl@iniflag % case 1,3
+ \ifodd\bbl@iniflag % case 1,3 (main is ini)
\bbl@ldfinit
\let\CurrentOption\bbl@opt@main
- \ifx\bbl@opt@provide\@nnil
- \bbl@exp{\\\babelprovide[import,main]{\bbl@opt@main}}%
+ \bbl@exp{% \bbl@opt@provide = empty if *
+ \\\babelprovide[\bbl@opt@provide,import,main]{\bbl@opt@main}}%
+ \bbl@afterldf{}
+ \DeclareOption{\bbl@opt@main}{}
+ \else % case 0,2 (main is ldf)
+ \ifx\bbl@loadmain\relax
+ \DeclareOption{\bbl@opt@main}{\bbl@load@language{\bbl@opt@main}}
\else
- \bbl@exp{\\\bbl@forkv{\@nameuse{@raw@opt@babel.sty}}}{%
- \bbl@xin@{,provide,}{,#1,}%
- \ifin@
- \def\bbl@opt@provide{#2}%
- \bbl@replace\bbl@opt@provide{;}{,}%
- \fi}%
- \bbl@exp{%
- \\\babelprovide[\bbl@opt@provide,import,main]{\bbl@opt@main}}%
+ \DeclareOption{\bbl@opt@main}{\bbl@loadmain}
\fi
- \bbl@afterldf{}%
- \else % case 0,2
- \chardef\bbl@iniflag\z@ % Force ldf
- \expandafter\let\csname ds@\bbl@opt@main\endcsname\bbl@loadmain
\ExecuteOptions{\bbl@opt@main}
- \DeclareOption*{}%
- \ProcessOptions*
+ \@namedef{ds@\bbl@opt@main}{}%
\fi
+ \DeclareOption*{}
+ \ProcessOptions*
\fi
\def\AfterBabelLanguage{%
\bbl@error
@@ -12304,10 +12272,9 @@ help from Bernd Raichle, for which I am grateful.
{Languages have been loaded, so I can do nothing}}
% \end{macrocode}
%
-% In order to catch the case where the user forgot to specify a
+% In order to catch the case where the user didn’t specify a
% language we check whether |\bbl@main@language|, has become
-% defined. If not, no language has been loaded and an error
-% message is displayed.
+% defined. If not, the |nil| language is loaded.
%
% \begin{macrocode}
\ifx\bbl@main@language\@undefined
@@ -14516,6 +14483,10 @@ end
\frozen@everydisplay\expandafter{%
\expandafter\bbl@mathboxdir\the\frozen@everydisplay}
\fi
+\def\bbl@truellap{%s
+ \ifcase\bbl@attr@dir\expandafter\llap\else\expandafter\rlap\fi}
+\def\bbl@truerlap{%
+ \ifcase\bbl@attr@dir\expandafter\rlap\else\expandafter\llap\fi}
% \end{macrocode}
%
% \subsection{Layout}
@@ -14543,11 +14514,37 @@ end
%
% \begin{macrocode}
\bbl@trace{Redefinitions for bidi layout}
+\AtBeginDocument{% amsmath
+ \ifx\place@tag\@undefined\else
+ \bbl@sreplace\place@tag{\llap}{\bbl@truellap}%
+ \bbl@sreplace\place@tag@gather{\llap}{\bbl@truellap}%
+ \bbl@sreplace\place@tag{\rlap}{\bbl@truerlap}%
+ \bbl@sreplace\place@tag@gather{\rlap}{\bbl@truerlap}%
+ \fi}
+\ifx\AddToHook\@undefined\else
+ \AddToHook{env/equation/before}{\pardir TLT }{}
+\fi
\ifx\@eqnnum\@undefined\else
\ifx\bbl@attr@dir\@undefined\else
- \edef\@eqnnum{{%
- \unexpanded{\ifcase\bbl@attr@dir\else\bbl@textdir\@ne\fi}%
- \unexpanded\expandafter{\@eqnnum}}}
+ \bbl@xin@{,leqno,}{,\@classoptionslist,}%
+ \ifin@
+ \bbl@sreplace\@eqnnum{\rlap}{\bbl@leqno@aux}
+ \def\bbl@leqno@aux#1{%
+ \bbl@truerlap{%
+ \ifcase\bbl@attr@dir
+ #1%
+ \else
+ \bbl@textdir\@ne
+ #1%
+ \hskip-\displaywidth
+ \fi}}
+ \else
+ \bbl@exp{%
+ \def\\\@eqnnum{{%
+ \<ifcase>\\\bbl@attr@dir\<else>\\\bbl@textdir\@ne\<fi>%
+ \\\bbl@ifsamestring{\\\@currenvir}{equation}%
+ {}{\\\bbl@truellap}{\[@eqnnum]}}}}
+ \fi
\fi
\fi
\ifx\bbl@opt@layout\@nnil\endinput\fi % if no layout
@@ -21854,7 +21851,7 @@ function Babel.bidi(head, ispar, hdir)
elseif item.id == DIR then
d = nil
- new_d = true
+ if head ~= item then new_d = true end
elseif item.id == node.id'glue' and item.subtype == 13 then
glue_d = d