summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/babel/luababel.def
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/babel/luababel.def')
-rw-r--r--Master/texmf-dist/tex/generic/babel/luababel.def293
1 files changed, 210 insertions, 83 deletions
diff --git a/Master/texmf-dist/tex/generic/babel/luababel.def b/Master/texmf-dist/tex/generic/babel/luababel.def
index 82edeff91f7..c6eae45ca37 100644
--- a/Master/texmf-dist/tex/generic/babel/luababel.def
+++ b/Master/texmf-dist/tex/generic/babel/luababel.def
@@ -32,7 +32,7 @@
%% and covered by LPPL is defined by the unpacking scripts (with
%% extension |.ins|) which are part of the distribution.
%%
-
+\directlua{ Babel = Babel or {} } % DL2
\ifx\AddBabelHook\@undefined % When plain.def, babel.sty starts
\bbl@trace{Read language.dat}
\ifx\bbl@readstream\@undefined
@@ -178,8 +178,6 @@
{\expandafter\expandafter\expandafter\bbl@luapatterns
\csname bbl@hyphendata@\the\language\endcsname}}{}}
\endinput\fi
- % Here ends \ifx\AddBabelHook\@undefined
- % A few lines are only read by hyphen.cfg
\ifx\DisableBabelHook\@undefined
\AddBabelHook{luatex}{everylanguage}{%
\def\process@language##1##2##3{%
@@ -195,16 +193,13 @@
{\expandafter\expandafter\expandafter\bbl@tempb
\csname bbl@hyphendata@\the\language\endcsname}}
\endinput\fi
- % Here stops reading code for hyphen.cfg
- % The following is read the 2nd time it's loaded
- % First, global declarations for lua
-\begingroup % TODO - to a lua file
+\begingroup % TODO - to a lua file % DL3
\catcode`\%=12
\catcode`\'=12
\catcode`\"=12
\catcode`\:=12
\directlua{
- Babel = Babel or {}
+ Babel.locale_props = Babel.locale_props or {}
function Babel.lua_error(e, a)
tex.print([[\noexpand\csname bbl@error\endcsname{]] ..
e .. '}{' .. (a or '') .. '}{}{}')
@@ -229,6 +224,40 @@
callback.register('process_input_buffer',Babel.callback)
end
end
+ function Babel.str_to_nodes(fn, matches, base)
+ local n, head, last
+ if fn == nil then return nil end
+ for s in string.utfvalues(fn(matches)) do
+ if base.id == 7 then
+ base = base.replace
+ end
+ n = node.copy(base)
+ n.char = s
+ if not head then
+ head = n
+ else
+ last.next = n
+ end
+ last = n
+ end
+ return head
+ end
+ Babel.linebreaking = Babel.linebreaking or {}
+ Babel.linebreaking.before = {}
+ Babel.linebreaking.after = {}
+ Babel.locale = {}
+ function Babel.linebreaking.add_before(func, pos)
+ tex.print([[\noexpand\csname bbl@luahyphenate\endcsname]])
+ if pos == nil then
+ table.insert(Babel.linebreaking.before, func)
+ else
+ table.insert(Babel.linebreaking.before, pos, func)
+ end
+ end
+ function Babel.linebreaking.add_after(func)
+ tex.print([[\noexpand\csname bbl@luahyphenate\endcsname]])
+ table.insert(Babel.linebreaking.after, func)
+ end
function Babel.addpatterns(pp, lg)
local lg = lang.new(lg)
local pats = lang.patterns(lg) or ''
@@ -295,13 +324,13 @@
str:find( [[\string\babelsublr]] ) then
str = str:gsub( [[\string\babelsublr%s*(%b{})]],
function(m) return m:sub(2,-2) end )
- end
- return str
-end
+ end
+ return str
+ end
}
\endgroup
\ifx\newattribute\@undefined\else % Test for plain
- \newattribute\bbl@attr@locale
+ \newattribute\bbl@attr@locale % DL4
\directlua{ Babel.attr_locale = luatexbase.registernumber'bbl@attr@locale' }
\AddBabelHook{luatex}{beforeextras}{%
\setattribute\bbl@attr@locale\localeid}
@@ -379,28 +408,8 @@ end
{\csname bbl@patterns@\bbl@tempa\endcsname\space}%
#2}}}%
\fi}}
-\directlua{
- Babel = Babel or {}
- Babel.linebreaking = Babel.linebreaking or {}
- Babel.linebreaking.before = {}
- Babel.linebreaking.after = {}
- Babel.locale = {} % Free to use, indexed by \localeid
- function Babel.linebreaking.add_before(func, pos)
- tex.print([[\noexpand\csname bbl@luahyphenate\endcsname]])
- if pos == nil then
- table.insert(Babel.linebreaking.before, func)
- else
- table.insert(Babel.linebreaking.before, pos, func)
- end
- end
- function Babel.linebreaking.add_after(func)
- tex.print([[\noexpand\csname bbl@luahyphenate\endcsname]])
- table.insert(Babel.linebreaking.after, func)
- end
-}
\def\bbl@intraspace#1 #2 #3\@@{%
\directlua{
- Babel = Babel or {}
Babel.intraspaces = Babel.intraspaces or {}
Babel.intraspaces['\csname bbl@sbcp@\languagename\endcsname'] = %
{b = #1, p = #2, m = #3}
@@ -409,7 +418,6 @@ end
}}
\def\bbl@intrapenalty#1\@@{%
\directlua{
- Babel = Babel or {}
Babel.intrapenalties = Babel.intrapenalties or {}
Babel.intrapenalties['\csname bbl@sbcp@\languagename\endcsname'] = #1
Babel.locale_props[\the\localeid].intrapenalty = #1
@@ -422,7 +430,6 @@ end
\gdef\bbl@seaintraspace{&
\let\bbl@seaintraspace\relax
\directlua{
- Babel = Babel or {}
Babel.sea_enabled = true
Babel.sea_ranges = Babel.sea_ranges or {}
function Babel.set_chranges (script, chrng)
@@ -471,7 +478,6 @@ end
\gdef\bbl@cjkintraspace{%
\let\bbl@cjkintraspace\relax
\directlua{
- Babel = Babel or {}
require('babel-data-cjk.lua')
Babel.cjk_enabled = true
function Babel.cjk_linebreak(head)
@@ -496,8 +502,10 @@ end
class = props.cjk_quotes[item.char]
end
- if class == 'cp' then class = 'cl' end % )] as CL
- if class == 'id' then class = 'I' end
+ if class == 'cp' then class = 'cl' % )] as CL
+ elseif class == 'id' then class = 'I'
+ elseif class == 'cj' then class = 'I' % loose
+ end
local br = 0
if class and last_class and Babel.cjk_breaks[last_class][class] then
@@ -544,10 +552,10 @@ end
func(head)
end
end
+ lang.hyphenate(head)
if Babel.cjk_enabled then
Babel.cjk_linebreak(head)
end
- lang.hyphenate(head)
if Babel.linebreaking.after then
for k, func in ipairs(Babel.linebreaking.after) do
func(head)
@@ -568,7 +576,6 @@ end
\ifin@ % cjk
\bbl@cjkintraspace
\directlua{
- Babel = Babel or {}
Babel.locale_props = Babel.locale_props or {}
Babel.locale_props[\the\localeid].linebreak = 'c'
}%
@@ -580,7 +587,6 @@ end
\bbl@seaintraspace
\bbl@exp{\\\bbl@intraspace\bbl@cl{intsp}\\\@@}%
\directlua{
- Babel = Babel or {}
Babel.sea_ranges = Babel.sea_ranges or {}
Babel.set_chranges('\bbl@cl{sbcp}',
'\bbl@cl{chrng}')
@@ -844,23 +850,10 @@ end
}
\endgroup
\fi\fi % ends Arabic just block: \ifnum\bbl@bidimode>100...
+\bbl@trace{Font handling with fontspec}
\AddBabelHook{babel-fontspec}{afterextras}{\bbl@switchfont}
\AddBabelHook{babel-fontspec}{beforestart}{\bbl@ckeckstdfonts}
\DisableBabelHook{babel-fontspec}
-\bbl@trace{Font handling with fontspec}
-\ifx\ExplSyntaxOn\@undefined\else
- \def\bbl@fs@warn@nx#1#2{% \bbl@tempfs is the original macro
- \in@{,#1,}{,no-script,language-not-exist,}%
- \ifin@\else\bbl@tempfs@nx{#1}{#2}\fi}
- \def\bbl@fs@warn@nxx#1#2#3{%
- \in@{,#1,}{,no-script,language-not-exist,}%
- \ifin@\else\bbl@tempfs@nxx{#1}{#2}{#3}\fi}
- \def\bbl@loadfontspec{%
- \let\bbl@loadfontspec\relax
- \ifx\fontspec\@undefined
- \usepackage{fontspec}%
- \fi}%
-\fi
\@onlypreamble\babelfont
\newcommand\babelfont[2][]{% 1=langs/scripts 2=fam
\bbl@foreach{#1}{%
@@ -871,8 +864,10 @@ end
\fi}%
\edef\bbl@tempa{#1}%
\def\bbl@tempb{#2}% Used by \bbl@bblfont
- \bbl@loadfontspec
- \EnableBabelHook{babel-fontspec}% Just calls \bbl@switchfont
+ \ifx\fontspec\@undefined
+ \usepackage{fontspec}%
+ \fi
+ \EnableBabelHook{babel-fontspec}%
\bbl@bblfont}
\newcommand\bbl@bblfont[2][]{% 1=features 2=fontname, @font=rm|sf|tt
\bbl@ifunset{\bbl@tempb family}%
@@ -996,17 +991,10 @@ end
{\\\newfontscript{\bbl@cl{sname}}{\bbl@cl{sotf}}}%
\<keys_if_exist:nnF>{fontspec-opentype}{Language/\bbl@cl{lname}}%
{\\\newfontlanguage{\bbl@cl{lname}}{\bbl@cl{lotf}}}%
- \let\\\bbl@tempfs@nx\<__fontspec_warning:nx>%
- \let\<__fontspec_warning:nx>\\\bbl@fs@warn@nx
- \let\\\bbl@tempfs@nxx\<__fontspec_warning:nxx>%
- \let\<__fontspec_warning:nxx>\\\bbl@fs@warn@nxx
\\\renewfontfamily\\#4%
[\bbl@cl{lsys},% xetex removes unknown features :-(
\ifcase\bbl@engine\or RawFeature={family=\bbl@tempb},\fi
#2]}{#3}% ie \bbl@exp{..}{#3}
- \bbl@exp{%
- \let\<__fontspec_warning:nx>\\\bbl@tempfs@nx
- \let\<__fontspec_warning:nxx>\\\bbl@tempfs@nxx}%
\begingroup
#4%
\xdef#1{\f@family}% eg, \bbl@rmdflt@lang{FreeSerif(0)}
@@ -1027,7 +1015,7 @@ end
\def\bbl@font@rst#1#2#3#4{%
\bbl@csarg\def{famrst@#4}{\bbl@font@set{#1}#2#3}}
\def\bbl@font@fams{rm,sf,tt}
-\directlua{
+\directlua{% DL6
Babel.script_blocks = {
['dflt'] = {},
['Arab'] = {{0x0600, 0x06FF}, {0x08A0, 0x08FF}, {0x0750, 0x077F},
@@ -1195,7 +1183,7 @@ end
Babel.chr_to_loc[\the\count@] =
\bbl@ifblank{#1}{-1000}{\the\bbl@cs{id@@#1}}\space
}}
-\directlua{
+\directlua{% DL7
Babel.nohyphenation = \the\l@nohyphenation
}
\begingroup
@@ -1223,23 +1211,26 @@ end
{\bbl@add@list\babeltempb{nil}}&%
{\directlua{
local rep = [=[##1]=]
+ local three_args = '%s*=%s*([%-%d%.%a{}|]+)%s+([%-%d%.%a{}|]+)%s+([%-%d%.%a{}|]+)'
+ &% Numeric passes directly: kern, penalty...
rep = rep:gsub('^%s*(remove)%s*$', 'remove = true')
rep = rep:gsub('^%s*(insert)%s*,', 'insert = true, ')
rep = rep:gsub('^%s*(after)%s*,', 'after = true, ')
rep = rep:gsub('(string)%s*=%s*([^%s,]*)', Babel.capture_func)
rep = rep:gsub('node%s*=%s*(%a+)%s*(%a*)', Babel.capture_node)
- rep = rep:gsub(&%
- '(norule)%s*=%s*([%-%d%.]+)%s+([%-%d%.]+)%s+([%-%d%.]+)',
- 'norule = {' .. '%2, %3, %4' .. '}')
+ rep = rep:gsub( '(norule)' .. three_args,
+ 'norule = {' .. '%2, %3, %4' .. '}')
if #1 == 0 or #1 == 2 then
- rep = rep:gsub(&%
- '(space)%s*=%s*([%-%d%.]+)%s+([%-%d%.]+)%s+([%-%d%.]+)',
+ rep = rep:gsub( '(space)' .. three_args,
'space = {' .. '%2, %3, %4' .. '}')
- rep = rep:gsub(&%
- '(spacefactor)%s*=%s*([%-%d%.]+)%s+([%-%d%.]+)%s+([%-%d%.]+)',
+ rep = rep:gsub( '(spacefactor)' .. three_args,
'spacefactor = {' .. '%2, %3, %4' .. '}')
rep = rep:gsub('(kashida)%s*=%s*([^%s,]*)', Babel.capture_kashida)
- else
+ &% Transform values
+ rep, n = rep:gsub( '{([%a%-%.]+)|([%-%d%.]+)}',
+ '{\the\csname bbl@id@@#3\endcsname,"%1",%2}')
+ end
+ if #1 == 1 then
rep = rep:gsub( '(no)%s*=%s*([^%s,]*)', Babel.capture_func)
rep = rep:gsub( '(pre)%s*=%s*([^%s,]*)', Babel.capture_func)
rep = rep:gsub( '(post)%s*=%s*([^%s,]*)', Babel.capture_func)
@@ -1248,8 +1239,8 @@ end
}}}&%
\bbl@foreach\babeltempb{&%
\bbl@forkv{{##1}}{&%
- \in@{,####1,}{,nil,step,data,remove,insert,string,no,pre,&%
- no,post,penalty,kashida,space,spacefactor,kern,node,after,}&%
+ \in@{,####1,}{,nil,step,data,remove,insert,string,no,pre,no,&%
+ post,penalty,kashida,space,spacefactor,kern,node,after,norule,}&%
\ifin@\else
\bbl@error{bad-transform-option}{####1}{}{}&%
\fi}}&%
@@ -1375,13 +1366,15 @@ end
require('babel-transforms.lua')
Babel.linebreaking.add_before(Babel.pre_hyphenate_replace)
}}
+\newcommand\SetTransformValue[3]{%
+ \directlua{
+ Babel.locale_props[\the\csname bbl@id@@#1\endcsname].vars["#2"] = #3
+ }}
\newcommand\localeprehyphenation[1]{%
\directlua{ Babel.string_prehyphenation([==[#1]==], \the\localeid) }}
\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)
@@ -1392,7 +1385,7 @@ end
return head
end
%
- function Babel.pre_otfload_h(head, gc, sz, pt, dir)
+ function Babel.pre_otfload_h(head, gc, sz, pt, dir) %%% TODO
if Babel.numbers and Babel.digits_mapped then
head = Babel.numbers(head)
end
@@ -1415,7 +1408,7 @@ end
'luaotfload.node_processor') or nil)
}}
\breakafterdirmode=1
-\ifnum\bbl@bidimode>\@ne % Any bidi= except default=1
+\ifnum\bbl@bidimode>\@ne % Any bidi= except default (=1)
\let\bbl@beforeforeign\leavevmode
\AtEndOfPackage{\EnableBabelHook{babel-bidi}}
\RequirePackage{luatexbase}
@@ -1426,6 +1419,9 @@ end
require('babel-bidi-basic.lua')
\or
require('babel-bidi-basic-r.lua')
+ table.insert(Babel.ranges, {0xE000, 0xF8FF, 'on'})
+ table.insert(Babel.ranges, {0xF0000, 0xFFFFD, 'on'})
+ table.insert(Babel.ranges, {0x100000, 0x10FFFD, 'on'})
\fi}
\newattribute\bbl@attr@dir
\directlua{ Babel.attr_dir = luatexbase.registernumber'bbl@attr@dir' }
@@ -1493,6 +1489,12 @@ end
end
luatexbase.add_to_callback("hpack_filter", Babel.math_box_dir,
"Babel.math_box_dir", 0)
+ if Babel.unset_atdir then
+ luatexbase.add_to_callback("pre_linebreak_filter", Babel.unset_atdir,
+ "Babel.unset_atdir")
+ luatexbase.add_to_callback("hpack_filter", Babel.unset_atdir,
+ "Babel.unset_atdir")
+ end
}}%
\fi
\DeclareRobustCommand\localebox[1]{%
@@ -1638,6 +1640,115 @@ end
\fi\fi}
\fi
\def\bbl@provide@extra#1{%
+ % == onchar ==
+ \ifx\bbl@KVP@onchar\@nnil\else
+ \bbl@luahyphenate
+ \bbl@exp{%
+ \\\AddToHook{env/document/before}{{\\\select@language{#1}{}}}}%
+ \directlua{
+ if Babel.locale_mapped == nil then
+ Babel.locale_mapped = true
+ Babel.linebreaking.add_before(Babel.locale_map, 1)
+ Babel.loc_to_scr = {}
+ Babel.chr_to_loc = Babel.chr_to_loc or {}
+ end
+ Babel.locale_props[\the\localeid].letters = false
+ }%
+ \bbl@xin@{ letters }{ \bbl@KVP@onchar\space}%
+ \ifin@
+ \directlua{
+ Babel.locale_props[\the\localeid].letters = true
+ }%
+ \fi
+ \bbl@xin@{ ids }{ \bbl@KVP@onchar\space}%
+ \ifin@
+ \ifx\bbl@starthyphens\@undefined % Needed if no explicit selection
+ \AddBabelHook{babel-onchar}{beforestart}{{\bbl@starthyphens}}%
+ \fi
+ \bbl@exp{\\\bbl@add\\\bbl@starthyphens
+ {\\\bbl@patterns@lua{\languagename}}}%
+ \directlua{
+ if Babel.script_blocks['\bbl@cl{sbcp}'] then
+ Babel.loc_to_scr[\the\localeid] = Babel.script_blocks['\bbl@cl{sbcp}']
+ Babel.locale_props[\the\localeid].lg = \the\@nameuse{l@\languagename}\space
+ end
+ }%
+ \fi
+ \bbl@xin@{ fonts }{ \bbl@KVP@onchar\space}%
+ \ifin@
+ \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}%
+ \bbl@ifunset{bbl@wdir@\languagename}{\bbl@provide@dirs{\languagename}}{}%
+ \directlua{
+ if Babel.script_blocks['\bbl@cl{sbcp}'] then
+ Babel.loc_to_scr[\the\localeid] =
+ Babel.script_blocks['\bbl@cl{sbcp}']
+ end}%
+ \ifx\bbl@mapselect\@undefined % TODO. almost the same as mapfont
+ \AtBeginDocument{%
+ \bbl@patchfont{{\bbl@mapselect}}%
+ {\selectfont}}%
+ \def\bbl@mapselect{%
+ \let\bbl@mapselect\relax
+ \edef\bbl@prefontid{\fontid\font}}%
+ \def\bbl@mapdir##1{%
+ \begingroup
+ \setbox\z@\hbox{% Force text mode
+ \def\languagename{##1}%
+ \let\bbl@ifrestoring\@firstoftwo % To avoid font warning
+ \bbl@switchfont
+ \ifnum\fontid\font>\z@ % A hack, for the pgf nullfont hack
+ \directlua{
+ Babel.locale_props[\the\csname bbl@id@@##1\endcsname]%
+ ['/\bbl@prefontid'] = \fontid\font\space}%
+ \fi}%
+ \endgroup}%
+ \fi
+ \bbl@exp{\\\bbl@add\\\bbl@mapselect{\\\bbl@mapdir{\languagename}}}%
+ \fi
+ % TODO - catch non-valid values
+ \fi
+ % == mapfont ==
+ % For bidi texts, to switch the font based on direction
+ \ifx\bbl@KVP@mapfont\@nnil\else
+ \bbl@ifsamestring{\bbl@KVP@mapfont}{direction}{}%
+ {\bbl@error{unknown-mapfont}{}{}{}}%
+ \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}%
+ \bbl@ifunset{bbl@wdir@\languagename}{\bbl@provide@dirs{\languagename}}{}%
+ \ifx\bbl@mapselect\@undefined % TODO. See onchar.
+ \AtBeginDocument{%
+ \bbl@patchfont{{\bbl@mapselect}}%
+ {\selectfont}}%
+ \def\bbl@mapselect{%
+ \let\bbl@mapselect\relax
+ \edef\bbl@prefontid{\fontid\font}}%
+ \def\bbl@mapdir##1{%
+ {\def\languagename{##1}%
+ \let\bbl@ifrestoring\@firstoftwo % avoid font warning
+ \bbl@switchfont
+ \directlua{Babel.fontmap
+ [\the\csname bbl@wdir@##1\endcsname]%
+ [\bbl@prefontid]=\fontid\font}}}%
+ \fi
+ \bbl@exp{\\\bbl@add\\\bbl@mapselect{\\\bbl@mapdir{\languagename}}}%
+ \fi
+ % == Line breaking: CJK quotes ==
+ \ifcase\bbl@engine\or
+ \bbl@xin@{/c}{/\bbl@cl{lnbrk}}%
+ \ifin@
+ \bbl@ifunset{bbl@quote@\languagename}{}%
+ {\directlua{
+ Babel.locale_props[\the\localeid].cjk_quotes = {}
+ local cs = 'op'
+ for c in string.utfvalues(%
+ [[\csname bbl@quote@\languagename\endcsname]]) do
+ if Babel.cjk_characters[c].c == 'qu' then
+ Babel.locale_props[\the\localeid].cjk_quotes[c] = cs
+ end
+ cs = ( cs == 'op') and 'cl' or 'op'
+ end
+ }}%
+ \fi
+ \fi
% == Counters: mapdigits ==
% Native digits
\ifx\bbl@KVP@mapdigits\@nnil\else
@@ -1645,7 +1756,6 @@ end
{\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] =
@@ -1682,6 +1792,21 @@ end
\bbl@replace\bbl@tempa{transforms.}{}%
\bbl@carg\bbl@transforms{babel\bbl@tempa}{##2}{##3}%
\fi}%
+ \bbl@exp{%
+ \\\bbl@ifblank{\bbl@cl{dgnat}}%
+ {\let\\\bbl@tempa\relax}%
+ {\def\\\bbl@tempa{%
+ \\\bbl@elt{transforms.prehyphenation}%
+ {digits.native.1.0}{([0-9])}%
+ \\\bbl@elt{transforms.prehyphenation}%
+ {digits.native.1.1}{string={1\string|0123456789\string|\bbl@cl{dgnat}}}}}}%
+ \ifx\bbl@tempa\relax\else
+ \toks@\expandafter\expandafter\expandafter{%
+ \csname bbl@inidata@\languagename\endcsname}%
+ \bbl@csarg\edef{inidata@\languagename}{%
+ \unexpanded\expandafter{\bbl@tempa}%
+ \the\toks@}%
+ \fi
\csname bbl@inidata@\languagename\endcsname
\bbl@release@transforms\relax % \relax closes the last item.
\fi}
@@ -1702,7 +1827,9 @@ end
{\chardef\bbl@tabular@mode\z@}%
{\chardef\bbl@tabular@mode\@ne}}% Mixed, with LTR cols
\ifnum\bbl@bidimode>\@ne % Any lua bidi= except default=1
- \ifcase\bbl@tabular@mode\or % 1
+ % Redefine: vrules mess up dirs. TODO: why?
+ \def\@arstrut{\relax\copy\@arstrutbox}%
+ \ifcase\bbl@tabular@mode\or % 1 = Mixed - default
\let\bbl@parabefore\relax
\AddToHook{para/before}{\bbl@parabefore}
\AtBeginDocument{%
@@ -1727,7 +1854,7 @@ end
{\\\do@row@strut\<fi>}{\\\do@row@strut\<fi>\egroup}}}%
{}}%
\fi}%
- \or % 2
+ \or % 2 = All RTL - tabular
\let\bbl@parabefore\relax
\AddToHook{para/before}{\bbl@parabefore}%
\AtBeginDocument{%
@@ -1753,9 +1880,9 @@ end
\ifnum\bbl@bidimode>\z@ % Any bidi=
\def\bbl@nextfake#1{% non-local changes, use always inside a group!
\bbl@exp{%
- \def\\\bbl@insidemath{0}%
\mathdir\the\bodydir
#1% Once entered in math, set boxes to restore values
+ \def\\\bbl@insidemath{0}%
\<ifmmode>%
\everyvbox{%
\the\everyvbox