summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/babel/babel.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/babel/babel.dtx')
-rw-r--r--Master/texmf-dist/source/latex/babel/babel.dtx464
1 files changed, 272 insertions, 192 deletions
diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx
index 1a19d9f2d35..093a61a6f1c 100644
--- a/Master/texmf-dist/source/latex/babel/babel.dtx
+++ b/Master/texmf-dist/source/latex/babel/babel.dtx
@@ -31,7 +31,7 @@
%
% \iffalse
%<*filedriver>
-\ProvidesFile{babel.dtx}[2021/01/26 v3.53 The Babel package]
+\ProvidesFile{babel.dtx}[2021/02/22 v3.54 The Babel package]
\documentclass{ltxdoc}
\GetFileInfo{babel.dtx}
\usepackage{fontspec}
@@ -2408,12 +2408,11 @@ Conveniently, some options allow to fill the language, and \babel{}
warns you about what to do if there is a missing string. Very likely
you will find alerts like that in the |log| file:
\begin{verbatim}
-Package babel Warning: \mylangchaptername not set. Please, define it
-(babel) after the language has been loaded (typically
-(babel) in the preamble) with the help of
-(babel) \setlocalecaption. An example is:
+Package babel Warning: \chaptername not set for 'mylang'. Please,
+(babel) define it after the language has been loaded
+(babel) (typically in the preamble) with:
(babel) \setlocalecaption{mylang}{chapter}{..}
-(babel) Reported on input line 18.
+(babel) Reported on input line 26.
\end{verbatim}
In most cases, you will only need to define a few macros. Note
@@ -3445,10 +3444,8 @@ bidirectional (with both R and L paragraphs) documents in \luatex{}.
\item[graphics] modifies the |picture| environment so that the whole
figure is L but the text is R. It \textit{does not} work with the
-standard |picture|, and \textit{pict2e} is required if you want sloped
-lines \textbf{(With recent versions of \LaTeX, this feature has
-stopped working)}. It attempts to do the same for \textsf{pgf/tikz}.
-Somewhat experimental. \New{3.32}.
+standard |picture|, and \textit{pict2e} is required. It attempts to do
+the same for \textsf{pgf/tikz}. Somewhat experimental. \New{3.32}.
\item[extras] is used for miscellaneous readjustments which do not fit into
the previous groups. Currently redefines in \luatex{} |\underline| and
@@ -4851,8 +4848,8 @@ help from Bernd Raichle, for which I am grateful.
% \section{Tools}
%
% \begin{macrocode}
-%<<version=3.53>>
-%<<date=2021/01/26>>
+%<<version=3.54>>
+%<<date=2021/02/22>>
% \end{macrocode}
%
% \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -5274,7 +5271,7 @@ help from Bernd Raichle, for which I am grateful.
Babel.debug = false }%
\fi}
<@Basic macros@>
- % Temporarily repeat here the code for errors
+ % Temporarily repeat here the code for errors. TODO.
\def\bbl@error#1#2{%
\begingroup
\def\\{\MessageBreak}%
@@ -5297,16 +5294,18 @@ help from Bernd Raichle, for which I am grateful.
\def\\{\MessageBreak}%
\PackageInfo{babel}{#1}%
\endgroup}
- \def\bbl@nocaption{\protect\bbl@nocaption@i}
+\def\bbl@nocaption{\protect\bbl@nocaption@i}
+% TODO - Wrong for \today !!! Must be a separate macro.
\def\bbl@nocaption@i#1#2{% 1: text to be printed 2: caption macro \langXname
\global\@namedef{#2}{\textbf{?#1?}}%
\@nameuse{#2}%
- \bbl@warning{% TODO.
- \@backslashchar#2 not set. Please, define it\\%
- after the language has been loaded (typically\\%
- in the preamble) with the help of\\%
- \string\setlocalecaption. An example is:\\%
- \string\setlocalecaption{mylang}{chapter}{..}\\
+ \edef\bbl@tempa{#1}%
+ \bbl@sreplace\bbl@tempa{name}{}%
+ \bbl@warning{%
+ \@backslashchar#1 not set for '\languagename'. Please,\\%
+ define it after the language has been loaded\\%
+ (typically in the preamble) with\\%
+ \string\setlocalecaption{\languagename}{\bbl@tempa}{..}\\%
Reported}}
\def\bbl@tentative{\protect\bbl@tentative@i}
\def\bbl@tentative@i#1{%
@@ -7666,6 +7665,7 @@ help from Bernd Raichle, for which I am grateful.
\def\bbl@foreign@s#1#2{% TODO - \shapemode, \@setpar, ?\@@par
\begingroup
{\par}%
+ \let\bbl@select@opts\@empty
\let\BabelText\@firstofone
\foreign@language{#1}%
\bbl@usehooks{foreign*}{}%
@@ -7938,12 +7938,13 @@ help from Bernd Raichle, for which I am grateful.
\def\bbl@nocaption@i#1#2{% 1: text to be printed 2: caption macro \langXname
\global\@namedef{#2}{\textbf{?#1?}}%
\@nameuse{#2}%
- \bbl@warning{%
- \@backslashchar#2 not set. Please, define it\\%
- after the language has been loaded (typically\\%
- in the preamble) with the help of\\%
- \string\setlocalecaption. An example is\\%
- \string\setlocalecaption{mylang}{chapter}{..}\\
+ \edef\bbl@tempa{#1}%
+ \bbl@sreplace\bbl@tempa{name}{}%
+ \bbl@warning{% TODO.
+ \@backslashchar#1 not set for '\languagename'. Please,\\%
+ define it after the language has been loaded\\%
+ (typically in the preamble) with:\\%
+ \string\setlocalecaption{\languagename}{\bbl@tempa}{..}\\%
Reported}}
\def\bbl@tentative{\protect\bbl@tentative@i}
\def\bbl@tentative@i#1{%
@@ -9317,12 +9318,6 @@ help from Bernd Raichle, for which I am grateful.
% attribute being checked, and the third and fourth arguments are
% the true and false clauses.
%
-% First we need to find out if any attributes were set; if not we're
-% done. Then we need to check the list of known attributes. When
-% we're this far |\ifin@| has a value indicating if the attribute in
-% question was set or not. Just to be safe the code to be executed
-% is `thrown over the |\fi|'.
-%
% \begin{macrocode}
\def\bbl@ifattributeset#1#2#3#4{%
\ifx\bbl@known@attribs\@undefined
@@ -9334,8 +9329,7 @@ help from Bernd Raichle, for which I am grateful.
\bbl@afterelse#3%
\else
\bbl@afterfi#4%
- \fi
- }
+ \fi}
% \end{macrocode}
%
% \end{macro}
@@ -9347,9 +9341,7 @@ help from Bernd Raichle, for which I am grateful.
% is known and the \TeX-code to be executed otherwise.
%
% We first assume the attribute is unknown. Then we loop over the
-% list of known attributes, trying to find a match. When a match is
-% found the definition of |\bbl@tempa| is changed. Finally we
-% execute |\bbl@tempa|.
+% list of known attributes, trying to find a match.
%
% \begin{macrocode}
\def\bbl@ifknown@ttrib#1#2{%
@@ -9360,8 +9352,7 @@ help from Bernd Raichle, for which I am grateful.
\let\bbl@tempa\@firstoftwo
\else
\fi}%
- \bbl@tempa
-}
+ \bbl@tempa}
% \end{macrocode}
%
% \end{macro}
@@ -9451,7 +9442,10 @@ help from Bernd Raichle, for which I am grateful.
% Some languages need to have |\frenchspacing| in effect. Others
% don't want that. The command |\bbl@frenchspacing| switches it on
% when it isn't already in effect and |\bbl@nonfrenchspacing|
-% switches it off if necessary.
+% switches it off if necessary. A more refined way to switch the
+% catcodes is done with |ini| files. Here an auxiliary macro is
+% defined, but the main part is in |\babelprovide|. This new method
+% should be ideally the default one.
%
% \begin{macrocode}
\def\bbl@frenchspacing{%
@@ -9462,7 +9456,6 @@ help from Bernd Raichle, for which I am grateful.
\let\bbl@nonfrenchspacing\nonfrenchspacing
\fi}
\let\bbl@nonfrenchspacing\nonfrenchspacing
-%
\let\bbl@elt\relax
\edef\bbl@fs@chars{%
\bbl@elt{\string.}\@m{3000}\bbl@elt{\string?}\@m{3000}%
@@ -9503,7 +9496,7 @@ help from Bernd Raichle, for which I am grateful.
%
% \subsection{Hyphens}
%
-% \begin{macro}{\babelhyphenation}
+% \begin{macro}{\babelhyphenation}
%
% This macro saves hyphenation exceptions. Two macros are used to
% store them: |\bbl@hyphenation@| for the global ones and
@@ -9534,7 +9527,7 @@ help from Bernd Raichle, for which I am grateful.
\bbl@iflanguage\bbl@tempa{%
\bbl@csarg\protected@edef{hyphenation@\bbl@tempa}{%
\bbl@ifunset{bbl@hyphenation@\bbl@tempa}%
- \@empty
+ {}%
{\csname bbl@hyphenation@\bbl@tempa\endcsname\space}%
#2}}}%
\fi}}
@@ -10667,6 +10660,7 @@ help from Bernd Raichle, for which I am grateful.
\let\bbl@KVP@Alph\@nil
\let\bbl@KVP@labels\@nil
\bbl@csarg\let{KVP@labels*}\@nil
+ \global\let\bbl@inidata\@empty
\bbl@forkv{#1}{% TODO - error handling
\in@{/}{##1}%
\ifin@
@@ -10732,7 +10726,8 @@ help from Bernd Raichle, for which I am grateful.
% ==
% At this point all parameters are defined if 'import'. Now we
% execute some code depending on them. But what about if nothing was
- % imported? We just set the very basic parameters.
+ % imported? We just set the basic parameters, but still loading the
+ % whole ini file.
\bbl@load@basic{#2}%
% == script, language ==
% Override the values from ini or defines them
@@ -10974,12 +10969,10 @@ help from Bernd Raichle, for which I am grateful.
\expandafter\bbl@tempb\bbl@captionslist\@empty
\else
\ifx\bbl@initoload\relax
- \bbl@read@ini{\bbl@KVP@captions}0% Here letters cat = 11
+ \bbl@read@ini{\bbl@KVP@captions}2% % Here letters cat = 11
\else
- \bbl@read@ini{\bbl@initoload}0% Here all letters cat = 11
+ \bbl@read@ini{\bbl@initoload}2% % Same
\fi
- \bbl@after@ini
- \bbl@savestrings
\fi
\StartBabelCommands*{#1}{date}%
\ifx\bbl@KVP@import\@nil
@@ -11031,9 +11024,7 @@ help from Bernd Raichle, for which I am grateful.
\def\bbl@provide@renew#1{%
\ifx\bbl@KVP@captions\@nil\else
\StartBabelCommands*{#1}{captions}%
- \bbl@read@ini{\bbl@KVP@captions}0% Here all letters cat = 11
- \bbl@after@ini
- \bbl@savestrings
+ \bbl@read@ini{\bbl@KVP@captions}2% % Here all letters cat = 11
\EndBabelCommands
\fi
\ifx\bbl@KVP@import\@nil\else
@@ -11046,24 +11037,18 @@ help from Bernd Raichle, for which I am grateful.
\ifx\bbl@lbkflag\@empty
\bbl@provide@hyphens{#1}%
\fi}
+% \end{macrocode}
+%
% Load the basic parameters (ids, typography, counters, and a few
% more), while captions and dates are left out. But it may happen some
% data has been loaded before automatically, so we first discard the
% saved values.
-\def\bbl@linebreak@export{%
- \bbl@exportkey{lnbrk}{typography.linebreaking}{h}%
- \bbl@exportkey{hyphr}{typography.hyphenrules}{}%
- \bbl@exportkey{lfthm}{typography.lefthyphenmin}{2}%
- \bbl@exportkey{rgthm}{typography.righthyphenmin}{3}%
- \bbl@exportkey{prehc}{typography.prehyphenchar}{}%
- \bbl@exportkey{hyotl}{typography.hyphenate.other.locale}{}%
- \bbl@exportkey{hyots}{typography.hyphenate.other.script}{}%
- \bbl@exportkey{intsp}{typography.intraspace}{}%
- \bbl@exportkey{chrng}{characters.ranges}{}}
+%
+% \begin{macrocode}
\def\bbl@load@basic#1{%
\bbl@ifunset{bbl@inidata@\languagename}{}%
{\getlocaleproperty\bbl@tempa{\languagename}{identification/load.level}%
- \ifcase\bbl@tempa\else
+ \ifcase\bbl@tempa
\bbl@csarg\let{lname@\languagename}\relax
\fi}%
\bbl@ifunset{bbl@lname@#1}%
@@ -11071,10 +11056,7 @@ help from Bernd Raichle, for which I am grateful.
\begingroup
\let\bbl@ini@captions@aux\@gobbletwo
\def\bbl@inidate ####1.####2.####3.####4\relax ####5####6{}%
- \bbl@read@ini{##1}0%
- \bbl@linebreak@export
- \bbl@exportkey{dgnat}{numbers.digits.native}{}%
- \bbl@exportkey{frspc}{typography.frenchspacing}{u}% unset
+ \bbl@read@ini{##1}1%
\ifx\bbl@initoload\relax\endinput\fi
\endgroup}%
\begingroup % boxed, to avoid extra spaces:
@@ -11126,14 +11108,10 @@ help from Bernd Raichle, for which I am grateful.
{\bbl@exp{\\\adddialect\<l@#1>\bbl@tempa}}}% found in opt list or ini
% \end{macrocode}
%
-% The reader of |ini| files. There are 3 possible cases: a section name
-% (in the form |[...]|), a comment (starting with |;|) and a
-% key/value pair.
+% The reader of |babel-...tex| files. We reset temporarily some
+% catcodes.
%
% \begin{macrocode}
-\ifx\bbl@readstream\@undefined
- \csname newread\endcsname\bbl@readstream
-\fi
\def\bbl@input@texini#1{%
\bbl@bsphack
\bbl@exp{%
@@ -11145,20 +11123,51 @@ help from Bernd Raichle, for which I am grateful.
\catcode`\\\{=\the\catcode`\{\relax
\catcode`\\\}=\the\catcode`\}\relax}%
\bbl@esphack}
-\def\bbl@inipreread#1=#2\@@{%
- \bbl@trim@def\bbl@tempa{#1}% Redundant below !!
+% \end{macrocode}
+%
+% The following macros read and store |ini| files (but don't process
+% them). For each line, there are 3 possible actions: ignore if starts
+% with |;|, switch section if starts with |[|, and store otherwise.
+% There are used in the first step of |\bbl@read@ini|.
+%
+% \begin{macrocode}
+\def\bbl@iniline#1\bbl@iniline{%
+ \@ifnextchar[\bbl@inisect{\@ifnextchar;\bbl@iniskip\bbl@inistore}#1\@@}% ]
+\def\bbl@inisect[#1]#2\@@{\def\bbl@section{#1}}%
+\def\bbl@iniskip#1\@@{}% if starts with ;
+\def\bbl@inistore#1=#2\@@{% full (default)
+ \bbl@trim@def\bbl@tempa{#1}%
\bbl@trim\toks@{#2}%
- % Move trims here ??
\bbl@ifunset{bbl@KVP@\bbl@section/\bbl@tempa}%
{\bbl@exp{%
- \\\g@addto@macro\\\bbl@inidata{%
- \\\bbl@elt{\bbl@section}{\bbl@tempa}{\the\toks@}}}%
- \expandafter\bbl@inireader\bbl@tempa=#2\@@}%
+ \\\g@addto@macro\\\bbl@inidata{%
+ \\\bbl@elt{\bbl@section}{\bbl@tempa}{\the\toks@}}}}%
{}}%
-\def\bbl@fetch@ini#1#2{%
- \bbl@exp{\def\\\bbl@inidata{%
- \\\bbl@elt{identification}{tag.ini}{#1}%
- \\\bbl@elt{identification}{load.level}{#2}}}%
+\def\bbl@inistore@min#1=#2\@@{% minimal (maybe set in \bbl@read@ini)
+ \bbl@trim@def\bbl@tempa{#1}%
+ \bbl@trim\toks@{#2}%
+ \bbl@xin@{.identification.}{.\bbl@section.}%
+ \ifin@
+ \bbl@exp{\\\g@addto@macro\\\bbl@inidata{%
+ \\\bbl@elt{identification}{\bbl@tempa}{\the\toks@}}}%
+ \fi}%
+% \end{macrocode}
+%
+% Now, the ‘main loop’, which \textbf{**must be executed inside a
+% group**}. At this point, |\bbl@inidata| may contain data declared in
+% |\babelprovide|, with ‘slashed’ keys. There are 3 steps: first read
+% the ini file and store it; then traverse the stored values, and
+% process some groups if required (date, captions, labels, counters);
+% finally, ‘export’ some values by defining global macros
+% (identification, typography, characters, numbers). The second
+% argument is 0 when called to read the minimal data for fonts; with
+% |\babelprovide| it's either 1 or 2.
+%
+% \begin{macrocode}
+\ifx\bbl@readstream\@undefined
+ \csname newread\endcsname\bbl@readstream
+\fi
+\def\bbl@read@ini#1#2{%
\openin\bbl@readstream=babel-#1.ini
\ifeof\bbl@readstream
\bbl@error
@@ -11167,12 +11176,20 @@ help from Bernd Raichle, for which I am grateful.
is not complete.}%
{Fix the name or reinstall babel.}%
\else
+ % Store ini data in \bbl@inidata
\catcode`\[=12 \catcode`\]=12 \catcode`\==12 \catcode`\&=12
\catcode`\;=12 \catcode`\|=12 \catcode`\%=14 \catcode`\-=12
\bbl@info{Importing
- \ifcase#2 \or font and identification \or basic \fi
- data for \languagename\\%
+ \ifcase#2font and identification \or basic \fi
+ data for \languagename\\%
from babel-#1.ini. Reported}%
+ \ifnum#2=\z@
+ \global\let\bbl@inidata\@empty
+ \let\bbl@inistore\bbl@inistore@min % Remember it's local
+ \fi
+ \def\bbl@section{identification}%
+ \bbl@exp{\\\bbl@inistore tag.ini=#1\\\@@}%
+ \bbl@inistore load.level=#2\@@
\loop
\if T\ifeof\bbl@readstream F\fi T\relax % Trick, because inside \loop
\endlinechar\m@ne
@@ -11182,95 +11199,70 @@ help from Bernd Raichle, for which I am grateful.
\expandafter\bbl@iniline\bbl@line\bbl@iniline
\fi
\repeat
+ % Process stored data
+ \bbl@csarg\xdef{lini@\languagename}{#1}%
+ \let\bbl@savestrings\@empty
+ \let\bbl@savetoday\@empty
+ \let\bbl@savedate\@empty
+ \def\bbl@elt##1##2##3{%
+ \def\bbl@section{##1}%
+ \in@{=date.}{=##1}% Find a better place
+ \ifin@
+ \bbl@ini@calendar{##1}%
+ \fi
+ \global\bbl@csarg\let{bbl@KVP@##1/##2}\relax
+ \bbl@ifunset{bbl@inikv@##1}{}%
+ {\csname bbl@inikv@##1\endcsname{##2}{##3}}}%
+ \bbl@inidata
+ % 'Export' data
+ \bbl@ini@exports{#2}%
+ \global\bbl@csarg\let{inidata@\languagename}\bbl@inidata
+ \global\let\bbl@inidata\@empty
+ \bbl@exp{\\\bbl@add@list\\\bbl@ini@loaded{\languagename}}%
+ \bbl@toglobal\bbl@ini@loaded
\fi}
-\def\bbl@read@ini#1#2{%
- \bbl@csarg\xdef{lini@\languagename}{#1}%
- \let\bbl@section\@empty
- \let\bbl@savestrings\@empty
- \let\bbl@savetoday\@empty
- \let\bbl@savedate\@empty
- \let\bbl@inireader\bbl@iniskip
- \bbl@fetch@ini{#1}{#2}%
- \bbl@foreach\bbl@renewlist{%
- \bbl@ifunset{bbl@renew@##1}{}{\bbl@inisec[##1]\@@}}%
- \global\let\bbl@renewlist\@empty
- % Ends last section. See \bbl@inisec
- \def\bbl@elt##1##2{\bbl@inireader##1=##2\@@}%
- \bbl@cs{renew@\bbl@section}%
- \global\bbl@csarg\let{renew@\bbl@section}\relax
- \bbl@cs{secpost@\bbl@section}%
- \bbl@csarg{\global\expandafter\let}{inidata@\languagename}\bbl@inidata
- \bbl@exp{\\\bbl@add@list\\\bbl@ini@loaded{\languagename}}%
- \bbl@toglobal\bbl@ini@loaded}
-\def\bbl@iniline#1\bbl@iniline{%
- \@ifnextchar[\bbl@inisec{\@ifnextchar;\bbl@iniskip\bbl@inipreread}#1\@@}% ]
% \end{macrocode}
%
-% The special cases for comment lines and sections are handled by the
-% two following commands. In sections, we provide the posibility to
-% take extra actions at the end or at the start. By default, key=val
-% pairs are ignored. The |secpost| ``hook'' is used only by
-% `identification', while |secpre| only by |date.gregorian.licr|.
+% A somewhat hackish tool to handle calendar sections. To be improved.
%
% \begin{macrocode}
-\def\bbl@iniskip#1\@@{}% if starts with ;
-\def\bbl@inisec[#1]#2\@@{% if starts with opening bracket
- \def\bbl@elt##1##2{%
- \expandafter\toks@\expandafter{%
- \expandafter{\bbl@section}{##1}{##2}}%
- \bbl@exp{%
- \\\g@addto@macro\\\bbl@inidata{\\\bbl@elt\the\toks@}}%
- \bbl@inireader##1=##2\@@}%
- \bbl@cs{renew@\bbl@section}%
- \global\bbl@csarg\let{renew@\bbl@section}\relax
- \bbl@cs{secpost@\bbl@section}%
- % The previous code belongs to the previous section.
- % --------------------------
- % Now start the current one.
- \in@{=date.}{=#1}%
- \ifin@
- \lowercase{\def\bbl@tempa{=#1=}}%
- \bbl@replace\bbl@tempa{=date.gregorian}{}%
- \bbl@replace\bbl@tempa{=date.}{}%
- \in@{.licr=}{#1=}%
- \ifin@
- \ifcase\bbl@engine
- \bbl@replace\bbl@tempa{.licr=}{}%
- \else
- \let\bbl@tempa\relax
- \fi
- \fi
- \ifx\bbl@tempa\relax\else
- \bbl@replace\bbl@tempa{=}{}%
- \bbl@exp{%
- \def\<bbl@inikv@#1>####1=####2\\\@@{%
- \\\bbl@inidate####1...\relax{####2}{\bbl@tempa}}}%
- \fi
- \fi
- \def\bbl@section{#1}%
- \def\bbl@elt##1##2{%
- \@namedef{bbl@KVP@#1/##1}{}}%
- \bbl@cs{renew@#1}%
- \bbl@cs{secpre@#1}% pre-section `hook'
- \bbl@ifunset{bbl@inikv@#1}%
- {\let\bbl@inireader\bbl@iniskip}%
- {\bbl@exp{\let\\\bbl@inireader\<bbl@inikv@#1>}}}
-\let\bbl@renewlist\@empty
-\def\bbl@renewinikey#1/#2\@@#3{%
- \bbl@ifunset{bbl@renew@#1}%
- {\bbl@add@list\bbl@renewlist{#1}}%
- {}%
- \bbl@csarg\bbl@add{renew@#1}{\bbl@elt{#2}{#3}}}
-% \end{macrocode}
-%
-% Reads a key=val line and stores the trimmed val in
-% |\bbl@@kv@<section>.<key>|.
+\def\bbl@ini@calendar#1{%
+ \lowercase{\def\bbl@tempa{=#1=}}%
+ \bbl@replace\bbl@tempa{=date.gregorian}{}%
+ \bbl@replace\bbl@tempa{=date.}{}%
+ \in@{.licr=}{#1=}%
+ \ifin@
+ \ifcase\bbl@engine
+ \bbl@replace\bbl@tempa{.licr=}{}%
+ \else
+ \let\bbl@tempa\relax
+ \fi
+ \fi
+ \ifx\bbl@tempa\relax\else
+ \bbl@replace\bbl@tempa{=}{}%
+ \bbl@exp{%
+ \def\<bbl@inikv@#1>####1####2{%
+ \\\bbl@inidate####1...\relax{####2}{\bbl@tempa}}}%
+ \fi}
+% \end{macrocode}
+%
+% A key with a slash in |\babelprovide| replaces the value in the |ini|
+% file (which is ignored altogether). The mechanism is simple (but
+% suboptimal): add the data to the |ini| one (at this point the |ini|
+% file has not yet been read), and define a dummy macro. When the |ini|
+% file is read, just skip the corresponding key and reset the macro (in
+% |\bbl@inistore| above).
+%
%
% \begin{macrocode}
-\def\bbl@inikv#1=#2\@@{% key=value
- \bbl@trim@def\bbl@tempa{#1}%
- \bbl@trim\toks@{#2}%
- \bbl@csarg\edef{@kv@\bbl@section.\bbl@tempa}{\the\toks@}}
+\def\bbl@renewinikey#1/#2\@@#3{%
+ \edef\bbl@tempa{\zap@space #1 \@empty}% section
+ \edef\bbl@tempb{\zap@space #2 \@empty}% key
+ \bbl@trim\toks@{#3}% value
+ \bbl@exp{%
+ \global\let\<bbl@KVP@\bbl@tempa/\bbl@tempb>\\\@empty % just a flag
+ \\\g@addto@macro\\\bbl@inidata{%
+ \\\bbl@elt{\bbl@tempa}{\bbl@tempb}{\the\toks@}}}}%
% \end{macrocode}
%
% The previous assignments are local, so we need to export them. If
@@ -11289,7 +11281,7 @@ help from Bernd Raichle, for which I am grateful.
%
% Key-value pairs are treated differently depending on the section in
% the |ini| file. The following macros are the readers for
-% |identification| and |typography|. Note |\bbl@secpost@identification|
+% |identification| and |typography|. Note |\bbl@ini@exports|
% is called always (via |\bbl@inisec|), while |\bbl@after@ini| must be
% called explicitly after |\bbl@read@ini| if necessary.
%
@@ -11301,8 +11293,8 @@ help from Bernd Raichle, for which I am grateful.
\bbl@cs{@kv@identification.warning#1}\\%
Reported }}}
%
-\let\bbl@inikv@identification\bbl@inikv
-\def\bbl@secpost@identification{%
+\def\bbl@ini@exports#1{%
+ % Identification always exported
\bbl@iniwarning{}%
\ifcase\bbl@engine
\bbl@iniwarning{.pdflatex}%
@@ -11322,15 +11314,46 @@ help from Bernd Raichle, for which I am grateful.
{\csname bbl@esname@\languagename\endcsname}}%
\bbl@exportkey{sbcp}{identification.script.tag.bcp47}{}%
\bbl@exportkey{sotf}{identification.script.tag.opentype}{DFLT}%
+ % Also maps bcp47 -> languagename
\ifbbl@bcptoname
\bbl@csarg\xdef{bcp@map@\bbl@cl{tbcp}}{\languagename}%
+ \fi
+ % Conditional
+ \ifnum#1>\z@ % 0 = only info, 1, 2 = basic, (re)new
+ \bbl@exportkey{lnbrk}{typography.linebreaking}{h}%
+ \bbl@exportkey{hyphr}{typography.hyphenrules}{}%
+ \bbl@exportkey{lfthm}{typography.lefthyphenmin}{2}%
+ \bbl@exportkey{rgthm}{typography.righthyphenmin}{3}%
+ \bbl@exportkey{prehc}{typography.prehyphenchar}{}%
+ \bbl@exportkey{hyotl}{typography.hyphenate.other.locale}{}%
+ \bbl@exportkey{hyots}{typography.hyphenate.other.script}{}%
+ \bbl@exportkey{intsp}{typography.intraspace}{}%
+ \bbl@exportkey{chrng}{characters.ranges}{}%
+ \bbl@exportkey{dgnat}{numbers.digits.native}{}%
+ \bbl@exportkey{frspc}{typography.frenchspacing}{u}%
+ \ifnum#1=\tw@ % only (re)new
+ \bbl@exportkey{rqtex}{identification.require.babel}{}%
+ \bbl@toglobal\bbl@savetoday
+ \bbl@toglobal\bbl@savedate
+ \bbl@savestrings
+ \fi
\fi}
% \end{macrocode}
%
+% A shared handler for key=val lines to be stored in
+% |\bbl@@kv@<section>.<key>|.
+%
+% \begin{macrocode}
+\def\bbl@inikv#1#2{% key=value
+ \toks@{#2}% This hides #'s from ini values
+ \bbl@csarg\edef{@kv@\bbl@section.#1}{\the\toks@}}
+% \end{macrocode}
+%
% By default, the following sections are just read. Actions are taken
% later.
%
% \begin{macrocode}
+\let\bbl@inikv@identification\bbl@inikv
\let\bbl@inikv@typography\bbl@inikv
\let\bbl@inikv@characters\bbl@inikv
\let\bbl@inikv@numbers\bbl@inikv
@@ -11342,7 +11365,7 @@ help from Bernd Raichle, for which I am grateful.
% the ‘units’.
%
% \begin{macrocode}
-\def\bbl@inikv@counters#1=#2\@@{%
+\def\bbl@inikv@counters#1#2{%
\bbl@ifsamestring{#1}{digits}%
{\bbl@error{The counter name 'digits' is reserved for mapping\\%
decimal digits}%
@@ -11365,13 +11388,6 @@ help from Bernd Raichle, for which I am grateful.
\expandafter\bbl@buildifcase\bbl@tempb* \\ % Space after \\
\bbl@csarg{\global\expandafter\let}{cntr@#1@\languagename}\bbl@tempa
\fi}
-\def\bbl@after@ini{%
- \bbl@linebreak@export
- \bbl@exportkey{dgnat}{numbers.digits.native}{}%
- \bbl@exportkey{rqtex}{identification.require.babel}{}%
- \bbl@exportkey{frspc}{typography.frenchspacing}{u}% unset
- \bbl@toglobal\bbl@savetoday
- \bbl@toglobal\bbl@savedate}
% \end{macrocode}
%
% Now |captions| and |captions.licr|, depending on the engine. And
@@ -11381,10 +11397,10 @@ help from Bernd Raichle, for which I am grateful.
%
% \begin{macrocode}
\ifcase\bbl@engine
- \bbl@csarg\def{inikv@captions.licr}#1=#2\@@{%
+ \bbl@csarg\def{inikv@captions.licr}#1#2{%
\bbl@ini@captions@aux{#1}{#2}}
\else
- \def\bbl@inikv@captions#1=#2\@@{%
+ \def\bbl@inikv@captions#1#2{%
\bbl@ini@captions@aux{#1}{#2}}
\fi
% \end{macrocode}
@@ -11445,7 +11461,7 @@ help from Bernd Raichle, for which I am grateful.
\bbl@ifunset{bbl@map@#1@\languagename}%
{\@nameuse{#1}}%
{\@nameuse{bbl@map@#1@\languagename}}}
-\def\bbl@inikv@labels#1=#2\@@{%
+\def\bbl@inikv@labels#1#2{%
\in@{.map}{#1}%
\ifin@
\ifx\bbl@KVP@labels\@nil\else
@@ -11665,7 +11681,7 @@ help from Bernd Raichle, for which I am grateful.
% \begin{macrocode}
\def\bbl@provide@lsys#1{%
\bbl@ifunset{bbl@lname@#1}%
- {\bbl@ini@basic{#1}}%
+ {\bbl@load@info{#1}}%
{}%
\bbl@csarg\let{lsys@#1}\@empty
\bbl@ifunset{bbl@sname@#1}{\bbl@csarg\gdef{sname@#1}{Default}}{}%
@@ -11717,14 +11733,13 @@ help from Bernd Raichle, for which I am grateful.
% must be enabled. This means we must make sure a few characters are
% not active. The |ini| is not read directly, but with a proxy |tex|
% file named as the language (which means any code in it must be
-% skipped, too.
+% skipped, too).
%
% \begin{macrocode}
-\def\bbl@ini@basic#1{%
+\def\bbl@load@info#1{%
\def\BabelBeforeIni##1##2{%
\begingroup
- \bbl@add\bbl@secpost@identification{\closein\bbl@readstream }%
- \bbl@read@ini{##1}1%
+ \bbl@read@ini{##1}0%
\endinput % babel- .tex may contain onlypreamble's
\endgroup}% boxed, to avoid extra spaces:
{\bbl@input@texini{#1}}}
@@ -11850,7 +11865,7 @@ help from Bernd Raichle, for which I am grateful.
\newcommand\BabelEnsureInfo{%
\ifx\InputIfFileExists\@undefined\else
\def\bbl@ensureinfo##1{%
- \bbl@ifunset{bbl@lname@##1}{\bbl@ini@basic{##1}}{}}%
+ \bbl@ifunset{bbl@lname@##1}{\bbl@load@info{##1}}{}}%
\fi
\bbl@foreach\bbl@loaded{{%
\def\languagename{##1}%
@@ -13373,7 +13388,7 @@ help from Bernd Raichle, for which I am grateful.
\let\bbl@cjkintraspace\relax
\directlua{
Babel = Babel or {}
- require'babel-data-cjk.lua'
+ require('babel-data-cjk.lua')
Babel.cjk_enabled = true
function Babel.cjk_linebreak(head)
local GLYPH = node.id'glyph'
@@ -14276,21 +14291,86 @@ end
\ifcase\bbl@thetextdir
\let\bbl@pictresetdir\relax
\else
- \bodydir TLT
+ \ifcase#1\bodydir TLT % Remember this sets the inner boxes
+ \or\textdir TLT
+ \else\bodydir TLT \textdir TLT
+ \fi
% \(text|par)dir required in pgf:
\def\bbl@pictresetdir{\bodydir TRT\pardir TRT\textdir TRT\relax}%
\fi}%
\ifx\AddToHook\@undefined\else
- \AddToHook{env/picture/begin}{\bbl@pictsetdir\z@}%
+ \AddToHook{env/picture/begin}{\bbl@pictsetdir\tw@}%
+ \directlua{
+ Babel.get_picture_dir = true
+ Babel.picture_has_bidi = 0
+ function Babel.picture_dir (head)
+ if not Babel.get_picture_dir then return head end
+ for item in node.traverse(head) do
+ if item.id == node.id'glyph' then
+ local itemchar = item.char
+ % TODO. Copypaste pattern from Babel.bidi (-r)
+ local chardata = Babel.characters[itemchar]
+ local dir = chardata and chardata.d or nil
+ if not dir then
+ for nn, et in ipairs(Babel.ranges) do
+ if itemchar < et[1] then
+ break
+ elseif itemchar <= et[2] then
+ dir = et[3]
+ break
+ end
+ end
+ end
+ if dir and (dir == 'al' or dir == 'r') then
+ Babel.picture_has_bidi = 1
+ end
+ end
+ end
+ return head
+ end
+ luatexbase.add_to_callback("hpack_filter", Babel.picture_dir,
+ "Babel.picture_dir")
+ }%
+ \AtBeginDocument{%
+ \long\def\put(#1,#2)#3{%
+ \@killglue
+ % Try:
+ \ifx\bbl@pictresetdir\relax
+ \def\bbl@tempc{0}%
+ \else
+ \directlua{
+ Babel.get_picture_dir = true
+ Babel.picture_has_bidi = 0
+ }%
+ \setbox\z@\hb@xt@\z@{%
+ \@defaultunitsset\@tempdimc{#1}\unitlength
+ \kern\@tempdimc
+ #3\hss}%
+ \edef\bbl@tempc{\directlua{tex.print(Babel.picture_has_bidi)}}%
+ \fi
+ % Do:
+ \@defaultunitsset\@tempdimc{#2}\unitlength
+ \raise\@tempdimc\hb@xt@\z@{%
+ \@defaultunitsset\@tempdimc{#1}\unitlength
+ \kern\@tempdimc
+ {\ifnum\bbl@tempc>\z@\bbl@pictresetdir\fi#3}\hss}%
+ \ignorespaces}%
+ \MakeRobust\put}%
\fi
\AtBeginDocument
{\ifx\tikz@atbegin@node\@undefined\else
\let\bbl@OL@pgfpicture\pgfpicture
\bbl@sreplace\pgfpicture{\pgfpicturetrue}%
- {\bbl@pictsetdir\@ne\pgfpicturetrue}%
- \bbl@add\pgfsys@beginpicture{\bbl@pictsetdir\@ne}%
+ {\bbl@pictsetdir\z@\pgfpicturetrue}%
+ \bbl@add\pgfsys@beginpicture{\bbl@pictsetdir\z@}%
\bbl@add\tikz@atbegin@node{\bbl@pictresetdir}%
- \fi}}
+ \bbl@sreplace\tikz{\begingroup}%
+ {\begingroup\bbl@pictsetdir\tw@}%
+ \fi
+ \ifx\AddToHook\@undefined\else
+ \AddToHook{env/tcolorbox/begin}{\bbl@pictsetdir\@ne}%
+ \fi
+ }}
{}
% \end{macrocode}
%