texlive[50951] Master/texmf-dist: babel (22apr19)

commits+karl at tug.org commits+karl at tug.org
Fri May 3 00:52:12 CEST 2019


Revision: 50951
          http://tug.org/svn/texlive?view=revision&revision=50951
Author:   karl
Date:     2019-05-03 00:52:12 +0200 (Fri, 03 May 2019)
Log Message:
-----------
babel (22apr19)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/babel/README.md
    trunk/Master/texmf-dist/doc/latex/babel/babel.pdf
    trunk/Master/texmf-dist/source/latex/babel/babel.dtx
    trunk/Master/texmf-dist/source/latex/babel/babel.ins
    trunk/Master/texmf-dist/source/latex/babel/bbcompat.dtx
    trunk/Master/texmf-dist/source/latex/babel/locale.zip
    trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua
    trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic.lua
    trunk/Master/texmf-dist/tex/generic/babel/babel.def
    trunk/Master/texmf-dist/tex/generic/babel/babel.sty
    trunk/Master/texmf-dist/tex/generic/babel/hyphen.cfg
    trunk/Master/texmf-dist/tex/generic/babel/luababel.def
    trunk/Master/texmf-dist/tex/generic/babel/nil.ldf
    trunk/Master/texmf-dist/tex/generic/babel/switch.def

Modified: trunk/Master/texmf-dist/doc/latex/babel/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/babel/README.md	2019-05-02 22:51:31 UTC (rev 50950)
+++ trunk/Master/texmf-dist/doc/latex/babel/README.md	2019-05-02 22:52:12 UTC (rev 50951)
@@ -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,9 +51,13 @@
 ### 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
@@ -60,16 +64,21 @@
          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 @@
          the Japanese script).
        - Set the \thepage bidi bahavior in foots/heads.
        - Fix - Undefined \bbl at 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 @@
        - 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 @@
          . 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 @@
        - 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 @@
 ```
 
 Javier Bezos
-2019/04/03
-
+2019/04/22

Modified: trunk/Master/texmf-dist/doc/latex/babel/babel.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/babel/babel.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/babel/babel.dtx	2019-05-02 22:51:31 UTC (rev 50950)
+++ trunk/Master/texmf-dist/source/latex/babel/babel.dtx	2019-05-02 22:52:12 UTC (rev 50951)
@@ -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 @@
 \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 @@
   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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 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 @@
 
 \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 @@
   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 @@
   \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,7 +2590,7 @@
 \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
@@ -2557,6 +2597,14 @@
   |\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 @@
 % \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 @@
 % |\bbl at 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 at languages\@undefined\else
   \begingroup
@@ -4383,6 +4434,46 @@
   \bbl at languages
 \fi
 \ifodd\bbl at engine
+  \def\bbl at activate@preotf{%
+    \let\bbl at 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 at tempa\relax
   \@ifpackagewith{babel}{bidi=basic}%
     {\def\bbl at tempa{basic}}%
@@ -4396,17 +4487,8 @@
     \directlua{
       require('babel-bidi.lua')
       require('babel-bidi-\bbl at 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 at activate@preotf
   \fi
 \fi
 %    \end{macrocode}
@@ -7769,9 +7851,9 @@
 % \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 @@
 % \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 at trace{Creating languages and reading ini files}
 \newcommand\babelprovide[2][]{%
   \let\bbl at savelangname\languagename
+  \edef\bbl at savelocaleid{\the\localeid}%
+  % Set name and locale id
   \def\languagename{#2}%
+  \bbl at id@assign
+  \chardef\localeid\@nameuse{bbl at id@@\languagename}%
   \let\bbl at KVP@captions\@nil
   \let\bbl at KVP@import\@nil
   \let\bbl at KVP@main\@nil
@@ -7801,6 +7892,7 @@
   \let\bbl at KVP@hyphenrules\@nil
   \let\bbl at KVP@mapfont\@nil
   \let\bbl at KVP@maparabic\@nil
+  \let\bbl at KVP@mapdigits\@nil
   \let\bbl at KVP@intraspace\@nil
   \let\bbl at KVP@intrapenalty\@nil
   \bbl at forkv{#1}{\bbl at csarg\def{KVP@##1}{##2}}%  TODO - error handling
@@ -7833,7 +7925,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 at ifunset{bbl at lname@#2}%
+    {\def\BabelBeforeIni##1##2{%
+       \begingroup
+         \catcode`\[=12 \catcode`\]=12 \catcode`\==12 %
+         \let\bbl at ini@captions at aux\@gobbletwo
+         \def\bbl at inidate ####1.####2.####3.####4\relax ####5####6{}%
+         \let\bbl at inikv@typography\bbl at iniskip
+         \bbl at read@ini{##1}%
+         \bbl at exportkey{chrng}{characters.ranges}{}%
+         \bbl at 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 at KVP@script\@nil\else
     \bbl at csarg\edef{sname@#2}{\bbl at KVP@script}%
   \fi
@@ -7865,7 +7975,7 @@
     \fi
     \bbl at exp{\\\bbl at add\\\bbl at mapselect{\\\bbl at mapdir{\languagename}}}%
   \fi
-  % For Southeast Asian, if interspace in ini
+  % For Southeast Asian, if interspace in ini -- TODO: as hook
   \ifcase\bbl at engine\or
     \bbl at ifunset{bbl at intsp@\languagename}{}%
       {\expandafter\ifx\csname bbl at intsp@\languagename\endcsname\@empty\else
@@ -7917,7 +8027,7 @@
         \fi}%
     \fi
   \fi
-  % Native digits, if provided in ini
+  % Native digits, if provided in ini (TeX level, xe and lua)
   \ifcase\bbl at engine\else
     \bbl at ifunset{bbl at dgnat@\languagename}{}%
       {\expandafter\ifx\csname bbl at dgnat@\languagename\endcsname\@empty\else
@@ -7934,6 +8044,42 @@
         \fi
       \fi}%
   \fi
+  % Native digits (lua level).
+  \ifodd\bbl at engine
+    \ifx\bbl at KVP@mapdigits\@nil\else
+      \bbl at ifunset{bbl at dgnat@\languagename}{}%
+        {\RequirePackage{luatexbase}%
+         \bbl at 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 at cs{dgnat@\languagename}'))
+           if not Babel.numbers then
+             function Babel.numbers(head)
+               local LOCALE = luatexbase.registernumber'bbl at 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 at ifunset{bbl at rqtex@\languagename}{}%
     {\expandafter\ifx\csname bbl at rqtex@\languagename\endcsname\@empty\else
@@ -7944,7 +8090,8 @@
        \catcode`\@=\atcatcode
        \let\atcatcode\relax
      \fi}%
-  \let\languagename\bbl at savelangname}
+  \let\languagename\bbl at savelangname
+  \chardef\localeid\bbl at savelocaleid\relax}
 %    \end{macrocode}
 %
 % A tool to define the macros for native digits from the list provided 
@@ -8083,7 +8230,7 @@
 %
 %    \begin{macrocode}
 \def\bbl at read@ini#1{%
-  \openin1=babel-#1.ini
+  \openin1=babel-#1.ini        % FIXME - number must not be hardcoded
   \ifeof1
     \bbl at error
       {There is no ini file for the requested language\\%
@@ -8246,7 +8393,7 @@
 \ifcase\bbl at engine
   \bbl at csarg\def{inikv at date.gregorian.licr}#1=#2\@@{%  override
     \bbl at inidate#1...\relax{#2}{}}
-  \bbl at csarg\def{secpre at date.gregorian.licr}{%           discard uni
+  \bbl at csarg\def{secpre at date.gregorian.licr}{%         discard uni
     \ifcase\bbl at engine\let\bbl at savedate\@empty\fi}
 \fi
 % eg: 1=months, 2=wide, 3=1, 4=dummy
@@ -9285,7 +9432,7 @@
       \fi
     \fi}
   \def\bbl at textdir#1{%
-    \bbl at setluadir{text}\textdir{#1}% TODO - ?\linedir
+    \bbl at setluadir{text}\textdir{#1}%
     \chardef\bbl at thetextdir#1\relax
     \setattribute\bbl at attr@dir{\numexpr\bbl at thepardir*3+#1}}
   \def\bbl at pardir#1{%
@@ -9298,9 +9445,9 @@
   % Activated every math with the package option bidi=:
   \def\bbl at mathboxdir{%
     \ifcase\bbl at 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 at switchdir}
@@ -9679,7 +9826,27 @@
 %  \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 at ...| will be
+%  reserved for hyphenation patterns.
+%
 %    \begin{macrocode}
+\chardef\localeid\z@
+\def\bbl at id@last{0}    % No real need for a new counter
+\def\bbl at id@assign{%
+  \bbl at ifunset{bbl at id@@\languagename}%
+    {\count@\bbl at id@last\relax
+     \advance\count@\@ne
+     \bbl at csarg\chardef{id@@\languagename}\count@
+     \edef\bbl at id@last{\the\count@}}%
+    {}}
+%    \end{macrocode}
+%
+% The unprotected part of |\selectlanguage|.
+%
+%    \begin{macrocode}
 \expandafter\def\csname selectlanguage \endcsname#1{%
   \ifnum\bbl at hymapsel=\@cclv\let\bbl at hymapsel\tw@\fi
   \bbl at push@language
@@ -9836,6 +10003,9 @@
     \babel at beginsave}%
   \bbl at usehooks{afterreset}{}%
   \languageshorthands{none}%
+  % set the locale id
+  \bbl at id@assign
+  \chardef\localeid\@nameuse{bbl at id@@\languagename}%
   % switch captions, date
   \ifcase\bbl at select@type
     \ifhmode
@@ -10795,6 +10965,9 @@
 % 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 at engine
@@ -10803,9 +10976,11 @@
   \DeclareOption{bidi=basic}%
     {\let\bbl at beforeforeign\leavevmode
      \newattribute\bbl at attr@dir
-     % TODO - the same trick as bbl at severypar
-     % \everymath{\bbl at mathboxdir}%
-     % \everydisplay{\bbl at mathboxdir}%
+     % I don't like it, hackish:
+     \frozen at everymath\expandafter{%
+       \expandafter\bbl at mathboxdir\the\frozen at everymath}%
+     \frozen at everydisplay\expandafter{%
+       \expandafter\bbl at mathboxdir\the\frozen at everydisplay}%
      \bbl at exp{\output{\bodydir\pagedir\the\output}}%
      \AtEndOfPackage{\EnableBabelHook{babel-bidi}}}
 \else
@@ -11642,6 +11817,11 @@
   end
 }
 \endgroup
+\ifx\newattribute\@undefined\else
+  \newattribute\bbl at attr@locale
+  \AddBabelHook{luatex}{beforeextras}{%
+    \setattribute\bbl at attr@locale\localeid}
+\fi
 \def\BabelStringsDefault{unicode}
 \let\luabbl at stop\relax
 \AddBabelHook{luatex}{encodedcommands}{%
@@ -11836,6 +12016,33 @@
 <@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 at 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 at luafixboxdir}
+%    \end{macrocode}
+%
 % \subsection{Layout}
 %
 % \textbf{Work in progress}.
@@ -18113,15 +18320,16 @@
 % 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 at 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 @@
   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 @@
 %      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,23 +18596,15 @@
 %<*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
+Babel.bidi_enabled = true
 
-function Babel.pre_otfload_h(head, gc, sz, pt, dir)
-  -- head = Babel.numbers(head)
-  head = Babel.bidi(head, false, dir)
-  return head
-end
-
 require('babel-bidi.lua')
 
 local characters = Babel.characters
@@ -18533,9 +18723,9 @@
         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 @@
 
       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'

Modified: trunk/Master/texmf-dist/source/latex/babel/babel.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/babel/babel.ins	2019-05-02 22:51:31 UTC (rev 50950)
+++ trunk/Master/texmf-dist/source/latex/babel/babel.ins	2019-05-02 22:52:12 UTC (rev 50951)
@@ -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
 

Modified: trunk/Master/texmf-dist/source/latex/babel/bbcompat.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/babel/bbcompat.dtx	2019-05-02 22:51:31 UTC (rev 50950)
+++ trunk/Master/texmf-dist/source/latex/babel/bbcompat.dtx	2019-05-02 22:52:12 UTC (rev 50951)
@@ -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'

Modified: trunk/Master/texmf-dist/source/latex/babel/locale.zip
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua	2019-05-02 22:51:31 UTC (rev 50950)
+++ trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua	2019-05-02 22:52:12 UTC (rev 50951)
@@ -34,6 +34,8 @@
 
 Babel = Babel or {}
 
+Babel.bidi_enabled = true
+
 require('babel-bidi.lua')
 
 local characters = Babel.characters
@@ -51,18 +53,6 @@
   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

Modified: trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic.lua
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic.lua	2019-05-02 22:51:31 UTC (rev 50950)
+++ trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic.lua	2019-05-02 22:52:12 UTC (rev 50951)
@@ -34,23 +34,15 @@
 
 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
+Babel.bidi_enabled = true
 
-function Babel.pre_otfload_h(head, gc, sz, pt, dir)
-  -- head = Babel.numbers(head)
-  head = Babel.bidi(head, false, dir)
-  return head
-end
-
 require('babel-bidi.lua')
 
 local characters = Babel.characters
@@ -169,9 +161,9 @@
         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
@@ -183,8 +175,12 @@
 
       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'

Modified: trunk/Master/texmf-dist/tex/generic/babel/babel.def
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/babel.def	2019-05-02 22:51:31 UTC (rev 50950)
+++ trunk/Master/texmf-dist/tex/generic/babel/babel.def	2019-05-02 22:52:12 UTC (rev 50951)
@@ -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 at trace{Creating languages and reading ini files}
 \newcommand\babelprovide[2][]{%
   \let\bbl at savelangname\languagename
+  \edef\bbl at savelocaleid{\the\localeid}%
+  % Set name and locale id
   \def\languagename{#2}%
+  \bbl at id@assign
+  \chardef\localeid\@nameuse{bbl at id@@\languagename}%
   \let\bbl at KVP@captions\@nil
   \let\bbl at KVP@import\@nil
   \let\bbl at KVP@main\@nil
@@ -1314,6 +1318,7 @@
   \let\bbl at KVP@hyphenrules\@nil
   \let\bbl at KVP@mapfont\@nil
   \let\bbl at KVP@maparabic\@nil
+  \let\bbl at KVP@mapdigits\@nil
   \let\bbl at KVP@intraspace\@nil
   \let\bbl at KVP@intrapenalty\@nil
   \bbl at forkv{#1}{\bbl at 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 at ifunset{bbl at lname@#2}%
+    {\def\BabelBeforeIni##1##2{%
+       \begingroup
+         \catcode`\[=12 \catcode`\]=12 \catcode`\==12 %
+         \let\bbl at ini@captions at aux\@gobbletwo
+         \def\bbl at inidate ####1.####2.####3.####4\relax ####5####6{}%
+         \let\bbl at inikv@typography\bbl at iniskip
+         \bbl at read@ini{##1}%
+         \bbl at exportkey{chrng}{characters.ranges}{}%
+         \bbl at 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 at KVP@script\@nil\else
     \bbl at csarg\edef{sname@#2}{\bbl at KVP@script}%
   \fi
@@ -1378,7 +1401,7 @@
     \fi
     \bbl at exp{\\\bbl at add\\\bbl at mapselect{\\\bbl at mapdir{\languagename}}}%
   \fi
-  % For Southeast Asian, if interspace in ini
+  % For Southeast Asian, if interspace in ini -- TODO: as hook
   \ifcase\bbl at engine\or
     \bbl at ifunset{bbl at intsp@\languagename}{}%
       {\expandafter\ifx\csname bbl at 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 at engine\else
     \bbl at ifunset{bbl at dgnat@\languagename}{}%
       {\expandafter\ifx\csname bbl at dgnat@\languagename\endcsname\@empty\else
@@ -1447,6 +1470,42 @@
         \fi
       \fi}%
   \fi
+  % Native digits (lua level).
+  \ifodd\bbl at engine
+    \ifx\bbl at KVP@mapdigits\@nil\else
+      \bbl at ifunset{bbl at dgnat@\languagename}{}%
+        {\RequirePackage{luatexbase}%
+         \bbl at 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 at cs{dgnat@\languagename}'))
+           if not Babel.numbers then
+             function Babel.numbers(head)
+               local LOCALE = luatexbase.registernumber'bbl at 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 at ifunset{bbl at rqtex@\languagename}{}%
     {\expandafter\ifx\csname bbl at rqtex@\languagename\endcsname\@empty\else
@@ -1457,7 +1516,8 @@
        \catcode`\@=\atcatcode
        \let\atcatcode\relax
      \fi}%
-  \let\languagename\bbl at savelangname}
+  \let\languagename\bbl at savelangname
+  \chardef\localeid\bbl at savelocaleid\relax}
 \def\bbl at setdigits#1#2#3#4#5{%
   \bbl at exp{%
     \def\<\languagename digits>####1{%       ie, \langdigits
@@ -1567,7 +1627,7 @@
        {}}%                      so, l@<lang> is ok - nothing to do
     {\bbl at exp{\\\adddialect\<l@#1>\bbl at tempa}}}%  found in opt list or ini
 \def\bbl at read@ini#1{%
-  \openin1=babel-#1.ini
+  \openin1=babel-#1.ini        % FIXME - number must not be hardcoded
   \ifeof1
     \bbl at error
       {There is no ini file for the requested language\\%
@@ -1678,7 +1738,7 @@
 \ifcase\bbl at engine
   \bbl at csarg\def{inikv at date.gregorian.licr}#1=#2\@@{%  override
     \bbl at inidate#1...\relax{#2}{}}
-  \bbl at csarg\def{secpre at date.gregorian.licr}{%           discard uni
+  \bbl at csarg\def{secpre at date.gregorian.licr}{%         discard uni
     \ifcase\bbl at engine\let\bbl at savedate\@empty\fi}
 \fi
 \def\bbl at inidate#1.#2.#3.#4\relax#5#6{% TODO - ignore with 'captions'
@@ -2063,7 +2123,7 @@
       \fi
     \fi}
   \def\bbl at textdir#1{%
-    \bbl at setluadir{text}\textdir{#1}% TODO - ?\linedir
+    \bbl at setluadir{text}\textdir{#1}%
     \chardef\bbl at thetextdir#1\relax
     \setattribute\bbl at attr@dir{\numexpr\bbl at thepardir*3+#1}}
   \def\bbl at pardir#1{%
@@ -2076,9 +2136,9 @@
   % Activated every math with the package option bidi=:
   \def\bbl at mathboxdir{%
     \ifcase\bbl at 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 at switchdir}

Modified: trunk/Master/texmf-dist/tex/generic/babel/babel.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/babel.sty	2019-05-02 22:51:31 UTC (rev 50950)
+++ trunk/Master/texmf-dist/tex/generic/babel/babel.sty	2019-05-02 22:52:12 UTC (rev 50951)
@@ -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 at trace[1]{\message{^^J[ #1 ]}}%
    \let\bbl at debug\@firstofone}
@@ -187,6 +187,46 @@
   \bbl at languages
 \fi
 \ifodd\bbl at engine
+  \def\bbl at activate@preotf{%
+    \let\bbl at 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 at tempa\relax
   \@ifpackagewith{babel}{bidi=basic}%
     {\def\bbl at tempa{basic}}%
@@ -200,17 +240,8 @@
     \directlua{
       require('babel-bidi.lua')
       require('babel-bidi-\bbl at 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 at activate@preotf
   \fi
 \fi
 \bbl at trace{Defining option 'base'}
@@ -276,9 +307,11 @@
   \DeclareOption{bidi=basic}%
     {\let\bbl at beforeforeign\leavevmode
      \newattribute\bbl at attr@dir
-     % TODO - the same trick as bbl at severypar
-     % \everymath{\bbl at mathboxdir}%
-     % \everydisplay{\bbl at mathboxdir}%
+     % I don't like it, hackish:
+     \frozen at everymath\expandafter{%
+       \expandafter\bbl at mathboxdir\the\frozen at everymath}%
+     \frozen at everydisplay\expandafter{%
+       \expandafter\bbl at mathboxdir\the\frozen at everydisplay}%
      \bbl at exp{\output{\bodydir\pagedir\the\output}}%
      \AtEndOfPackage{\EnableBabelHook{babel-bidi}}}
 \else

Modified: trunk/Master/texmf-dist/tex/generic/babel/hyphen.cfg
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/hyphen.cfg	2019-05-02 22:51:31 UTC (rev 50950)
+++ trunk/Master/texmf-dist/tex/generic/babel/hyphen.cfg	2019-05-02 22:52:12 UTC (rev 50951)
@@ -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 at format{\jobname}
 \ifx\AtBeginDocument\@undefined
   \def\@empty{}

Modified: trunk/Master/texmf-dist/tex/generic/babel/luababel.def
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/luababel.def	2019-05-02 22:51:31 UTC (rev 50950)
+++ trunk/Master/texmf-dist/tex/generic/babel/luababel.def	2019-05-02 22:52:12 UTC (rev 50951)
@@ -224,6 +224,11 @@
   end
 }
 \endgroup
+\ifx\newattribute\@undefined\else
+  \newattribute\bbl at attr@locale
+  \AddBabelHook{luatex}{beforeextras}{%
+    \setattribute\bbl at attr@locale\localeid}
+\fi
 \def\BabelStringsDefault{unicode}
 \let\luabbl at stop\relax
 \AddBabelHook{luatex}{encodedcommands}{%
@@ -546,6 +551,26 @@
   \expandafter\addto\csname extras#1\endcsname{%
     \babel at save\bbl at langfeatures
     \edef\bbl at langfeatures{#2,}}}
+\def\bbl at 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 at luafixboxdir}
 \bbl at trace{Redefinitions for bidi layout}
 \ifx\@eqnnum\@undefined\else
   \ifx\bbl at attr@dir\@undefined\else

Modified: trunk/Master/texmf-dist/tex/generic/babel/nil.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/nil.ldf	2019-05-02 22:51:31 UTC (rev 50950)
+++ trunk/Master/texmf-dist/tex/generic/babel/nil.ldf	2019-05-02 22:52:12 UTC (rev 50951)
@@ -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 at nohyphenation\@undefined
    \@nopatterns{nil}

Modified: trunk/Master/texmf-dist/tex/generic/babel/switch.def
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/switch.def	2019-05-02 22:51:31 UTC (rev 50950)
+++ trunk/Master/texmf-dist/tex/generic/babel/switch.def	2019-05-02 22:52:12 UTC (rev 50951)
@@ -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 at language=19
   \def\addlanguage{\alloc at 9\language\chardef\@cclvi}
 \fi
-\def\bbl at version{3.29}
-\def\bbl at date{2019/04/03}
+\def\bbl at version{3.30}
+\def\bbl at date{2019/04/22}
 \def\adddialect#1#2{%
   \global\chardef#1#2\relax
   \bbl at usehooks{adddialect}{{#1}{#2}}%
@@ -109,6 +109,15 @@
   \let\bbl at ifrestoring\@firstoftwo
   \expandafter\bbl at set@language\expandafter{\languagename}%
   \let\bbl at ifrestoring\@secondoftwo}
+\chardef\localeid\z@
+\def\bbl at id@last{0}    % No real need for a new counter
+\def\bbl at id@assign{%
+  \bbl at ifunset{bbl at id@@\languagename}%
+    {\count@\bbl at id@last\relax
+     \advance\count@\@ne
+     \bbl at csarg\chardef{id@@\languagename}\count@
+     \edef\bbl at id@last{\the\count@}}%
+    {}}
 \expandafter\def\csname selectlanguage \endcsname#1{%
   \ifnum\bbl at hymapsel=\@cclv\let\bbl at hymapsel\tw@\fi
   \bbl at push@language
@@ -175,6 +184,9 @@
     \babel at beginsave}%
   \bbl at usehooks{afterreset}{}%
   \languageshorthands{none}%
+  % set the locale id
+  \bbl at id@assign
+  \chardef\localeid\@nameuse{bbl at id@@\languagename}%
   % switch captions, date
   \ifcase\bbl at select@type
     \ifhmode



More information about the tex-live-commits mailing list