summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/babel
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-05-02 22:52:12 +0000
committerKarl Berry <karl@freefriends.org>2019-05-02 22:52:12 +0000
commit827d1879347a5aacecb471a576e1654149ad8a39 (patch)
tree773b8042298d8d685b88fd99261838dea531324f /Master/texmf-dist/source/latex/babel
parent4de7376b42147ed2246d7320e079bdebd84d9503 (diff)
babel (22apr19)
git-svn-id: svn://tug.org/texlive/trunk@50951 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/babel')
-rw-r--r--Master/texmf-dist/source/latex/babel/babel.dtx350
-rw-r--r--Master/texmf-dist/source/latex/babel/babel.ins2
-rw-r--r--Master/texmf-dist/source/latex/babel/bbcompat.dtx2
-rw-r--r--Master/texmf-dist/source/latex/babel/locale.zipbin710087 -> 710087 bytes
4 files changed, 274 insertions, 80 deletions
diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx
index f182740cffc..f90f975f092 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}[2019/04/03 v3.29 The Babel package]
+\ProvidesFile{babel.dtx}[2019/04/22 v3.30 The Babel package]
\documentclass{ltxdoc}
\GetFileInfo{babel.dtx}
\usepackage{fontspec}
@@ -1099,7 +1099,8 @@ can take the following values:
\end{description}
\Describe{bidi=}{\texttt{default} $\string|$ \texttt{basic}
- $\string|$ \texttt{basic-r}}
+ $\string|$ \texttt{basic-r} $\string|$ \texttt{bidi-l} $\string|$
+ \texttt{bidi-r}}
\New{3.14} Selects the bidi algorithm to be used in \luatex{} and
\xetex{}. See sec.~\ref{bidi}.
@@ -1936,6 +1937,18 @@ to select fonts in addition to the three basic families.
for that matter).
\end{warning}
+\begin{troubleshooting}
+\trouble{Package fontspec Warning: 'Language 'LANG' not available for
+font 'FONT' with script 'SCRIPT' 'Default' language used instead'}
+\textit{Package fontspec Warning: 'Language 'LANG' not available for
+font 'FONT' with script 'SCRIPT' 'Default' language used instead'}.
+This warning is shown by \textsf{fontspec}, not by \babel. It could be
+irrelevant for English, but not for many other languages, including
+Urdu and Turkish. This is a useful and harmless warning, and if
+everything is fine with your document the best thing you can do is just
+to ignore it altogether.
+\end{troubleshooting}
+
\subsection{Modifying a language}
Modifying the behavior of a language (say, the chapter “caption”), is
@@ -2105,10 +2118,10 @@ inconsistent, this makes setting a language up easier in most typical
cases.
\Describe{mapfont=}{\texttt{direction}}
-Assigns the font for the writing direction of this
-language.\footnote{There will be another value, \texttt{language}, not
-yet implemented.} More precisely, what |mapfont=direction| means is,
-‘when a character has the same direction as the script for the
+Assigns the font for the writing direction of this language (only with
+|bidi=basic|).\footnote{There will be another value, \texttt{language},
+not yet implemented.} More precisely, what |mapfont=direction| means
+is, ‘when a character has the same direction as the script for the
“provided” language, then change its font to that set for this
language’. There are 3 directions, following the bidi Unicode
algorithm, namely, Arabic-like, Hebrew-like and left to
@@ -2120,16 +2133,17 @@ Sets the interword space for the writing system of the language, in em
units (so, |0 .1 0| is |0em plus .1em|). Like |\spaceskip|, the em unit
applied is that of the current text (more precisely, the previous
glyph). Currently used only in Southeast Asian scrips, like Thai.
+Requires |import|.
\Describe{intrapenalty=}{\meta{penalty}}
Sets the interword penalty for the writing system of this language.
Currently used only in Southeast Asian scrips, like Thai. Ignored if 0
-(which is the default value).
+(which is the default value). Requires |import|.
\begin{note}
- (1) If you need shorthands, you can use |\useshorthands| and
- |\defineshorthand| as described above. (2) Captions and |\today| are
- ``ensured'' with |\babelensure| (this is the default in
+ (1) If you need shorthands, you can define them with |\useshorthands|
+ and |\defineshorthand| as described above. (2) Captions and |\today|
+ are ``ensured'' with |\babelensure| (this is the default in
|ini|-based languages).
\end{note}
@@ -2142,7 +2156,8 @@ Currently used only in Southeast Asian scrips, like Thai. Ignored if 0
the native digits of that language; the second takes a counter name as
argument. With the option |maparabic| in |\babelprovide|, |\arabic| is
redefined to produce the native digits (this is done \textit{globally},
-to avoid inconsistencies in, for example, page numbering).
+to avoid inconsistencies in, for example, page numbering, and note as
+well dates do not rely on |\arabic|.)
For example:
\begin{verbatim}
@@ -2161,6 +2176,14 @@ Languages providing native digits in all or some variants are
lrc, ml, mr, my, mzn, ne, or, pa, ps, ta, te, th, ug, ur, uz, vai, yue,
zh.}
+\New{3.30} With \luatex{} there is an alternative approach for mapping
+digits, namely, |mapdigits|. Conversion is based on the language and it
+is applied to the typeset text (not math, PDF bookmarks, etc.) before
+bidi and fonts are processed (ie, to the node list as generated by the
+\TeX{} code). This means the local digits have the correct
+bidirectional behavior (unlike |Numbers=Arabic| in \textsf{fontspec},
+which is not recommended).
+
\subsection{Getting the current language name}
\Describe{\languagename}{}
@@ -2375,17 +2398,26 @@ differ in the way `weak' numeric characters are ordered (eg, Arabic
There are some package options controlling bidi writing.
\Describe{bidi=}{\texttt{default} $\string|$ \texttt{basic}
- $\string|$ \texttt{basic-r}}
+ $\string|$ \texttt{basic-r} $\string|$ \texttt{bidi-l} $\string|$
+ \texttt{bidi-l}}
\New{3.14} Selects the bidi algorithm to be used. With |default| the
bidi mechanism is just activated (by default it is not), but every
change must by marked up. In \xetex{} and \pdftex{} this is the only
-option. In \luatex, |basic-r| provides a simple and fast method for R
+option.
+
+In \luatex, |basic-r| provides a simple and fast method for R
text, which handles numbers and unmarked L text within an R context in
-typical cases. \New{3.19} Finally, |basic| supports both L and R text.
+typical cases. \New{3.19} Finally, |basic| supports both L and R text
+and it is the preferred method (support for |basic-r| is now limited).
(They are named \texttt{basic} mainly because they only consider the
intrinsic direction of scripts and weak directionality.)
+\New{3.29} In \xetex, |bidi-r| and |bidi-l| resort to the package
+\textsf{bidi} (by Vafa Khalighi). Integration is still somewhat
+tentative, but it mostly works. For RL documents use the former, and
+for LR ones use the latter.
+
There are samples on GitHub, under \texttt{/required/babel/samples}.
See particularly |lua-bidibasic.tex| and |lua-secenum.tex|.
@@ -2507,7 +2539,7 @@ required by all engines.
\item[sectioning] makes sure the sectioning macros are typeset in the
main language, but with the title text in the current language (see
- below |\BabelPatchSection| for further details).
+ below |\BabelPatchSection| for further details).
\item[counters] required in all engines (except \luatex{} with
|bidi=basic|) to reorder section numbers and the like (eg,
@@ -2527,7 +2559,15 @@ required by all engines.
systems in general. Expect some minor readjustments.}
\item[lists] required in \xetex{} and \pdftex{}, but only in
- multilingual documents in \luatex{}.
+bidirectional (with both R and L paragraphs) documents in \luatex{}.
+
+\begin{warning}
+ As of April 2019 there is a bug with |\parshape| in \luatex{} (a
+ \TeX{} primitive) which makes lists to be horizontally misplaced if
+ they are inside a |\vbox| (like |minipage|) and the current direction
+ is different from the main one. A workaround is to restore the main
+ language before the box and then set the local one inside.
+\end{warning}
\item[contents] required in \xetex{} and \pdftex{}; in \luatex{}
toc entries are R by default if the main language is R.
@@ -2538,9 +2578,9 @@ required by all engines.
\textsf{multicol}).
\item[footnotes] not required in monolingual documents, but it may be
- useful in multilingual documents in all engines; you may use
- alternatively |\BabelFootnote| described below (what this options
- does exactly is also explained there).
+ useful in bidirectional documents (with both R and L paragraphs) in all
+ engines; you may use alternatively |\BabelFootnote| described below
+ (what this options does exactly is also explained there).
\item[captions] is similar to |sectioning|, but for |\caption|; not
required in monolingual documents with \luatex{}, but may be
@@ -2550,13 +2590,21 @@ required by all engines.
\item[tabular] required in \luatex{} for R |tabular| (it has been
tested only with simple tables, so expect some readjustments in the
future); ignored in \pdftex{} or \xetex{} (which will not support a
- similar option in the short term) \New{3.18},
+ similar option in the short term) \New{3.18}.
\item[extras] is used for miscellaneous readjustments which do not fit into
the previous groups. Currently redefines in \luatex{} |\underline| and
|\LaTeX2e| \New{3.19}.
\end{description}
+\begin{example}
+ Typically, in an Arabic document you would need:
+\begin{verbatim}
+\usepackage[bidi=basic,
+ layout=counters.tabular]{babel}
+\end{verbatim}
+\end{example}
+
\Describe{\babelsublr}{\marg{lr-text}}
Digits in \pdftex{} must be marked up explicitly (unlike \luatex{} with
@@ -3917,8 +3965,8 @@ help from Bernd Raichle, for which I am grateful.
% \section{Tools}
%
% \begin{macrocode}
-%<<version=3.29>>
-%<<date=2019/04/03>>
+%<<version=3.30>>
+%<<date=2019/04/22>>
% \end{macrocode}
%
% \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -4363,6 +4411,9 @@ help from Bernd Raichle, for which I am grateful.
% |\bbl@languages|), get the name of the 0-th to show the actual
% language used.
%
+% \changes{babel~3.30}{2019/04/22}{Callbacks aren't specific to
+% bidi any more, so they are moved.}
+%
% \begin{macrocode}
\ifx\bbl@languages\@undefined\else
\begingroup
@@ -4383,6 +4434,46 @@ help from Bernd Raichle, for which I am grateful.
\bbl@languages
\fi
\ifodd\bbl@engine
+ \def\bbl@activate@preotf{%
+ \let\bbl@activate@preotf\relax % only once
+ \directlua{
+ Babel = Babel or {}
+ %
+ function Babel.pre_otfload_v(head)
+ if Babel.numbers and Babel.digits_mapped then
+ head = Babel.numbers(head)
+ end
+ if Babel.bidi_enabled then
+ head = Babel.bidi(head, false, dir)
+ end
+ return head
+ end
+ %
+ function Babel.pre_otfload_h(head, gc, sz, pt, dir)
+ if Babel.numbers and Babel.digits_mapped then
+ head = Babel.numbers(head)
+ end
+ if Babel.fixboxdirs then % Temporary!
+ head = Babel.fixboxdirs(head)
+ end
+ if Babel.bidi_enabled then
+ head = Babel.bidi(head, false, dir)
+ end
+ return head
+ end
+ %
+ luatexbase.add_to_callback('pre_linebreak_filter',
+ Babel.pre_otfload_v,
+ 'Babel.pre_otfload_v',
+ luatexbase.priority_in_callback('pre_linebreak_filter',
+ 'luaotfload.node_processor') or nil)
+ %
+ luatexbase.add_to_callback('hpack_filter',
+ Babel.pre_otfload_h,
+ 'Babel.pre_otfload_h',
+ luatexbase.priority_in_callback('hpack_filter',
+ 'luaotfload.node_processor') or nil)
+ }}
\let\bbl@tempa\relax
\@ifpackagewith{babel}{bidi=basic}%
{\def\bbl@tempa{basic}}%
@@ -4396,17 +4487,8 @@ help from Bernd Raichle, for which I am grateful.
\directlua{
require('babel-bidi.lua')
require('babel-bidi-\bbl@tempa.lua')
- luatexbase.add_to_callback('pre_linebreak_filter',
- Babel.pre_otfload_v,
- 'Babel.pre_otfload_v',
- luatexbase.priority_in_callback('pre_linebreak_filter',
- 'luaotfload.node_processor') or nil)
- luatexbase.add_to_callback('hpack_filter',
- Babel.pre_otfload_h,
- 'Babel.pre_otfload_h',
- luatexbase.priority_in_callback('hpack_filter',
- 'luaotfload.node_processor') or nil)
- }
+ }
+ \bbl@activate@preotf
\fi
\fi
% \end{macrocode}
@@ -7769,9 +7851,9 @@ help from Bernd Raichle, for which I am grateful.
% \subsection{Creating languages}
%
% |\babelprovide| is a general purpose tool for creating and modifying
-% languages. It creates the language infrastructure, and
-% loads, if requested, an |ini| file. It may be used in conjunction to
-% previouly loaded |ldf| files.
+% languages. It creates the language infrastructure, and loads, if
+% requested, an |ini| file. It may be used in conjunction to previouly
+% loaded |ldf| files.
%
% \changes{3.10}{2017/05/19}{Added \cs{babelprovide}}
% \changes{3.13}{2017/08/30}{Added \cs{import}, which also reads
@@ -7786,12 +7868,21 @@ help from Bernd Raichle, for which I am grateful.
% \changes{babel~3.23}{2018/09/01}{Valueless import}
% \changes{babel~3.26}{2018/10/16}{Quick fix for xetex - test the
% script for intraspace}
+% \changes{3.30}{2019/04/22}{Read some basic parameters from ini
+% even without import.}
+% \changes{3.30}{2019/04/22}{Native digits (lua level).}
+% \changes{3.30}{2019/04/22}{New attribute in luatex for `locale'. Also
+% \cs{localeid}}
%
% \begin{macrocode}
\bbl@trace{Creating languages and reading ini files}
\newcommand\babelprovide[2][]{%
\let\bbl@savelangname\languagename
+ \edef\bbl@savelocaleid{\the\localeid}%
+ % Set name and locale id
\def\languagename{#2}%
+ \bbl@id@assign
+ \chardef\localeid\@nameuse{bbl@id@@\languagename}%
\let\bbl@KVP@captions\@nil
\let\bbl@KVP@import\@nil
\let\bbl@KVP@main\@nil
@@ -7801,6 +7892,7 @@ help from Bernd Raichle, for which I am grateful.
\let\bbl@KVP@hyphenrules\@nil
\let\bbl@KVP@mapfont\@nil
\let\bbl@KVP@maparabic\@nil
+ \let\bbl@KVP@mapdigits\@nil
\let\bbl@KVP@intraspace\@nil
\let\bbl@KVP@intrapenalty\@nil
\bbl@forkv{#1}{\bbl@csarg\def{KVP@##1}{##2}}% TODO - error handling
@@ -7833,7 +7925,25 @@ help from Bernd Raichle, for which I am grateful.
\\\foreignlanguage{\languagename}%
{####1}}}}%
{}%
- % To override script and language names
+ % 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 load the very basic parameters: ids and a few
+ % more.
+ \bbl@ifunset{bbl@lname@#2}%
+ {\def\BabelBeforeIni##1##2{%
+ \begingroup
+ \catcode`\[=12 \catcode`\]=12 \catcode`\==12 %
+ \let\bbl@ini@captions@aux\@gobbletwo
+ \def\bbl@inidate ####1.####2.####3.####4\relax ####5####6{}%
+ \let\bbl@inikv@typography\bbl@iniskip
+ \bbl@read@ini{##1}%
+ \bbl@exportkey{chrng}{characters.ranges}{}%
+ \bbl@exportkey{dgnat}{numbers.digits.native}{}%
+ \endgroup}% boxed, to avoid extra spaces:
+ {\setbox\z@\hbox{\InputIfFileExists{babel-#2.tex}{}{}}}}%
+ {}%
+ % -
+ % Override script and language names with script= and language=
\ifx\bbl@KVP@script\@nil\else
\bbl@csarg\edef{sname@#2}{\bbl@KVP@script}%
\fi
@@ -7865,7 +7975,7 @@ help from Bernd Raichle, for which I am grateful.
\fi
\bbl@exp{\\\bbl@add\\\bbl@mapselect{\\\bbl@mapdir{\languagename}}}%
\fi
- % For Southeast Asian, if interspace in ini
+ % For Southeast Asian, if interspace in ini -- TODO: as hook
\ifcase\bbl@engine\or
\bbl@ifunset{bbl@intsp@\languagename}{}%
{\expandafter\ifx\csname bbl@intsp@\languagename\endcsname\@empty\else
@@ -7917,7 +8027,7 @@ help from Bernd Raichle, for which I am grateful.
\fi}%
\fi
\fi
- % Native digits, if provided in ini
+ % Native digits, if provided in ini (TeX level, xe and lua)
\ifcase\bbl@engine\else
\bbl@ifunset{bbl@dgnat@\languagename}{}%
{\expandafter\ifx\csname bbl@dgnat@\languagename\endcsname\@empty\else
@@ -7934,6 +8044,42 @@ help from Bernd Raichle, for which I am grateful.
\fi
\fi}%
\fi
+ % Native digits (lua level).
+ \ifodd\bbl@engine
+ \ifx\bbl@KVP@mapdigits\@nil\else
+ \bbl@ifunset{bbl@dgnat@\languagename}{}%
+ {\RequirePackage{luatexbase}%
+ \bbl@activate@preotf
+ \directlua{
+ Babel = Babel or {} %%% -> presets in luababel
+ Babel.digits_mapped = true
+ Babel.digits = Babel.digits or {}
+ Babel.digits[\the\localeid] =
+ table.pack(string.utfvalue('\bbl@cs{dgnat@\languagename}'))
+ if not Babel.numbers then
+ function Babel.numbers(head)
+ local LOCALE = luatexbase.registernumber'bbl@attr@locale'
+ local GLYPH = node.id'glyph'
+ local inmath = false
+ for item in node.traverse(head) do
+ if not inmath and item.id == GLYPH then
+ local temp = node.get_attribute(item, LOCALE)
+ if Babel.digits[temp] then
+ local chr = item.char
+ if chr > 47 and chr < 58 then
+ item.char = Babel.digits[temp][chr-47]
+ end
+ end
+ elseif item.id == node.id'math' then
+ inmath = (item.subtype == 0)
+ end
+ end
+ return head
+ end
+ end
+ }}
+ \fi
+ \fi
% To load or reaload the babel-*.tex, if require.babel in ini
\bbl@ifunset{bbl@rqtex@\languagename}{}%
{\expandafter\ifx\csname bbl@rqtex@\languagename\endcsname\@empty\else
@@ -7944,7 +8090,8 @@ help from Bernd Raichle, for which I am grateful.
\catcode`\@=\atcatcode
\let\atcatcode\relax
\fi}%
- \let\languagename\bbl@savelangname}
+ \let\languagename\bbl@savelangname
+ \chardef\localeid\bbl@savelocaleid\relax}
% \end{macrocode}
%
% A tool to define the macros for native digits from the list provided
@@ -8083,7 +8230,7 @@ help from Bernd Raichle, for which I am grateful.
%
% \begin{macrocode}
\def\bbl@read@ini#1{%
- \openin1=babel-#1.ini
+ \openin1=babel-#1.ini % FIXME - number must not be hardcoded
\ifeof1
\bbl@error
{There is no ini file for the requested language\\%
@@ -8246,7 +8393,7 @@ help from Bernd Raichle, for which I am grateful.
\ifcase\bbl@engine
\bbl@csarg\def{inikv@date.gregorian.licr}#1=#2\@@{% override
\bbl@inidate#1...\relax{#2}{}}
- \bbl@csarg\def{secpre@date.gregorian.licr}{% discard uni
+ \bbl@csarg\def{secpre@date.gregorian.licr}{% discard uni
\ifcase\bbl@engine\let\bbl@savedate\@empty\fi}
\fi
% eg: 1=months, 2=wide, 3=1, 4=dummy
@@ -9285,7 +9432,7 @@ help from Bernd Raichle, for which I am grateful.
\fi
\fi}
\def\bbl@textdir#1{%
- \bbl@setluadir{text}\textdir{#1}% TODO - ?\linedir
+ \bbl@setluadir{text}\textdir{#1}%
\chardef\bbl@thetextdir#1\relax
\setattribute\bbl@attr@dir{\numexpr\bbl@thepardir*3+#1}}
\def\bbl@pardir#1{%
@@ -9298,9 +9445,9 @@ help from Bernd Raichle, for which I am grateful.
% Activated every math with the package option bidi=:
\def\bbl@mathboxdir{%
\ifcase\bbl@thetextdir\relax
- \everyhbox{\bgroup\aftergroup\egroup\textdir TLT\relax}%
+ \everyhbox{\textdir TLT\relax}%
\else
- \everyhbox{\bgroup\aftergroup\egroup\textdir TRT\relax}%
+ \everyhbox{\textdir TRT\relax}%
\fi}
\else % pdftex=0, xetex=2
\AddBabelHook{babel-bidi}{afterextras}{\bbl@switchdir}
@@ -9679,6 +9826,26 @@ help from Bernd Raichle, for which I am grateful.
% \end{macro}
% \end{macro}
%
+% An alternative way to identify languages (in the \babel{} sense)
+% with a numerical value is introduced in 3.30. This is one of the
+% first steps for a new interface based on the concept of locale,
+% which explains the name of |\localeid|. This means |\l@...| will be
+% reserved for hyphenation patterns.
+%
+% \begin{macrocode}
+\chardef\localeid\z@
+\def\bbl@id@last{0} % No real need for a new counter
+\def\bbl@id@assign{%
+ \bbl@ifunset{bbl@id@@\languagename}%
+ {\count@\bbl@id@last\relax
+ \advance\count@\@ne
+ \bbl@csarg\chardef{id@@\languagename}\count@
+ \edef\bbl@id@last{\the\count@}}%
+ {}}
+% \end{macrocode}
+%
+% The unprotected part of |\selectlanguage|.
+%
% \begin{macrocode}
\expandafter\def\csname selectlanguage \endcsname#1{%
\ifnum\bbl@hymapsel=\@cclv\let\bbl@hymapsel\tw@\fi
@@ -9836,6 +10003,9 @@ help from Bernd Raichle, for which I am grateful.
\babel@beginsave}%
\bbl@usehooks{afterreset}{}%
\languageshorthands{none}%
+ % set the locale id
+ \bbl@id@assign
+ \chardef\localeid\@nameuse{bbl@id@@\languagename}%
% switch captions, date
\ifcase\bbl@select@type
\ifhmode
@@ -10795,6 +10965,9 @@ help from Bernd Raichle, for which I am grateful.
% by LaTeX. Just in case, consider the possibility it has not been
% loaded. First, a couple of definitions related to bidi [misplaced].
%
+% \changes{babel~3.30}{2019/04/22}{Ensure the current textdir inside
+% boxes within math.}
+%
% \begin{macrocode}
%<<*More package options>>
\ifodd\bbl@engine
@@ -10803,9 +10976,11 @@ help from Bernd Raichle, for which I am grateful.
\DeclareOption{bidi=basic}%
{\let\bbl@beforeforeign\leavevmode
\newattribute\bbl@attr@dir
- % TODO - the same trick as bbl@severypar
- % \everymath{\bbl@mathboxdir}%
- % \everydisplay{\bbl@mathboxdir}%
+ % I don't like it, hackish:
+ \frozen@everymath\expandafter{%
+ \expandafter\bbl@mathboxdir\the\frozen@everymath}%
+ \frozen@everydisplay\expandafter{%
+ \expandafter\bbl@mathboxdir\the\frozen@everydisplay}%
\bbl@exp{\output{\bodydir\pagedir\the\output}}%
\AtEndOfPackage{\EnableBabelHook{babel-bidi}}}
\else
@@ -11642,6 +11817,11 @@ help from Bernd Raichle, for which I am grateful.
end
}
\endgroup
+\ifx\newattribute\@undefined\else
+ \newattribute\bbl@attr@locale
+ \AddBabelHook{luatex}{beforeextras}{%
+ \setattribute\bbl@attr@locale\localeid}
+\fi
\def\BabelStringsDefault{unicode}
\let\luabbl@stop\relax
\AddBabelHook{luatex}{encodedcommands}{%
@@ -11836,6 +12016,33 @@ help from Bernd Raichle, for which I am grateful.
<@Font selection@>
% \end{macrocode}
%
+% \textbf{Temporary} fix for luatex $<$1.10, which sometimes inserted a
+% spurious closing dir node with a |\textdir| within |\hbox|es. This
+% will be eventually removed.
+%
+% \begin{macrocode}
+\def\bbl@luafixboxdir{%
+ \setbox\z@\hbox{\textdir TLT}%
+ \directlua{
+ function Babel.first_dir(head)
+ for item in node.traverse_id(node.id'dir', head) do
+ return item
+ end
+ return nil
+ end
+ if Babel.first_dir(tex.box[0].head) then
+ function Babel.fixboxdirs(head)
+ local fd = Babel.first_dir(head)
+ if fd and fd.dir:sub(1,1) == '-' then
+ head = node.remove(head, fd)
+ end
+ return head
+ end
+ end
+ }}
+\AtBeginDocument{\bbl@luafixboxdir}
+% \end{macrocode}
+%
% \subsection{Layout}
%
% \textbf{Work in progress}.
@@ -18113,15 +18320,16 @@ Babel.characters={
% excels, because everything related to bidi writing is under our
% control.
%
-% TODO: math mode (as weak L?)
-%
% \changes{babel~3.20}{2018/05/01}{Adapted to exhyphens in luatex >=
% 1.07. Fix - now attr@dir is mod 3.}
+% \changes{babel~3.30}{2019/04/22}{Switch to enable/disable bidi.}
%
% \begin{macrocode}
%<*basic-r>
Babel = Babel or {}
+Babel.bidi_enabled = true
+
require('babel-bidi.lua')
local characters = Babel.characters
@@ -18139,18 +18347,6 @@ local function dir_mark(head, from, to, outer)
node.insert_after(head, to, d)
end
-function Babel.pre_otfload_v(head)
- -- head = Babel.numbers(head)
- head = Babel.bidi(head, true)
- return head
-end
-
-function Babel.pre_otfload_h(head)
- -- head = Babel.numbers(head)
- head = Babel.bidi(head, false)
- return head
-end
-
function Babel.bidi(head, ispar)
local first_n, last_n -- first and last char with nums
local last_es -- an auxiliary 'last' used with nums
@@ -18209,7 +18405,9 @@ function Babel.bidi(head, ispar)
% switches the script with its dir. We treat a language block as
% a separate Unicode sequence. The following piece of code is
% executed at the first glyph after a `dir' node. We don't know
-% the current language until then.
+% the current language until then. This is not exactly true, as
+% the math mode may insert explicit dirs in the node list, so, for
+% the moment there is a hack by brute force (just above).
%
% \begin{macrocode}
if new_dir then
@@ -18398,22 +18596,14 @@ end
%<*basic>
Babel = Babel or {}
+-- eg, Babel.fontmap[1][<prefontid>]=<dirfontid>
+
Babel.fontmap = Babel.fontmap or {}
Babel.fontmap[0] = {} -- l
Babel.fontmap[1] = {} -- r
Babel.fontmap[2] = {} -- al/an
-function Babel.pre_otfload_v(head)
- -- head = Babel.numbers(head)
- head = Babel.bidi(head, true)
- return head
-end
-
-function Babel.pre_otfload_h(head, gc, sz, pt, dir)
- -- head = Babel.numbers(head)
- head = Babel.bidi(head, false, dir)
- return head
-end
+Babel.bidi_enabled = true
require('babel-bidi.lua')
@@ -18533,9 +18723,9 @@ function Babel.bidi(head, ispar, hdir)
end
end
d = d or 'l'
- if inmath then d = ('TRT' == tex.mathdir) and 'r' or 'l' end
+
+ -- A short 'pause' in bidi for mapfont
d_font = d_font or d
-
d_font = (d_font == 'l' and 0) or
(d_font == 'nsm' and 0) or
(d_font == 'r' and 1) or
@@ -18547,8 +18737,12 @@ function Babel.bidi(head, ispar, hdir)
if new_d then
table.insert(nodes, {nil, (outer == 'l') and 'l' or 'r', nil})
- attr_d = node.get_attribute(item, ATDIR)
- attr_d = attr_d % 3
+ if inmath then
+ attr_d = 0
+ else
+ attr_d = node.get_attribute(item, ATDIR)
+ attr_d = attr_d % 3
+ end
if attr_d == 1 then
outer_first = 'r'
last = 'r'
diff --git a/Master/texmf-dist/source/latex/babel/babel.ins b/Master/texmf-dist/source/latex/babel/babel.ins
index 2d3b5d0a4e2..408833da08f 100644
--- a/Master/texmf-dist/source/latex/babel/babel.ins
+++ b/Master/texmf-dist/source/latex/babel/babel.ins
@@ -26,7 +26,7 @@
%% and covered by LPPL is defined by the unpacking scripts (with
%% extension .ins) which are part of the distribution.
%%
-\def\filedate{2019/04/03}
+\def\filedate{2019/04/22}
\def\batchfile{babel.ins}
\input docstrip.tex
diff --git a/Master/texmf-dist/source/latex/babel/bbcompat.dtx b/Master/texmf-dist/source/latex/babel/bbcompat.dtx
index 73f6bbcb4a0..4b31d63bcfd 100644
--- a/Master/texmf-dist/source/latex/babel/bbcompat.dtx
+++ b/Master/texmf-dist/source/latex/babel/bbcompat.dtx
@@ -30,7 +30,7 @@
%
% \iffalse
%<*dtx>
-\ProvidesFile{bbcompat.dtx}[2019/04/03 v3.29]
+\ProvidesFile{bbcompat.dtx}[2019/04/22 v3.30]
%</dtx>
%
%% File 'bbcompat.dtx'
diff --git a/Master/texmf-dist/source/latex/babel/locale.zip b/Master/texmf-dist/source/latex/babel/locale.zip
index 9dcb099b579..78e6a19c1fa 100644
--- a/Master/texmf-dist/source/latex/babel/locale.zip
+++ b/Master/texmf-dist/source/latex/babel/locale.zip
Binary files differ