From 02faaa93e729ccb5f614869f1c46d15d2b5502d3 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 13 Feb 2023 20:55:01 +0000 Subject: babel (13feb23) git-svn-id: svn://tug.org/texlive/trunk@65823 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/source/latex/babel/babel.dtx | 309 +++++++++++++--------- Master/texmf-dist/source/latex/babel/babel.ins | 2 +- Master/texmf-dist/source/latex/babel/bbcompat.dtx | 2 +- Master/texmf-dist/source/latex/babel/locale.zip | Bin 848392 -> 848447 bytes 4 files changed, 188 insertions(+), 125 deletions(-) (limited to 'Master/texmf-dist/source/latex/babel') diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx index dc012550747..48cda3816bf 100644 --- a/Master/texmf-dist/source/latex/babel/babel.dtx +++ b/Master/texmf-dist/source/latex/babel/babel.dtx @@ -32,7 +32,7 @@ % % \iffalse %<*filedriver> -\ProvidesFile{babel.dtx}[2022/01/23 v3.85 The Babel package] +\ProvidesFile{babel.dtx}[2023/02/13 v3.86 The Babel package] \documentclass{ltxdoc} \GetFileInfo{babel.dtx} \usepackage{fontspec} @@ -2579,7 +2579,7 @@ languages. Polytonic Greek with but with some sections in Italian. Then, the first attempt should be: \begin{verbatim} -\usepackage[italian, greek.polutonic]{babel} +\usepackage[italian, greek.polutonico]{babel} \end{verbatim} But if, say, accents in Greek are not shown correctly, you can try \begin{verbatim} @@ -3884,6 +3884,14 @@ up explictly; for example: RTL A \foreignlanguage{english}{ltr text \thechapter{} and still ltr} RTL B \end{verbatim} +\Describe{localerestoredirs}{} + +\New{3.86} \textit{LuaTeX}. This command resets the internal text, +paragraph and body directions to those of the current locale (if +different). Sometimes changing directly these values can be useful for +some hacks, and this command helps in restoring the directions to the +correct ones. It can be used in |>| arguments of \textsf{array}, too. + \Describe{\BabelPatchSection}{\marg{section-name}} Mainly for bidi text, but it can be useful in other cases. @@ -4207,12 +4215,13 @@ with values |on| or |off|: \ttfamily bidi.mirroring\\ bidi.text\\ +bidi.math\\%* % bidi.mapdigits\\ -linebreak.sea\\ -linebreak.cjk\\ -justify.arabic\\ -layout.tabular\\ -layout.lists\\ +linebreak.sea\\%* +linebreak.cjk\\%* +justify.arabic\\%* +layout.tabular\\%* +layout.lists\\%* autoload.bcp47\\ bcp47.toname \end{multicols} @@ -4220,12 +4229,12 @@ bcp47.toname Other keys [to be documented] are: \begin{multicols}{3} \ttfamily -autoload.options\\ +autoload.options\\%* autoload.bcp47.prefix\\ autoload.bcp47.options\\ -prehyphenation.disable\\ +prehyphenation.disable\\%* select.write\\ -select.encoding\\ +select.encoding\\%* \end{multicols} For example, you can set |\babeladjust{bidi.text=off}| if you are using @@ -5286,8 +5295,8 @@ help from Bernd Raichle, for which I am grateful. % \section{Tools} % % \begin{macrocode} -%<> -%<> +%<> +%<> % \end{macrocode} % % \textbf{Do not use the following macros in \texttt{ldf} files. They @@ -11322,6 +11331,10 @@ help from Bernd Raichle, for which I am grateful. \bbl@adjust@lua{bidi}{bidi_enabled=true}} \@namedef{bbl@ADJ@bidi.text@off}{% \bbl@adjust@lua{bidi}{bidi_enabled=false}} +\@namedef{bbl@ADJ@bidi.math@on}{% + \let\bbl@noamsmath\@empty} +\@namedef{bbl@ADJ@bidi.math@off}{% + \let\bbl@noamsmath\relax} \@namedef{bbl@ADJ@bidi.mapdigits@on}{% \bbl@adjust@lua{bidi}{digits_mapped=true}} \@namedef{bbl@ADJ@bidi.mapdigits@off}{% @@ -11350,9 +11363,17 @@ help from Bernd Raichle, for which I am grateful. in vertical mode.}% {Maybe things change in the future, but this is what it is.}}} \@namedef{bbl@ADJ@layout.tabular@on}{% - \bbl@adjust@layout{\let\@tabular\bbl@NL@@tabular}} + \ifnum\bbl@tabular@mode=\tw@ + \bbl@adjust@layout{\let\@tabular\bbl@NL@@tabular}% + \else + \chardef\bbl@tabular@mode\@ne + \fi} \@namedef{bbl@ADJ@layout.tabular@off}{% - \bbl@adjust@layout{\let\@tabular\bbl@OL@@tabular}} + \ifnum\bbl@tabular@mode=\tw@ + \bbl@adjust@layout{\let\@tabular\bbl@OL@@tabular}% + \else + \chardef\bbl@tabular@mode\z@ + \fi} \@namedef{bbl@ADJ@layout.lists@on}{% \bbl@adjust@layout{\let\list\bbl@NL@list}} \@namedef{bbl@ADJ@layout.lists@off}{% @@ -12203,7 +12224,7 @@ help from Bernd Raichle, for which I am grateful. \def\bbl@setdirs#1{% TODO - math \ifcase\bbl@select@type % TODO - strictly, not the right test \bbl@bodydir{#1}% - \bbl@pardir{#1}% + \bbl@pardir{#1}% <- Must precede \bbl@textdir \fi \bbl@textdir{#1}} % TODO. Only if \bbl@bidimode > 0?: @@ -14863,7 +14884,7 @@ end % math with the package option bidi=. % % \begin{macrocode} -\ifnum\bbl@bidimode>100 \ifnum\bbl@bidimode<200 +\ifnum\bbl@bidimode>\@ne % Excludes default=1 \let\bbl@beforeforeign\leavevmode \AtEndOfPackage{\EnableBabelHook{babel-bidi}} \RequirePackage{luatexbase} @@ -14875,13 +14896,10 @@ end \or require('babel-bidi-basic-r.lua') \fi} - % TODO - to locale_props, not as separate attribute \newattribute\bbl@attr@dir \directlua{ Babel.attr_dir = luatexbase.registernumber'bbl@attr@dir' } - % TODO. I don't like it, hackish: \bbl@exp{\output{\bodydir\pagedir\the\output}} - \AtEndOfPackage{\EnableBabelHook{babel-bidi}} -\fi\fi +\fi \chardef\bbl@thetextdir\z@ \chardef\bbl@thepardir\z@ \def\bbl@getluadir#1{% @@ -14901,52 +14919,45 @@ end #2 TRT\relax \fi \fi} +% ..00PPTT, with masks 0xC (par dir) and 0x3 (text dir) \def\bbl@thedir{0} \def\bbl@textdir#1{% \bbl@setluadir{text}\textdir{#1}% \chardef\bbl@thetextdir#1\relax - % par/text 0..8 = l/l l/r l/al r/l r/r r/al al/l al/r al/al - \edef\bbl@thedir{\the\numexpr\bbl@thepardir*3+#1}% - \setattribute\bbl@attr@dir{\numexpr\bbl@thepardir*3+#1}} -\def\bbl@pardir#1{% + \edef\bbl@thedir{\the\numexpr\bbl@thepardir*4+#1}% + \setattribute\bbl@attr@dir{\numexpr\bbl@thepardir*4+#1}} +\def\bbl@pardir#1{% Used twice \bbl@setluadir{par}\pardir{#1}% \chardef\bbl@thepardir#1\relax} -\def\bbl@bodydir{\bbl@setluadir{body}\bodydir} -\def\bbl@pagedir{\bbl@setluadir{page}\pagedir} -\def\bbl@dirparastext{\pardir\the\textdir\relax}% %%%% +\def\bbl@bodydir{\bbl@setluadir{body}\bodydir}% Used once +\def\bbl@pagedir{\bbl@setluadir{page}\pagedir}% Unused +\def\bbl@dirparastext{\pardir\the\textdir\relax}% Used once +% \end{macrocode} +% +% RTL text inside math needs special attention. It affects not only to +% actual math stuff, but also to `tabular`, which is based on a fake +% math. % +% \begin{macrocode} \ifnum\bbl@bidimode>\z@ \def\bbl@insidemath{0}% - \def\bbl@mathboxdir{% - \ifcase\bbl@thetextdir\relax - \everyhbox{\bbl@mathboxdir@aux L}% - \else - \everyhbox{\bbl@mathboxdir@aux R}% - \fi} - \def\bbl@mathboxdir@aux#1{% - \@ifnextchar\egroup{}{\textdir T#1T\relax}} - \def\bbl@everymath{\bbl@mathboxdir} - \def\bbl@everydisplay{% - \bbl@mathboxdir - \def\bbl@everymath{\bbl@mathboxdir}} + \def\bbl@everymath{\def\bbl@insidemath{1}} + \def\bbl@everydisplay{\def\bbl@insidemath{2}} \frozen@everymath\expandafter{% \expandafter\bbl@everymath\the\frozen@everymath} \frozen@everydisplay\expandafter{% \expandafter\bbl@everydisplay\the\frozen@everydisplay} \AtBeginDocument{ \directlua{ - Babel.use_math_box_dir = true function Babel.math_box_dir(head) - if Babel.use_math_box_dir then - if not (token.get_macro('bbl@insidemath') == '0') then - if Babel.hlist_has_bidi(head) then - local d = node.new(node.id'dir') - d.dir = '+TRT' - node.insert_before(head, node.has_glyph(head), d) - for item in node.traverse(head) do - node.set_attribute(item, - Babel.attr_dir, token.get_macro('bbl@thedir')) - end + if not (token.get_macro('bbl@insidemath') == '0') then + if Babel.hlist_has_bidi(head) then + local d = node.new(node.id'dir') + d.dir = '+TRT' + node.insert_before(head, node.has_glyph(head), d) + for item in node.traverse(head) do + node.set_attribute(item, + Babel.attr_dir, token.get_macro('bbl@thedir')) end end end @@ -14990,10 +15001,9 @@ end \DeclareOption{fleqn}{\chardef\bbl@eqnpos\tw@} %<> % -\def\BabelNoAMSMath{\let\bbl@noamsmath\relax} \ifnum\bbl@bidimode>\z@ \ifx\matheqdirmode\@undefined\else - \matheqdirmode\@ne + \matheqdirmode\@ne % A luatex primitive \fi \let\bbl@eqnodir\relax \def\bbl@eqdel{()} @@ -15019,6 +15029,7 @@ end \eqno\hbox{#1}% \fi} \AtBeginDocument{% + \ifx\bbl@noamsmath\relax\else \ifx\maketag@@@\@undefined % Normal equation, eqnarray \AddToHook{env/equation/begin}{% \ifnum\bbl@thetextdir>\z@ @@ -15038,7 +15049,6 @@ end \fi \AddToHook{env/eqnarray/begin}{% \ifnum\bbl@thetextdir>\z@ - \def\bbl@mathboxdir{\def\bbl@insidemath{1}} \def\bbl@mathboxdir{\def\bbl@insidemath{1}}% \edef\bbl@eqnodir{\noexpand\bbl@textdir{\the\bbl@thetextdir}}% \chardef\bbl@thetextdir\z@ @@ -15054,77 +15064,75 @@ end % Hack. YA luatex bug?: \expandafter\bbl@sreplace\csname] \endcsname{$$}{\eqno\kern.001pt$$}% \else % amstex - \ifx\bbl@noamsmath\@undefined - \bbl@exp{% Hack to hide maybe undefined conditionals: - \chardef\bbl@eqnpos=0% - \1\\2\\\relax}% - \ifnum\bbl@eqnpos=\@ne - \let\bbl@ams@lap\hbox - \else - \let\bbl@ams@lap\llap - \fi - \ExplSyntaxOn - \bbl@sreplace\intertext@{\normalbaselines}% - {\normalbaselines - \ifx\bbl@eqnodir\relax\else\bbl@pardir\@ne\bbl@eqnodir\fi}% - \ExplSyntaxOff - \def\bbl@ams@tagbox#1#2{#1{\bbl@eqnodir#2}}% #1=hbox|@lap|flip - \ifx\bbl@ams@lap\hbox % leqno - \def\bbl@ams@flip#1{% - \hbox to 0.01pt{\hss\hbox to\displaywidth{{#1}\hss}}}% - \else % eqno - \def\bbl@ams@flip#1{% - \hbox to 0.01pt{\hbox to\displaywidth{\hss{#1}}\hss}}% - \fi - \def\bbl@ams@preset#1{% + \bbl@exp{% Hack to hide maybe undefined conditionals: + \chardef\bbl@eqnpos=0% + \1\\2\\\relax}% + \ifnum\bbl@eqnpos=\@ne + \let\bbl@ams@lap\hbox + \else + \let\bbl@ams@lap\llap + \fi + \ExplSyntaxOn + \bbl@sreplace\intertext@{\normalbaselines}% + {\normalbaselines + \ifx\bbl@eqnodir\relax\else\bbl@pardir\@ne\bbl@eqnodir\fi}% + \ExplSyntaxOff + \def\bbl@ams@tagbox#1#2{#1{\bbl@eqnodir#2}}% #1=hbox|@lap|flip + \ifx\bbl@ams@lap\hbox % leqno + \def\bbl@ams@flip#1{% + \hbox to 0.01pt{\hss\hbox to\displaywidth{{#1}\hss}}}% + \else % eqno + \def\bbl@ams@flip#1{% + \hbox to 0.01pt{\hbox to\displaywidth{\hss{#1}}\hss}}% + \fi + \def\bbl@ams@preset#1{% + \def\bbl@mathboxdir{\def\bbl@insidemath{1}}% + \ifnum\bbl@thetextdir>\z@ + \edef\bbl@eqnodir{\noexpand\bbl@textdir{\the\bbl@thetextdir}}% + \bbl@sreplace\textdef@{\hbox}{\bbl@ams@tagbox\hbox}% + \bbl@sreplace\maketag@@@{\hbox}{\bbl@ams@tagbox#1}% + \fi}% + \ifnum\bbl@eqnpos=\tw@\else + \def\bbl@ams@equation{% \def\bbl@mathboxdir{\def\bbl@insidemath{1}}% \ifnum\bbl@thetextdir>\z@ \edef\bbl@eqnodir{\noexpand\bbl@textdir{\the\bbl@thetextdir}}% - \bbl@sreplace\textdef@{\hbox}{\bbl@ams@tagbox\hbox}% - \bbl@sreplace\maketag@@@{\hbox}{\bbl@ams@tagbox#1}% - \fi}% - \ifnum\bbl@eqnpos=\tw@\else - \def\bbl@ams@equation{% - \def\bbl@mathboxdir{\def\bbl@insidemath{1}}% - \ifnum\bbl@thetextdir>\z@ - \edef\bbl@eqnodir{\noexpand\bbl@textdir{\the\bbl@thetextdir}}% - \chardef\bbl@thetextdir\z@ - \bbl@add\normalfont{\bbl@eqnodir}% - \ifcase\bbl@eqnpos - \def\veqno##1##2{\bbl@eqno@flip{##1##2}}% - \or - \def\veqno##1##2{\bbl@leqno@flip{##1##2}}% - \fi - \fi}% - \AddToHook{env/equation/begin}{\bbl@ams@equation}% - \AddToHook{env/equation*/begin}{\bbl@ams@equation}% - \fi - \AddToHook{env/cases/begin}{\bbl@ams@preset\bbl@ams@lap}% - \AddToHook{env/multline/begin}{\bbl@ams@preset\hbox}% - \AddToHook{env/gather/begin}{\bbl@ams@preset\bbl@ams@lap}% - \AddToHook{env/gather*/begin}{\bbl@ams@preset\bbl@ams@lap}% - \AddToHook{env/align/begin}{\bbl@ams@preset\bbl@ams@lap}% - \AddToHook{env/align*/begin}{\bbl@ams@preset\bbl@ams@lap}% - \AddToHook{env/eqnalign/begin}{\bbl@ams@preset\hbox}% - % Hackish, for proper alignment. Don’t ask me why it works!: - \bbl@exp{% Avoid a 'visible' conditional - \\\AddToHook{env/align*/end}{\\\\\tag*{}\}}% - \AddToHook{env/flalign/begin}{\bbl@ams@preset\hbox}% - \AddToHook{env/split/before}{% - \def\bbl@mathboxdir{\def\bbl@insidemath{1}}% - \ifnum\bbl@thetextdir>\z@ - \bbl@ifsamestring\@currenvir{equation}% - {\ifx\bbl@ams@lap\hbox % leqno - \def\bbl@ams@flip#1{% - \hbox to 0.01pt{\hbox to\displaywidth{{#1}\hss}\hss}}% - \else - \def\bbl@ams@flip#1{% - \hbox to 0.01pt{\hss\hbox to\displaywidth{\hss{#1}}}}% - \fi}% - {}% + \chardef\bbl@thetextdir\z@ + \bbl@add\normalfont{\bbl@eqnodir}% + \ifcase\bbl@eqnpos + \def\veqno##1##2{\bbl@eqno@flip{##1##2}}% + \or + \def\veqno##1##2{\bbl@leqno@flip{##1##2}}% + \fi \fi}% + \AddToHook{env/equation/begin}{\bbl@ams@equation}% + \AddToHook{env/equation*/begin}{\bbl@ams@equation}% \fi - \fi} + \AddToHook{env/cases/begin}{\bbl@ams@preset\bbl@ams@lap}% + \AddToHook{env/multline/begin}{\bbl@ams@preset\hbox}% + \AddToHook{env/gather/begin}{\bbl@ams@preset\bbl@ams@lap}% + \AddToHook{env/gather*/begin}{\bbl@ams@preset\bbl@ams@lap}% + \AddToHook{env/align/begin}{\bbl@ams@preset\bbl@ams@lap}% + \AddToHook{env/align*/begin}{\bbl@ams@preset\bbl@ams@lap}% + \AddToHook{env/eqnalign/begin}{\bbl@ams@preset\hbox}% + % Hackish, for proper alignment. Don’t ask me why it works!: + \bbl@exp{% Avoid a 'visible' conditional + \\\AddToHook{env/align*/end}{\\\\\tag*{}\}}% + \AddToHook{env/flalign/begin}{\bbl@ams@preset\hbox}% + \AddToHook{env/split/before}{% + \def\bbl@mathboxdir{\def\bbl@insidemath{1}}% + \ifnum\bbl@thetextdir>\z@ + \bbl@ifsamestring\@currenvir{equation}% + {\ifx\bbl@ams@lap\hbox % leqno + \def\bbl@ams@flip#1{% + \hbox to 0.01pt{\hbox to\displaywidth{{#1}\hss}\hss}}% + \else + \def\bbl@ams@flip#1{% + \hbox to 0.01pt{\hss\hbox to\displaywidth{\hss{#1}}}}% + \fi}% + {}% + \fi}% + \fi\fi} \fi \def\bbl@provide@extra#1{% % == Counters: mapdigits == @@ -15174,8 +15182,63 @@ end \csname bbl@inidata@\languagename\endcsname \bbl@release@transforms\relax % \relax closes the last item. \fi} +% Start tabular here: +\def\localerestoredirs{% + \ifcase\bbl@thetextdir + \ifnum\textdirection=\z@\else\textdir TLT\fi + \else + \ifnum\textdirection=\@ne\else\textdir TRT\fi + \fi + \ifcase\bbl@thepardir + \ifnum\pardirection=\z@\else\pardir TLT\bodydir TLT\fi + \else + \ifnum\pardirection=\@ne\else\pardir TRT\bodydir TRT\fi + \fi} +\IfBabelLayout{tabular}% + {\chardef\bbl@tabular@mode\tw@}% All RTL + {\IfBabelLayout{notabular}% + {\chardef\bbl@tabular@mode\z@}% + {\chardef\bbl@tabular@mode\@ne}}% Mixed, with LTR cols +\ifnum\bbl@bidimode>\@ne + \ifnum\bbl@tabular@mode=\@ne + \let\bbl@parabefore\relax + \AddToHook{para/before}{\bbl@parabefore} + \AtBeginDocument{% + \bbl@replace\@tabular{$}{$% + \def\bbl@insidemath{0}% + \def\bbl@parabefore{\localerestoredirs}}% + \ifnum\bbl@tabular@mode=\@ne + \bbl@ifunset{@tabclassz}{}{% + \bbl@exp{% Hide conditionals + \\\bbl@sreplace\\\@tabclassz + {\\\\@chnum}% + {\\\localerestoredirs\\\\@chnum}}}% + \@ifpackageloaded{colortbl}% + {\bbl@sreplace\@classz + {\hbox\bgroup\bgroup}{\hbox\bgroup\bgroup\localerestoredirs}}% + {\@ifpackageloaded{array}% + {\bbl@exp{% Hide conditionals + \\\bbl@sreplace\\\@classz + {\\\\@chnum}% + {\bgroup\\\localerestoredirs\\\\@chnum}% + \\\bbl@sreplace\\\@classz + {\\\do@row@strut\}{\\\do@row@strut\\egroup}}}% + {}}% + \fi} + \fi +\fi \ifx\bbl@opt@layout\@nnil\endinput\fi % if no layout +% \end{macrocode} % +% \textsc{Omega} provided a companion to |\mathdir| (|\nextfakemath|) +% for those cases where we did not want it to be applied, so that the +% writing direction of the main text was left unchanged. +% |\bbl@nextfake| is an attempt to emulate it, because \luatex{} has +% removed it without an alternative. Also, |\hangindent| does not +% honour direction changes by default, so we need to redefine +% |\@hangfrom|. +% +% \begin{macrocode} \ifnum\bbl@bidimode>\z@ \def\bbl@nextfake#1{% non-local changes, use always inside a group! \bbl@exp{% @@ -22113,7 +22176,7 @@ function Babel.bidi(head, ispar) attr_dir = 0 for at in node.traverse(item.attr) do if at.number == Babel.attr_dir then - attr_dir = at.value % 3 + attr_dir = at.value & 0x3 end end if attr_dir == 1 then @@ -22373,7 +22436,7 @@ function Babel.bidi(head, ispar, hdir) local save_outer local temp = node.get_attribute(head, ATDIR) if temp then - temp = temp % 3 + temp = temp & 0x3 save_outer = (temp == 0 and 'l') or (temp == 1 and 'r') or (temp == 2 and 'al') @@ -22443,7 +22506,7 @@ function Babel.bidi(head, ispar, hdir) attr_d = 0 else attr_d = node.get_attribute(item, ATDIR) - attr_d = attr_d % 3 + attr_d = attr_d & 0x3 end if attr_d == 1 then outer_first = 'r' @@ -22471,7 +22534,7 @@ function Babel.bidi(head, ispar, hdir) elseif item.id == DIR then d = nil - -- new_d = true + if head ~= item then new_d = true end elseif item.id == node.id'glue' and item.subtype == 13 then diff --git a/Master/texmf-dist/source/latex/babel/babel.ins b/Master/texmf-dist/source/latex/babel/babel.ins index fbea84e25a0..1e1f4597776 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{2022/01/23} +\def\filedate{2023/02/13} \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 eb860ed322b..1c5d30d2e66 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}[2022/01/23 v3.85] +\ProvidesFile{bbcompat.dtx}[2023/02/13 v3.86] % % %% File 'bbcompat.dtx' diff --git a/Master/texmf-dist/source/latex/babel/locale.zip b/Master/texmf-dist/source/latex/babel/locale.zip index e0b19d9c794..d3313f2f8f2 100644 Binary files a/Master/texmf-dist/source/latex/babel/locale.zip and b/Master/texmf-dist/source/latex/babel/locale.zip differ -- cgit v1.2.3