summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/latex/babel/README.md26
-rw-r--r--Master/texmf-dist/doc/latex/babel/babel.pdfbin674167 -> 695563 bytes
-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
-rw-r--r--Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua14
-rw-r--r--Master/texmf-dist/tex/generic/babel/babel-bidi-basic.lua26
-rw-r--r--Master/texmf-dist/tex/generic/babel/babel.def80
-rw-r--r--Master/texmf-dist/tex/generic/babel/babel.sty63
-rw-r--r--Master/texmf-dist/tex/generic/babel/hyphen.cfg2
-rw-r--r--Master/texmf-dist/tex/generic/babel/luababel.def25
-rw-r--r--Master/texmf-dist/tex/generic/babel/nil.ldf2
-rw-r--r--Master/texmf-dist/tex/generic/babel/switch.def18
14 files changed, 466 insertions, 144 deletions
diff --git a/Master/texmf-dist/doc/latex/babel/README.md b/Master/texmf-dist/doc/latex/babel/README.md
index 912b1bb0d42..58b7a5e64d4 100644
--- a/Master/texmf-dist/doc/latex/babel/README.md
+++ b/Master/texmf-dist/doc/latex/babel/README.md
@@ -1,4 +1,4 @@
-## Babel 3.29
+## Babel 3.30
This package manages culturally-determined typographical (and other)
rules, and hyphenation patterns for a wide range of languages. Many
@@ -51,25 +51,34 @@ respective authors.
### Latest changes
```
+3.30 - Fix - dir in boxes inside math (hopefully now it works).
+ - Option mapdigits for \babelprovide (only luatex).
+
3.29 - The fix for boxes inside math is incompatible with ams.
Removed (a better fix is under study).
- Options bidi-l and bidi-r (for the bidi package).
+
3.28 - Fixes - wrong dir after math, in math inside tabular, in weak L
inside R inside L, and in boxes inside math.
- \babelfont now takes into account \defaultfontfeatures. This
is a potential source of backwards incompatibilities, but
very likely the risks are very low, and it is, I think, the
expected behavior.
+
3.27 - Preliminary support for bidi (by Vafa Khalighi) with xetex.
- Fix for 3.23 - \ensureascii was redefined even when not
necessary.
- Minor improvements in babel-vi.ini.
+
3.26 - Fix for 3.25 - \babelprovide raised an error with xetex.
+
3.25 - Fixes for 3.23 - mapfont=direction could raise an error.
Language and Script were not always defined correctly.
- Improved tentative support for Thai, Lao and Khmer in both
luatex and xetex.
+
3.24 - Prelimimary support for Thai interword spacing with luatex.
+
3.23 - After extensive tests and fixing some issues, bidi=basic is
not experimental any longer.
- import in \babelprovide does not require a language code if
@@ -81,14 +90,17 @@ respective authors.
the Japanese script).
- Set the \thepage bidi bahavior in foots/heads.
- Fix - Undefined \bbl@stripslash in Plain.
+
3.22 - Fix - Error with \chapter if empty in ini
- Prelimimary support for Sanskrit
- Unknown languages in aux files do not raise an error
any more (only show a warning).
+
3.21 - Fix - equation numbers raised an error.
- Two minor changes: if no language is requested load nil
instead of raising an error, and the message 'babel <x.x>...'
is not printed to the log any more.
+
3.20 - ini files with the field digits.native define
\<language>digits and \<language>counters. \arabic can be
redefined to use native digits.
@@ -99,6 +111,7 @@ respective authors.
- Fix for luatex 1.07 - An internal change in luatex broke
bidi at 'automatic' hyphens.
- Fix for latest latex - babel.ins raised an error.
+
3.19 - Most changes are for luatex:
. The main new feature is a bidi method for both implicit L in
R text, and implicit R in L text, with the possibility of
@@ -107,8 +120,8 @@ respective authors.
. layout=extras for a couple of miscellaneous readjustments.
. bidi equation numbers.
- Also, for all engines, new field in some ini files:
- digits.native (to be used in future releases).
-
+ digits.native (to be used in future releases).
+
3.18 - More bidi in luatex: captions (required only in multilingual
docs) and tabular (required for R tables). Also an experimental
support for captions in xetex and pdftex (tabular is not yet
@@ -116,10 +129,10 @@ respective authors.
- New ini files: ar-DZ, ar-MA, ar-SY
- Fix - \begin{hyphenrules} didn't work with polyglossia.
- Fix - switch.def was loaded twice.
-
+
3.17 - A tool for bidi footnotes.
- Fix - \ragged... didn't work for bidi.
-
+
3.16 - New package option layout for bidi documents.
- Quotes in TU encoding
- Fix - \<language>date did not work correctly
@@ -128,5 +141,4 @@ respective authors.
```
Javier Bezos
-2019/04/03
-
+2019/04/22
diff --git a/Master/texmf-dist/doc/latex/babel/babel.pdf b/Master/texmf-dist/doc/latex/babel/babel.pdf
index d74872dab72..6db73cf6186 100644
--- a/Master/texmf-dist/doc/latex/babel/babel.pdf
+++ b/Master/texmf-dist/doc/latex/babel/babel.pdf
Binary files differ
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
diff --git a/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua b/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua
index c9c45087a99..0705daa99d6 100644
--- a/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua
+++ b/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua
@@ -34,6 +34,8 @@
Babel = Babel or {}
+Babel.bidi_enabled = true
+
require('babel-bidi.lua')
local characters = Babel.characters
@@ -51,18 +53,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
diff --git a/Master/texmf-dist/tex/generic/babel/babel-bidi-basic.lua b/Master/texmf-dist/tex/generic/babel/babel-bidi-basic.lua
index 345c90a2fef..02e1406e4d1 100644
--- a/Master/texmf-dist/tex/generic/babel/babel-bidi-basic.lua
+++ b/Master/texmf-dist/tex/generic/babel/babel-bidi-basic.lua
@@ -34,22 +34,14 @@
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')
@@ -169,9 +161,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
- d_font = d_font or d
+ -- 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
@@ -183,8 +175,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/tex/generic/babel/babel.def b/Master/texmf-dist/tex/generic/babel/babel.def
index 530548f8eec..1b65f99346f 100644
--- a/Master/texmf-dist/tex/generic/babel/babel.def
+++ b/Master/texmf-dist/tex/generic/babel/babel.def
@@ -41,7 +41,7 @@
\wlog{File: #1 #4 #3 <#2>}%
\let\ProvidesFile\@undefined}
\fi
-\ProvidesFile{babel.def}[2019/04/03 3.29 Babel common definitions]
+\ProvidesFile{babel.def}[2019/04/22 3.30 Babel common definitions]
\ifx\AtBeginDocument\@undefined
\input plain.def\relax
\fi
@@ -1304,7 +1304,11 @@
\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
@@ -1314,6 +1318,7 @@
\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
@@ -1346,7 +1351,25 @@
\\\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
@@ -1378,7 +1401,7 @@
\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
@@ -1430,7 +1453,7 @@
\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
@@ -1447,6 +1470,42 @@
\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
@@ -1457,7 +1516,8 @@
\catcode`\@=\atcatcode
\let\atcatcode\relax
\fi}%
- \let\languagename\bbl@savelangname}
+ \let\languagename\bbl@savelangname
+ \chardef\localeid\bbl@savelocaleid\relax}
\def\bbl@setdigits#1#2#3#4#5{%
\bbl@exp{%
\def\<\languagename digits>####1{% ie, \langdigits
@@ -1567,7 +1627,7 @@
{}}% so, l@<lang> is ok - nothing to do
{\bbl@exp{\\\adddialect\<l@#1>\bbl@tempa}}}% found in opt list or ini
\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\\%
@@ -1678,7 +1738,7 @@
\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
\def\bbl@inidate#1.#2.#3.#4\relax#5#6{% TODO - ignore with 'captions'
@@ -2063,7 +2123,7 @@
\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{%
@@ -2076,9 +2136,9 @@
% 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}
diff --git a/Master/texmf-dist/tex/generic/babel/babel.sty b/Master/texmf-dist/tex/generic/babel/babel.sty
index 62fd68065fc..7ee327b7c48 100644
--- a/Master/texmf-dist/tex/generic/babel/babel.sty
+++ b/Master/texmf-dist/tex/generic/babel/babel.sty
@@ -33,7 +33,7 @@
%%
\NeedsTeXFormat{LaTeX2e}[2005/12/01]
-\ProvidesPackage{babel}[2019/04/03 3.29 The Babel package]
+\ProvidesPackage{babel}[2019/04/22 3.30 The Babel package]
\@ifpackagewith{babel}{debug}
{\providecommand\bbl@trace[1]{\message{^^J[ #1 ]}}%
\let\bbl@debug\@firstofone}
@@ -187,6 +187,46 @@
\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}}%
@@ -200,17 +240,8 @@
\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
\bbl@trace{Defining option 'base'}
@@ -276,9 +307,11 @@
\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
diff --git a/Master/texmf-dist/tex/generic/babel/hyphen.cfg b/Master/texmf-dist/tex/generic/babel/hyphen.cfg
index cd1afb4d293..213ca7f27ce 100644
--- a/Master/texmf-dist/tex/generic/babel/hyphen.cfg
+++ b/Master/texmf-dist/tex/generic/babel/hyphen.cfg
@@ -37,7 +37,7 @@
\wlog{File: #1 #4 #3 <#2>}%
\let\ProvidesFile\@undefined}
\fi
-\ProvidesFile{hyphen.cfg}[2019/04/03 3.29 Babel hyphens]
+\ProvidesFile{hyphen.cfg}[2019/04/22 3.30 Babel hyphens]
\xdef\bbl@format{\jobname}
\ifx\AtBeginDocument\@undefined
\def\@empty{}
diff --git a/Master/texmf-dist/tex/generic/babel/luababel.def b/Master/texmf-dist/tex/generic/babel/luababel.def
index 85899a726ba..c3cd913bbf7 100644
--- a/Master/texmf-dist/tex/generic/babel/luababel.def
+++ b/Master/texmf-dist/tex/generic/babel/luababel.def
@@ -224,6 +224,11 @@
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}{%
@@ -546,6 +551,26 @@
\expandafter\addto\csname extras#1\endcsname{%
\babel@save\bbl@langfeatures
\edef\bbl@langfeatures{#2,}}}
+\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}
\bbl@trace{Redefinitions for bidi layout}
\ifx\@eqnnum\@undefined\else
\ifx\bbl@attr@dir\@undefined\else
diff --git a/Master/texmf-dist/tex/generic/babel/nil.ldf b/Master/texmf-dist/tex/generic/babel/nil.ldf
index 4be4ec7477d..a50efbf34e7 100644
--- a/Master/texmf-dist/tex/generic/babel/nil.ldf
+++ b/Master/texmf-dist/tex/generic/babel/nil.ldf
@@ -32,7 +32,7 @@
%% extension |.ins|) which are part of the distribution.
%%
-\ProvidesLanguage{nil}[2019/04/03 3.29 Nil language]
+\ProvidesLanguage{nil}[2019/04/22 3.30 Nil language]
\LdfInit{nil}{datenil}
\ifx\l@nohyphenation\@undefined
\@nopatterns{nil}
diff --git a/Master/texmf-dist/tex/generic/babel/switch.def b/Master/texmf-dist/tex/generic/babel/switch.def
index 1755128ad0a..f03f7486849 100644
--- a/Master/texmf-dist/tex/generic/babel/switch.def
+++ b/Master/texmf-dist/tex/generic/babel/switch.def
@@ -37,7 +37,7 @@
\wlog{File: #1 #4 #3 <#2>}%
\let\ProvidesFile\@undefined}
\fi
-\ProvidesFile{switch.def}[2019/04/03 3.29 Babel switching mechanism]
+\ProvidesFile{switch.def}[2019/04/22 3.30 Babel switching mechanism]
\ifx\AtBeginDocument\@undefined
\input plain.def\relax
\fi
@@ -58,8 +58,8 @@
\countdef\last@language=19
\def\addlanguage{\alloc@9\language\chardef\@cclvi}
\fi
-\def\bbl@version{3.29}
-\def\bbl@date{2019/04/03}
+\def\bbl@version{3.30}
+\def\bbl@date{2019/04/22}
\def\adddialect#1#2{%
\global\chardef#1#2\relax
\bbl@usehooks{adddialect}{{#1}{#2}}%
@@ -109,6 +109,15 @@
\let\bbl@ifrestoring\@firstoftwo
\expandafter\bbl@set@language\expandafter{\languagename}%
\let\bbl@ifrestoring\@secondoftwo}
+\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@}}%
+ {}}
\expandafter\def\csname selectlanguage \endcsname#1{%
\ifnum\bbl@hymapsel=\@cclv\let\bbl@hymapsel\tw@\fi
\bbl@push@language
@@ -175,6 +184,9 @@
\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