From b06c6695162b493aeec3b594c6beb518c15c98ba Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Tue, 24 Jan 2023 03:02:57 +0000 Subject: CTAN sync 202301240302 --- macros/latex/required/babel/base/README.md | 23 +- macros/latex/required/babel/base/babel.dtx | 369 ++++++++++++++++++-------- macros/latex/required/babel/base/babel.ins | 4 +- macros/latex/required/babel/base/babel.pdf | Bin 902955 -> 917543 bytes macros/latex/required/babel/base/bbcompat.dtx | 2 +- 5 files changed, 278 insertions(+), 120 deletions(-) (limited to 'macros/latex/required/babel') diff --git a/macros/latex/required/babel/base/README.md b/macros/latex/required/babel/base/README.md index 7efdf6d9b1..ccb3cdd5b4 100644 --- a/macros/latex/required/babel/base/README.md +++ b/macros/latex/required/babel/base/README.md @@ -1,4 +1,6 @@ -## Babel 3.84 +## Babel 3.85 + +2023-01-23 This package manages culturally-determined typographical (and other) rules, and hyphenation patterns for a wide range of languages. Many @@ -8,9 +10,9 @@ is a set of ini files for about 250 languages. The latest stable version is available on . -Changes in version 3.84 are described in: +Changes in version 3.85 are described in: -https://latex3.github.io/babel/news/whats-new-in-babel-3.84.html +https://latex3.github.io/babel/news/whats-new-in-babel-3.85.html Apart from the manual, you can find information on some aspects of babel at: @@ -46,14 +48,15 @@ respective authors. ### Summary of latest changes ``` -3.84 2022-12-26 - * Automatic selection of encodings with \babelprovide and pdftex. +3.85 2023-01-23 + * A high-level interface to enable and disable transforms (lua). + * Font-dependent transforms (lua). + * Spaces allowed as separators in layout=. * Fixes: - - With 'select.write = omit' the main language wasn’t selected - in the aux file. - - Incorrect link box in end of line if it is preceded by a - non-Arabic character (#207) - - New option counters* the pre-expand \thepage. See #26. + - \babelprehyphenation was not applied with 'onchar'. + - In some rare cases the hyphenrules weren’t correctly set. + - Partial fix for bidi in tabular (broken after an attempt to + fix amsmath). ``` ### Previous changes diff --git a/macros/latex/required/babel/base/babel.dtx b/macros/latex/required/babel/base/babel.dtx index fe81253e4f..dc01255074 100644 --- a/macros/latex/required/babel/base/babel.dtx +++ b/macros/latex/required/babel/base/babel.dtx @@ -1,7 +1,7 @@ % \iffalse % This document requires lualatex %% -%% Copyright (C) 2012-2022 Javier Bezos and Johannes L. Braams. +%% Copyright (C) 2012-2023 Javier Bezos and Johannes L. Braams. %% Copyright (C) 1989-2012 Johannes L. Braams and %% any individual authors listed elsewhere in this file. %% All rights reserved. @@ -32,7 +32,7 @@ % % \iffalse %<*filedriver> -\ProvidesFile{babel.dtx}[2022/12/26 v3.84 The Babel package] +\ProvidesFile{babel.dtx}[2022/01/23 v3.85 The Babel package] \documentclass{ltxdoc} \GetFileInfo{babel.dtx} \usepackage{fontspec} @@ -433,6 +433,14 @@ This is not currently done by \babel{} and you must set it by hand. shorthands in those macros. \end{note} +\begin{note} + \Babel{} does not make any readjustments by default in font size, + vertical positioning or line height by default. This is on purpose + because the optimal solution depends on the document layout and the + font, and very likely the most appropriate one is a combination of + these settings. +\end{note} + \subsection{Multilingual documents} In multilingual documents, just use a list of the required languages as @@ -3355,6 +3363,34 @@ to \textit{ύ}, so that the diaeresis is removed. This feature is activated with the first |\babelposthyphenation| or |\babelprehyphenation|. +\New{3.85} Another option is |label|, which takes a value similar to +those in |\babelprovide| key |transforms| (in fact, the latter just +applies this option). This label can be used to turn on and off +transforms with a higher level interface, by means of +|\enablelocaletransform| and |\disablelocaletransform| (see below). + +\New{3.85} When used in conjunction with |label|, this key makes a +transform font dependent. As an example, the rules for Arabic kashida +can differ depending on the font design. The value consists in a list +of space-separated font tags: +\begin{verbatim} +\babelprehyphenation[label=transform.name, fonts=rm sf]{..}{..} +\end{verbatim} +Tags can adopt two forms: a family, such as |rm| or |tt|, or the set +family/series/shape. If a font matches one of these conditions, the +transform is enabled. The second tag in |rm rm/n/it| is redundant. +There are no wildcards; so, for italics you may want to write something +like |sf/m/it sf/b/it|. + +Transforms set for specific fonts (at least once in any language) are +always reset with a font selector. + +In |\babelprovide|, transform labels can be tagged before its name, +with a list separated with colons, like: +\begin{verbatim} +transforms = _rm:sf:_transform.name +\end{verbatim} + \New{3.67} With the optional argument you can associate a user defined transform to an attribute, so that it’s active only when it’s set (currently its attribute value is ignored). With this mechanism @@ -3364,7 +3400,7 @@ LaTeX kernel provides the macros |\newattribute|, |\setattribute| and |\unsetattribute|. The following example shows how to use it, provided an attribute named |\latinnoj| has been declared: \begin{verbatim} - \babelprehyphenation[attribute=\latinnoj]{latin}{ J }{ string = I } +\babelprehyphenation[attribute=\latinnoj]{latin}{ J }{ string = I } \end{verbatim} See the @@ -3437,6 +3473,12 @@ This feature is activated with the first |\babelposthyphenation| or linked to fonts, not to languages. \end{note} +\Describe{\enablelocaletransform}{\marg{label}} +\DescribeOther{\disablelocaletransform}{\marg{label}} + +\New{3.85} Enables and disables the transform with the given label in +the current language. + \subsection{Selection based on BCP 47 tags} \label{bcp47} @@ -3711,8 +3753,8 @@ Arabic as @1فصحى العصر@0 \textit{fuṣḥā l-ʻaṣr} (MSA) and \newcommand\refrange[2]{\babelsublr{\texthe{\ref{#1}}-\texthe{\ref{#2}}}} \end{verbatim} - In the future a more complete method, reading recursively boxed text, may - be added. + In the future a more complete method, reading recursively boxed text, + may be added. \end{note} \Describe{layout=}{\texttt{sectioning} $\string|$ @@ -3729,9 +3771,10 @@ Arabic as @1فصحى العصر@0 \textit{fuṣḥā l-ʻaṣr} (MSA) and adapted in bidi documents, including some text elements (except with options loading the |bidi| package, which provides its own mechanism to control these elements). You may use several options with a -dot-separated list (eg, |layout=counters.contents.sectioning|). This -list will be expanded in future releases. Note not all options are -required by all engines. +space-separated list, like |layout=counters contents sectioning| (in +\New{3.85} spaces are to be preferred over dots, which was the former +syntax). This list will be expanded in future releases. Note not all +options are required by all engines. \begin{description} \renewcommand\makelabel[1]{% @@ -3812,7 +3855,7 @@ the same for \textsf{pgf/tikz}. Somewhat experimental. \New{3.32}. Typically, in an Arabic document you would need: \begin{verbatim} \usepackage[bidi=basic, - layout=counters.tabular]{babel} + layout=counters tabular]{babel} \end{verbatim} \end{example} @@ -4747,6 +4790,11 @@ curly braces. The macros |\bbl@add@special|\meta{char} and |\bbl@remove@special|\meta{char} add and remove the character \meta{char} to these two sets. +\DescribeMacro{\@safe@activestrue} +\DescribeMacro{\@safe@activesfalse} +Enables and disables the “safe” mode. It is a tool for package and class +authors. See the description below. + \subsection{Support for saving macro definitions} Language definition files may want to \emph{re}define macros that @@ -5238,8 +5286,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 @@ -6021,6 +6069,12 @@ help from Bernd Raichle, for which I am grateful. \ifx\bbl@opt@layout\@nnil \newcommand\IfBabelLayout[3]{#3}% \else + \bbl@exp{\\\bbl@forkv{\@nameuse{@raw@opt@babel.sty}}}{% + \in@{,layout,}{,#1,}% + \ifin@ + \def\bbl@opt@layout{#2}% + \bbl@replace\bbl@opt@layout{ }{.}% + \fi} \newcommand\IfBabelLayout[1]{% \@expandtwoargs\in@{.#1.}{.\bbl@opt@layout.}% \ifin@ @@ -7830,11 +7884,17 @@ help from Bernd Raichle, for which I am grateful. % \end{macro} % % \begin{macro}{\if@safe@actives} -% In some circumstances it is necessary to be able to change the -% expansion of an active character on the fly. For this purpose the -% switch |@safe@actives| is available. The setting of this switch -% should be checked in the first level expansion of -% |\active@char|\m{char}. +% In some circumstances it is necessary to be able to reset the +% shorthand to its ‘normal’ value (usually the character with catcode +% ‘other’) on the fly. For this purpose the switch |@safe@actives| is +% available. The setting of this switch should be checked in the first +% level expansion of |\active@char|\m{char}. When this expansion mode +% is active (with |\@safe@activestrue|), something like +% |"|$\sb{13}$|"|$\sb{13}$ becomes |"|$\sb{12}$|"|$\sb{12}$ in an +% |\edef| (in other words, shorthands are |\string|’ed). This +% contrasts with |\protected@edef|, where catcodes are always left +% unchanged. Once converted, they can be used safely even after this +% expansion mode is deactivated (with |\@safe@activefalse|). % % \begin{macrocode} \newif\if@safe@actives @@ -7844,10 +7904,10 @@ help from Bernd Raichle, for which I am grateful. % \end{macro} % % \begin{macro}{\bbl@restore@actives} -% When the output routine kicks in while the -% active characters were made ``safe'' this must be undone in -% the headers to prevent unexpected typeset results. For this -% situation we define a command to make them ``unsafe'' again. +% When the output routine kicks in while the active characters were +% made ``safe'' this must be undone in the headers to prevent +% unexpected typeset results. For this situation we define a command to +% make them ``unsafe'' again. % % \begin{macrocode} \def\bbl@restore@actives{\if@safe@actives\@safe@activesfalse\fi} @@ -7858,10 +7918,10 @@ help from Bernd Raichle, for which I am grateful. % \begin{macro}{\bbl@activate} % \begin{macro}{\bbl@deactivate} % -% Both macros take one argument, like |\initiate@active@char|. The -% macro is used to change the definition of an active character to -% expand to |\active@char|\m{char} in the case of |\bbl@activate|, -% or |\normal@char|\m{char} in the case of |\bbl@deactivate|. +% Both macros take one argument, like |\initiate@active@char|. The +% macro is used to change the definition of an active character to +% expand to |\active@char|\m{char} in the case of |\bbl@activate|, +% or |\normal@char|\m{char} in the case of |\bbl@deactivate|. % % \begin{macrocode} \chardef\bbl@activated\z@ @@ -7891,16 +7951,16 @@ help from Bernd Raichle, for which I am grateful. % \end{macro} % \end{macro} % -% \begin{macro}{\declare@shorthand} -% The command |\declare@shorthand| is used to declare a shorthand -% on a certain level. It takes three arguments: -% \begin{enumerate} -% \item a name for the collection of shorthands, i.e. `system', or -% `dutch'; -% \item the character (sequence) that makes up the shorthand, -% i.e. |~| or |"a|; -% \item the code to be executed when the shorthand is encountered. -% \end{enumerate} +% \begin{macro}{\declare@shorthand} +% The command |\declare@shorthand| is used to declare a shorthand +% on a certain level. It takes three arguments: +% \begin{enumerate} +% \item a name for the collection of shorthands, i.e. `system', or +% `dutch'; +% \item the character (sequence) that makes up the shorthand, +% i.e. |~| or |"a|; +% \item the code to be executed when the shorthand is encountered. +% \end{enumerate} % % The auxiliary macro |\babel@texpdf| improves the interoperativity with % \textsf{hyperref} and takes 4 arguments: (1) The \TeX{} code in text @@ -8182,6 +8242,7 @@ help from Bernd Raichle, for which I am grateful. \def\bbl@putsh@i#1#2\@nnil{% \csname\language@group @sh@\string#1@% \ifx\@empty#2\else\string#2@\fi\endcsname} +% \ifx\bbl@opt@shorthands\@nnil\else \let\bbl@s@initiate@active@char\initiate@active@char \def\initiate@active@char#1{% @@ -8776,26 +8837,6 @@ help from Bernd Raichle, for which I am grateful. {\bbl@tolower\@empty}{\bbl@toupper\@empty}}% \gdef\bbl@tolower{\csname\languagename @bbl@lc\endcsname}% \gdef\bbl@toupper{\csname\languagename @bbl@uc\endcsname}}} -% A temporary hack, for testing purposes: -\def\BabelRestoreCase{% - \DeclareRobustCommand{\MakeUppercase}[1]{{% - \def\reserved@a####1####2{\let####1####2\reserved@a}% - \def\i{I}\def\j{J}% - \expandafter\reserved@a\@uclclist\reserved@b{\reserved@b\@gobble}% - \let\UTF@two@octets@noexpand\@empty - \let\UTF@three@octets@noexpand\@empty - \let\UTF@four@octets@noexpand\@empty - \protected@edef\reserved@a{\uppercase{##1}}% - \reserved@a - }}% - \DeclareRobustCommand{\MakeLowercase}[1]{{% - \def\reserved@a####1####2{\let####2####1\reserved@a}% - \expandafter\reserved@a\@uclclist\reserved@b{\reserved@b\@gobble}% - \let\UTF@two@octets@noexpand\@empty - \let\UTF@three@octets@noexpand\@empty - \let\UTF@four@octets@noexpand\@empty - \protected@edef\reserved@a{\lowercase{##1}}% - \reserved@a}}} % \end{macrocode} % % \begin{macrocode} @@ -9802,7 +9843,7 @@ help from Bernd Raichle, for which I am grateful. % \ifx\bbl@KVP@date\@nnil\else % \fi % == - \let\bbl@lbkflag\relax % \@empty = do setup linebreak + \let\bbl@lbkflag\relax % \@empty = do setup linebreak, only in 3 cases: \ifcase\bbl@howloaded \let\bbl@lbkflag\@empty % new \else @@ -9827,6 +9868,7 @@ help from Bernd Raichle, for which I am grateful. {}% \let\bbl@KVP@date\@empty \fi + \let\bbl@KVP@captions@@\bbl@KVP@captions % TODO. A dirty hack \ifx\bbl@KVP@captions\@nnil \let\bbl@KVP@captions\bbl@KVP@import \fi @@ -9891,7 +9933,7 @@ help from Bernd Raichle, for which I am grateful. \directlua{ if Babel.locale_mapped == nil then Babel.locale_mapped = true - Babel.linebreaking.add_before(Babel.locale_map) + Babel.linebreaking.add_before(Babel.locale_map, 1) Babel.loc_to_scr = {} Babel.chr_to_loc = Babel.chr_to_loc or {} end @@ -10230,48 +10272,49 @@ help from Bernd Raichle, for which I am grateful. {}} % \end{macrocode} % -% The |hyphenrules| option is handled with an auxiliary macro. +% The |hyphenrules| option is handled with an auxiliary macro. This +% macro is called in three cases: when a language is first declared +% with |\babelprovide|, with |hyphenrules| and with |import|. % % \begin{macrocode} \def\bbl@provide@hyphens#1{% - \let\bbl@tempa\relax + \@tempcnta\m@ne % a flag \ifx\bbl@KVP@hyphenrules\@nnil\else \bbl@replace\bbl@KVP@hyphenrules{ }{,}% \bbl@foreach\bbl@KVP@hyphenrules{% - \ifx\bbl@tempa\relax % if not yet found - \bbl@ifsamestring{##1}{+}% - {{\bbl@exp{\\\addlanguage\}}}% + \ifnum\@tempcnta=\m@ne % if not yet found + \bbl@ifsamestring{##1}{+}% + {\bbl@carg\addlanguage{l@##1}}% {}% - \bbl@ifunset{l@##1}% + \bbl@ifunset{l@##1}% After a possible + {}% - {\bbl@exp{\let\bbl@tempa\}}% + {\@tempcnta\@nameuse{l@##1}}% \fi}% - \ifx\bbl@tempa\relax + \ifnum\@tempcnta=\m@ne \bbl@warning{% Requested 'hyphenrules=' for '\languagename' not found.\\% Using the default value. Reported}% \fi \fi - \ifx\bbl@tempa\relax % if no opt or no language in opt found - \ifx\bbl@KVP@import\@nnil - \ifx\bbl@initoload\relax\else - \bbl@exp{% and hyphenrules is not empty - \\\bbl@ifblank{\bbl@cs{hyphr@#1}}% - {}% - {\let\\\bbl@tempa\}}% - \fi - \else % if importing - \bbl@exp{% and hyphenrules is not empty - \\\bbl@ifblank{\bbl@cs{hyphr@#1}}% - {}% - {\let\\\bbl@tempa\}}% + \ifnum\@tempcnta=\m@ne % if no opt or no language in opt found + \ifx\bbl@KVP@captions@@\@nnil % TODO. Hackish. See above. + \bbl@ifunset{bbl@hyphr@#1}{}% use value in ini, if exists + {\bbl@exp{\\\bbl@ifblank{\bbl@cs{hyphr@#1}}}% + {}% + {\bbl@ifunset{l@\bbl@cl{hyphr}}% + {}% if hyphenrules found: + {\@tempcnta\@nameuse{l@\bbl@cl{hyphr}}}}}% \fi \fi - \bbl@ifunset{bbl@tempa}% ie, relax or undefined - {\bbl@ifunset{l@#1}% no hyphenrules found - fallback - {\bbl@exp{\\\adddialect\\language}}% - {}}% so, l@ is ok - nothing to do - {\bbl@exp{\\\adddialect\\bbl@tempa}}}% found in opt list or ini + \bbl@ifunset{l@#1}% + {\ifnum\@tempcnta=\m@ne + \bbl@carg\adddialect{l@#1}\language + \else + \bbl@carg\adddialect{l@#1}\@tempcnta + \fi}% + {\ifnum\@tempcnta=\m@ne\else + \global\bbl@carg\chardef{l@#1}\@tempcnta + \fi}} % \end{macrocode} % % The reader of |babel-...tex| files. We reset temporarily some @@ -10952,27 +10995,44 @@ help from Bernd Raichle, for which I am grateful. \directlua{ local str = [==[#2]==] str = str:gsub('%.%d+%.%d+$', '') - tex.print([[\def\string\babeltempa{]] .. str .. [[}]]) + token.set_macro('babeltempa', str) }&% + \def\babeltempc{}&% \bbl@xin@{,\babeltempa,}{,\bbl@KVP@transforms,}&% + \ifin@\else + \bbl@xin@{:\babeltempa,}{,\bbl@KVP@transforms,}&% + \fi \ifin@ + \bbl@foreach\bbl@KVP@transforms{&% + \bbl@xin@{:\babeltempa,}{,##1,}&% + \ifin@ &% font:font:transform syntax + \directlua{ + local t = {} + for m in string.gmatch('##1'..':', '(.-):') do + table.insert(t, m) + end + table.remove(t) + token.set_macro('babeltempc', ',fonts=' .. table.concat(t, ' ')) + }&% + \fi}&% \in@{.0$}{#2$}&% \ifin@ \directlua{&% (\attribute) syntax local str = string.match([[\bbl@KVP@transforms]], '%(([^%(]-)%)[^%)]-\babeltempa') if str == nil then - tex.print([[\def\string\babeltempb{}]]) + token.set_macro('babeltempb', '') else - tex.print([[\def\string\babeltempb{,attribute=]] .. str .. [[}]]) + token.set_macro('babeltempb', ',attribute=' .. str) end - } + }&% \toks@{#3}&% \bbl@exp{&% \\\g@addto@macro\\\bbl@release@transforms{&% \relax &% Closes previous \bbl@transforms@aux \\\bbl@transforms@aux - \\#1{label=\babeltempa\babeltempb}{\languagename}{\the\toks@}}}&% + \\#1{label=\babeltempa\babeltempb\babeltempc}&% + {\languagename}{\the\toks@}}}&% \else \g@addto@macro\bbl@release@transforms{, {#3}}&% \fi @@ -12011,8 +12071,7 @@ help from Bernd Raichle, for which I am grateful. % % For several functions, we need to execute some code with % |\selectfont|. With \LaTeX\ 2021-06-01, there is a hook for this -% purpose, but in older versions the \LaTeX{} command is patched (the -% latter solution will be eventually removed). +% purpose. % % \begin{macrocode} \def\bbl@patchfont#1{\AddToHook{selectfont}{#1}} @@ -12112,8 +12171,8 @@ help from Bernd Raichle, for which I am grateful. \def\bbl@alscripts{,Arabic,Syriac,Thaana,} \def\bbl@rscripts{% TODO. Base on codes ?? ,Imperial Aramaic,Avestan,Cypriot,Hatran,Hebrew,% - Old Hungarian,Old Hungarian,Lydian,Mandaean,Manichaean,% - Manichaean,Meroitic Cursive,Meroitic,Old North Arabian,% + Old Hungarian,Lydian,Mandaean,Manichaean,% + Meroitic Cursive,Meroitic,Old North Arabian,% Nabataean,N'Ko,Orkhon,Palmyrene,Inscriptional Pahlavi,% Psalter Pahlavi,Phoenician,Inscriptional Parthian,Samaritan,% Old South Arabian,}% @@ -12951,8 +13010,8 @@ help from Bernd Raichle, for which I am grateful. % At the time of this writing, \textsf{fontspec} shows a warning about % there are languages not available, which some people think refers to % \babel{}, even if there is nothing wrong. Here is hack to patch -% \textsf{fontspec} to avoid the misleading message, which is replaced -% ba a more explanatory one. +% \textsf{fontspec} to avoid the misleading (and mostly unuseful) +% message. % % \begin{macrocode} %<<*Font selection>> @@ -13051,7 +13110,7 @@ help from Bernd Raichle, for which I am grateful. \global\let\% \}}}% {}}% 1=T - language, already defined - \def\bbl@tempa{\bbl@nostdfont{}}% + \def\bbl@tempa{\bbl@nostdfont{}}% TODO. Don't use \bbl@tempa \bbl@foreach\bbl@font@fams{% don't gather with prev for \bbl@ifunset{bbl@##1dflt@\languagename}% {\bbl@cs{famrst@##1}% @@ -13884,9 +13943,13 @@ end Babel.linebreaking.before = {} Babel.linebreaking.after = {} Babel.locale = {} % Free to use, indexed by \localeid - function Babel.linebreaking.add_before(func) + function Babel.linebreaking.add_before(func, pos) tex.print([[\noexpand\csname bbl@luahyphenate\endcsname]]) - table.insert(Babel.linebreaking.before, func) + 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]]) @@ -14615,8 +14678,36 @@ end \fi}}&% \let\bbl@kv@attribute\relax \let\bbl@kv@label\relax + \let\bbl@kv@fonts\@empty \bbl@forkv{#2}{\bbl@csarg\edef{kv@##1}{##2}}&% - \ifx\bbl@kv@attribute\relax\else + \ifx\bbl@kv@fonts\@empty\else\bbl@settransfont\fi + \ifx\bbl@kv@attribute\relax + \ifx\bbl@kv@label\relax\else + \bbl@exp{\\\bbl@trim@def\\\bbl@kv@fonts{\bbl@kv@fonts}}&% + \bbl@replace\bbl@kv@fonts{ }{,}&% + \edef\bbl@kv@attribute{bbl@ATR@\bbl@kv@label @#3@\bbl@kv@fonts}&% + \count@\z@ + \def\bbl@elt##1##2##3{&% + \bbl@ifsamestring{#3,\bbl@kv@label}{##1,##2}&% + {\bbl@ifsamestring{\bbl@kv@fonts}{##3}&% + {\count@\@ne}&% + {\bbl@error + {Transforms cannot be re-assigned to different\\&% + fonts. The conflict is in '\bbl@kv@label'.\\&% + Apply the same fonts or use a different label}&% + {See the manual for further details.}}}&% + {}}&% + \bbl@transfont@list + \ifnum\count@=\z@ + \bbl@exp{\global\\\bbl@add\\\bbl@transfont@list + {\\\bbl@elt{#3}{\bbl@kv@label}{\bbl@kv@fonts}}}&% + \fi + \bbl@ifunset{\bbl@kv@attribute}&% + {\global\bbl@carg\newattribute{\bbl@kv@attribute}}&% + {}&% + \global\bbl@carg\setattribute{\bbl@kv@attribute}\@ne + \fi + \else \edef\bbl@kv@attribute{\expandafter\bbl@stripslash\bbl@kv@attribute}&% \fi \directlua{ @@ -14662,6 +14753,49 @@ end }&% \endgroup} \endgroup +\let\bbl@transfont@list\@empty +\def\bbl@settransfont{% + \global\let\bbl@settransfont\relax % Execute only once + \gdef\bbl@transfont{% + \def\bbl@elt####1####2####3{% + \bbl@ifblank{####3}% + {\count@\tw@}% Do nothing if no fonts + {\count@\z@ + \bbl@vforeach{####3}{% + \def\bbl@tempd{########1}% + \edef\bbl@tempe{\bbl@transfam/\f@series/\f@shape}% + \ifx\bbl@tempd\bbl@tempe + \count@\@ne + \else\ifx\bbl@tempd\bbl@transfam + \count@\@ne + \fi\fi}% + \ifcase\count@ + \bbl@csarg\unsetattribute{ATR@####2@####1@####3}% + \or + \bbl@csarg\setattribute{ATR@####2@####1@####3}\@ne + \fi}}% + \bbl@transfont@list}% + \AddToHook{selectfont}{\bbl@transfont}% Hooks are global. + \gdef\bbl@transfam{-unknown-}% + \bbl@foreach\bbl@font@fams{% + \AddToHook{##1family}{\def\bbl@transfam{##1}}% + \bbl@ifsamestring{\@nameuse{##1default}}\familydefault + {\xdef\bbl@transfam{##1}}% + {}}} +\DeclareRobustCommand\enablelocaletransform[1]{% + \bbl@ifunset{bbl@ATR@#1@\languagename @}% + {\bbl@error + {'#1' for '\languagename' cannot be enabled.\\% + Maybe there is a typo or it’s a font-dependent transform}% + {See the manual for further details.}}% + {\bbl@csarg\setattribute{ATR@#1@\languagename @}\@ne}} +\DeclareRobustCommand\disablelocaletransform[1]{% + \bbl@ifunset{bbl@ATR@#1@\languagename @}% + {\bbl@error + {'#1' for '\languagename' cannot be disabled.\\% + Maybe there is a typo or it’s a font-dependent transform}% + {See the manual for further details.}}% + {\bbl@csarg\unsetattribute{ATR@#1@\languagename @}}} \def\bbl@activateposthyphen{% \let\bbl@activateposthyphen\relax \directlua{ @@ -14771,6 +14905,7 @@ end \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{% @@ -14782,23 +14917,36 @@ end % \ifnum\bbl@bidimode>\z@ \def\bbl@insidemath{0}% - \def\bbl@everymath{\def\bbl@insidemath{1}} - \def\bbl@everydisplay{\def\bbl@insidemath{2}} + \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}} \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 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')) + 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 end end end @@ -14874,6 +15022,7 @@ end \ifx\maketag@@@\@undefined % Normal equation, eqnarray \AddToHook{env/equation/begin}{% \ifnum\bbl@thetextdir>\z@ + \def\bbl@mathboxdir{\def\bbl@insidemath{1}}% \let\@eqnnum\bbl@eqnum \edef\bbl@eqnodir{\noexpand\bbl@textdir{\the\bbl@thetextdir}}% \chardef\bbl@thetextdir\z@ @@ -14889,6 +15038,8 @@ 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@ \bbl@add\normalfont{\bbl@eqnodir}% @@ -14926,6 +15077,7 @@ end \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}% @@ -14933,6 +15085,7 @@ end \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@ @@ -14958,6 +15111,7 @@ end \\\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 @@ -22317,6 +22471,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/macros/latex/required/babel/base/babel.ins b/macros/latex/required/babel/base/babel.ins index fde40b7087..fbea84e25a 100644 --- a/macros/latex/required/babel/base/babel.ins +++ b/macros/latex/required/babel/base/babel.ins @@ -3,7 +3,7 @@ %% driver files from the doc files in this package when run through %% LaTeX or TeX. %% -%% Copyright 2012-2022 Javier Bezos and Johannes L. Braams. +%% Copyright 2012-2023 Javier Bezos and Johannes L. Braams. %% Copyright 1989-2008 Johannes L. Braams and any individual authors %% listed elsewhere in this file. All rights reserved. %% @@ -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/12/26} +\def\filedate{2022/01/23} \def\batchfile{babel.ins} \input docstrip.tex diff --git a/macros/latex/required/babel/base/babel.pdf b/macros/latex/required/babel/base/babel.pdf index 7f740c3fde..ce98f9678f 100644 Binary files a/macros/latex/required/babel/base/babel.pdf and b/macros/latex/required/babel/base/babel.pdf differ diff --git a/macros/latex/required/babel/base/bbcompat.dtx b/macros/latex/required/babel/base/bbcompat.dtx index 1fc18c4393..eb860ed322 100644 --- a/macros/latex/required/babel/base/bbcompat.dtx +++ b/macros/latex/required/babel/base/bbcompat.dtx @@ -30,7 +30,7 @@ % % \iffalse %<*dtx> -\ProvidesFile{bbcompat.dtx}[2022/12/26 v3.84] +\ProvidesFile{bbcompat.dtx}[2022/01/23 v3.85] % % %% File 'bbcompat.dtx' -- cgit v1.2.3