From 37729ddea335ca0dfe40ada381d05bde37c5ea61 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Tue, 30 Nov 2021 03:00:43 +0000 Subject: CTAN sync 202111300300 --- macros/latex/required/babel/base/README.md | 11 +- macros/latex/required/babel/base/babel.dtx | 253 +++++++++++++++++--------- macros/latex/required/babel/base/babel.ins | 2 +- macros/latex/required/babel/base/babel.pdf | Bin 854250 -> 858700 bytes macros/latex/required/babel/base/bbcompat.dtx | 2 +- 5 files changed, 182 insertions(+), 86 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 078385c04e..bfb72cd7cf 100644 --- a/macros/latex/required/babel/base/README.md +++ b/macros/latex/required/babel/base/README.md @@ -1,4 +1,4 @@ -## Babel 3.66 +## Babel 3.67 This package manages culturally-determined typographical (and other) rules, and hyphenation patterns for a wide range of languages. Many @@ -8,9 +8,9 @@ is a set of ini files for about 250 languages. The latest stable version is available on . -Changes in version 3.66 are described in: +Changes in version 3.67 are described in: -https://latex3.github.io/babel/news/whats-new-in-babel-3.66.html +https://latex3.github.io/babel/news/whats-new-in-babel-3.67.html Apart from the manual, you can find information on some aspects of babel at: @@ -46,6 +46,11 @@ respective authors. ### Summary of Latest changes ``` +3.67 2021-11-29 + * \IfBabelSelectorTF executes code conditionally based on the + selector type (select, foreign, etc.). + * Transforms can be turned on and off based on Lua attributes. + 3.66 2021-11-08 * Transforms for Greek: - transliteration.omega diff --git a/macros/latex/required/babel/base/babel.dtx b/macros/latex/required/babel/base/babel.dtx index a8d8834ab3..666c1b1eef 100644 --- a/macros/latex/required/babel/base/babel.dtx +++ b/macros/latex/required/babel/base/babel.dtx @@ -32,7 +32,7 @@ % % \iffalse %<*filedriver> -\ProvidesFile{babel.dtx}[2021/11/08 v3.66 The Babel package] +\ProvidesFile{babel.dtx}[2021/11/29 v3.67 The Babel package] \documentclass{ltxdoc} \GetFileInfo{babel.dtx} \usepackage{fontspec} @@ -687,6 +687,12 @@ This command can be used as environment, too. any language, it will get expanded as expected. \end{note} +\begin{note} + Bear in mind |\selectlanguage| can be automatically executed, in some + cases, in the auxiliary files, at heads and foots, and after the + environment |otherlanguage*|. +\end{note} + \begin{warning} If used inside braces there might be some non-local changes, as this would be roughly equivalent to: @@ -3101,6 +3107,16 @@ illustrates: \usepackage[magyar]{babel} \babelprovide[_transforms = digraphs.hyphen_]{magyar} \end{verbatim} +\New{3.67} Transforms predefined in the |ini| locale files can be made +attribute-dependent, too. When an attribute between parenthesis is +inserted subsequent transforms will be assigned to it (up to the list +end or another attribute). For example, +and provided an attribute called |\withsigmafinal| has been declared: +\begin{verbatim} +transforms = transliteration.omega (\withsigmafinal) sigma.final +\end{verbatim} +This applies |transliteration.omega| always, but |sigma.final| only when +|\withsigmafinal| is set. Here are the transforms currently predefined. (More to follow in future releases.) @@ -3164,19 +3180,29 @@ four characters: \textit{!?:;}\,.} danda or double danda if there is a space. For Assamese, Bengali, Gujarati, Hindi, Kannada, Malayalam, Marathi, Oriya, Tamil, Telugu.} -\trans{Arabic, Persian}{kashida.plain}{Experimental. A very simple and -basic transform for ‘plain’ Arabic fonts, which attempts to distribute -the tatwil as evenly as possible (starting at the end of the line). See -the news for version 3.59.} +\trans{Latin}{digraphs.ligatures}{Replaces the groups \textit{ae}, +\textit{AE}, \textit{oe}, \textit{OE} with \textit{æ}, \textit{Æ}, +\textit{œ}, \textit{Œ}.} + +\trans{Latin}{letters.noj}{Replaces \textit{j}, \textit{J} with +\textit{i}, \textit{I}.} + +\trans{Latin}{letters.uv}{Replaces \textit{v}, \textit{U} with +\textit{u}, \textit{V}.} \trans{Serbian}{transliteration.gajica}{(Note |serbian| with |ini| files refers to the Cyrillic script, which is here the target.) The standard system devised by Ljudevit Gaj.} +\trans{Arabic, Persian}{kashida.plain}{Experimental. A very simple and +basic transform for ‘plain’ Arabic fonts, which attempts to distribute +the tatwil as evenly as possible (starting at the end of the line). See +the news for version 3.59.} + \vspace{2mm}\hrule\nobreak \endgroup -\Describe{\babelposthyphenation}{\marg{hyphenrules-name}% +\Describe{\babelposthyphenation}{\oarg{options}\marg{hyphenrules-name}% \marg{lua-pattern}\marg{replacement}} \New{3.37-3.39} \textit{With \luatex{}} it is possible to define @@ -3202,6 +3228,18 @@ to \textit{ύ}, so that the diaeresis is removed. This feature is activated with the first |\babelposthyphenation| or |\babelprehyphenation|. +\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 +transforms can be set or unset even in the middle of paragraphs, and +applied to single words. To define, set and unset the attribute, the +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 } +\end{verbatim} + See the \href{https://latex3.github.io/babel/guides/% non-standard-hyphenation-with-luatex.html}{\babel\ site} for a more @@ -3215,7 +3253,7 @@ applied, so you must take discretionaries into account). You are limited to substitutions as done by \textsf{lua}, although a future implementation may alternatively accept \textsf{lpeg}. -\Describe{\babelprehyphenation}{\marg{locale-name}% +\Describe{\babelprehyphenation}{\oarg{options}\marg{locale-name}% \marg{lua-pattern}\marg{replacement}} \New{3.44-3-52} It is similar to the latter, but (as its name implies) @@ -3226,6 +3264,8 @@ search patterns |=| has no special meaning, while \verb+|+ stands for an ordinary space; (3) in the replacement, discretionaries are not accepted. +See the description above for the optional argument. + This feature is activated with the first |\babelposthyphenation| or |\babelprehyphenation|. @@ -4867,6 +4907,21 @@ This macro is not intended to fix wrong mappings done by Unicode (which are the default in both \xetex{} and \luatex{}) -- if an assignment is wrong, fix it directly. +\subsection{Executing code based on the selector} + +\Describe{\IfBabelSelectorTF}{\marg{selectors}\marg{true}\marg{false}} + +\New{3.67} Sometimes a different setup is desired depending on the +selector used. Values allowed in \m{selectors} are |select|, |other|, +|foreign|, |other*| (and also |foreign*| for the tentative starred +version), and it can consist of a comma-separated list. For example: +\begin{verbatim} +\IfBabelSelectorTF{other, other*}{A}{B} +\end{verbatim} +is true with these two environment selectors. + +Its natural place of use is in hooks or in |\extras|\m{language}. + \section{Changes} \subsection{Changes in \babel\ version 3.9} @@ -5063,8 +5118,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 @@ -6312,7 +6367,10 @@ help from Bernd Raichle, for which I am grateful. \newif\ifbbl@bcpallowed \bbl@bcpallowedfalse \def\select@language#1{% from set@, babel@aux + \ifx\bbl@selectorname\@empty + \def\bbl@selectorname{select}% % set hymap + \fi \ifnum\bbl@hymapsel=\@cclv\chardef\bbl@hymapsel4\relax\fi % set name \edef\languagename{#1}% @@ -6453,7 +6511,8 @@ help from Bernd Raichle, for which I am grateful. \else \expandafter\expandafter\expandafter\set@hyphenmins \csname #1hyphenmins\endcsname\relax - \fi} + \fi + \let\bbl@selectorname\@empty} % \end{macrocode} % % \begin{environment}{otherlanguage} @@ -6468,6 +6527,7 @@ help from Bernd Raichle, for which I am grateful. % % \begin{macrocode} \long\def\otherlanguage#1{% + \def\bbl@selectorname{other}% \ifnum\bbl@hymapsel=\@cclv\let\bbl@hymapsel\thr@@\fi \csname selectlanguage \endcsname{#1}% \ignorespaces} @@ -6493,6 +6553,7 @@ help from Bernd Raichle, for which I am grateful. \expandafter\def\csname otherlanguage*\endcsname{% \@ifnextchar[\bbl@otherlanguage@s{\bbl@otherlanguage@s[]}} \def\bbl@otherlanguage@s[#1]#2{% + \def\bbl@selectorname{other*}% \ifnum\bbl@hymapsel=\@cclv\chardef\bbl@hymapsel4\relax\fi \def\bbl@select@opts{#1}% \foreign@language{#2}} @@ -6556,6 +6617,7 @@ help from Bernd Raichle, for which I am grateful. \@ifstar\bbl@foreign@s\bbl@foreign@x} \providecommand\bbl@foreign@x[3][]{% \begingroup + \def\bbl@selectorname{foreign}% \def\bbl@select@opts{#1}% \let\BabelText\@firstofone \bbl@beforeforeign @@ -6566,6 +6628,7 @@ help from Bernd Raichle, for which I am grateful. \def\bbl@foreign@s#1#2{% TODO - \shapemode, \@setpar, ?\@@par \begingroup {\par}% + \def\bbl@selectorname{foreign*}% \let\bbl@select@opts\@empty \let\BabelText\@firstofone \foreign@language{#1}% @@ -6612,7 +6675,20 @@ help from Bernd Raichle, for which I am grateful. \expandafter\bbl@switch\expandafter{\languagename}}} % \end{macrocode} % -% \end{macro} +% \end{macro} +% +% The following macro executes conditionally some code based on the +% selector being used. +% +% \begin{macrocode} +\def\IfBabelSelectorTF#1{% + \bbl@xin@{,\bbl@selectorname,}{,\zap@space#1 \@empty,}% + \ifin@ + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi} +% \end{macrocode} % % \begin{macro}{\bbl@patterns} % @@ -6781,7 +6857,6 @@ help from Bernd Raichle, for which I am grateful. \let\uselocale\setlocale \let\locale\setlocale \let\selectlocale\setlocale -\let\localename\setlocale \let\textlocale\setlocale \let\textlanguage\setlocale \let\languagetext\setlocale @@ -10680,14 +10755,15 @@ help from Bernd Raichle, for which I am grateful. \bbl@transforms\babelprehyphenation} \@namedef{bbl@inikv@transforms.posthyphenation}{% \bbl@transforms\babelposthyphenation} -\def\bbl@transforms@aux#1#2#3,#4\relax{#1{#2}{#3}{#4}} +\def\bbl@transforms@aux#1#2#3#4,#5\relax{% + #1[#2]{#3}{#4}{#5}} \begingroup % A hack. TODO. Don't require an specific order \catcode`\%=12 \catcode`\&=14 \gdef\bbl@transforms#1#2#3{&% \ifx\bbl@KVP@transforms\@nil\else \directlua{ - str = [==[#2]==] + local str = [==[#2]==] str = str:gsub('%.%d+%.%d+$', '') tex.print([[\def\string\babeltempa{]] .. str .. [[}]]) }&% @@ -10695,10 +10771,23 @@ help from Bernd Raichle, for which I am grateful. \ifin@ \in@{.0$}{#2$}&% \ifin@ - \g@addto@macro\bbl@release@transforms{&% - \relax\bbl@transforms@aux#1{\languagename}{#3}}&% + \directlua{ + local str = string.match([[\bbl@KVP@transforms]], + '%(([^%(]-)%)[^%)]-\babeltempa') + if str == nil then + tex.print([[\def\string\babeltempb{}]]) + else + tex.print([[\def\string\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@}}}&% \else - \g@addto@macro\bbl@release@transforms{, {#3}}&% + \g@addto@macro\bbl@release@transforms{, {#3}}&% \fi \fi \fi} @@ -14212,13 +14301,21 @@ end \catcode`\~=12 \catcode`\%=12 \catcode`\&=14 -\gdef\babelposthyphenation#1#2#3{&% - \bbl@activateposthyphen +\gdef\babelprehyphenation{&% + \@ifnextchar[{\bbl@settransform{0}}{\bbl@settransform{0}[]}} +\gdef\babelposthyphenation{&% + \@ifnextchar[{\bbl@settransform{1}}{\bbl@settransform{1}[]}} +\gdef\bbl@settransform#1[#2]#3#4#5{&% + \ifcase#1 + \bbl@activateprehyphen + \else + \bbl@activateposthyphen + \fi \begingroup \def\babeltempa{\bbl@add@list\babeltempb}&% \let\babeltempb\@empty - \def\bbl@tempa{#3}&% TODO. Ugly trick to preserve {}: - \bbl@replace\bbl@tempa{,}{ ,}&% + \def\bbl@tempa{#5}&% + \bbl@replace\bbl@tempa{,}{ ,}&% TODO. Ugly trick to preserve {} \expandafter\bbl@foreach\expandafter{\bbl@tempa}{&% \bbl@ifsamestring{##1}{remove}&% {\bbl@add@list\babeltempb{nil}}&% @@ -14226,82 +14323,68 @@ end local rep = [=[##1]=] rep = rep:gsub('^%s*(remove)%s*$', 'remove = true') rep = rep:gsub('^%s*(insert)%s*,', 'insert = true, ') - 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) - rep = rep:gsub('(string)%s*=%s*([^%s,]*)', Babel.capture_func) + rep = rep:gsub('(string)%s*=%s*([^%s,]*)', Babel.capture_func) + if #1 == 0 then + rep = rep:gsub('(space)%s*=%s*([%d%.]+)%s+([%d%.]+)%s+([%d%.]+)', + 'space = {' .. '%2, %3, %4' .. '}') + rep = rep:gsub('(spacefactor)%s*=%s*([%d%.]+)%s+([%d%.]+)%s+([%d%.]+)', + 'spacefactor = {' .. '%2, %3, %4' .. '}') + rep = rep:gsub('(kashida)%s*=%s*([^%s,]*)', Babel.capture_kashida) + else + 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) + end tex.print([[\string\babeltempa{{]] .. rep .. [[}}]]) }}}&% + \let\bbl@kv@attribute\relax + \let\bbl@kv@label\relax + \bbl@forkv{#2}{\bbl@csarg\edef{kv@##1}{##2}}&% + \ifx\bbl@kv@attribute\relax\else + \edef\bbl@kv@attribute{\expandafter\bbl@stripslash\bbl@kv@attribute}&% + \fi \directlua{ - local lbkr = Babel.linebreaking.replacements[1] + local lbkr = Babel.linebreaking.replacements[#1] local u = unicode.utf8 - local id = \the\csname l@#1\endcsname + local id, attr, label + if #1 == 0 then + id = \the\csname bbl@id@@#3\endcsname\space + else + id = \the\csname l@#3\endcsname\space + end + \ifx\bbl@kv@attribute\relax + attr = -1 + \else + attr = luatexbase.registernumber'\bbl@kv@attribute' + \fi + \ifx\bbl@kv@label\relax\else &% Same refs: + label = [==[\bbl@kv@label]==] + \fi &% Convert pattern: - local patt = string.gsub([==[#2]==], '%s', '') + local patt = string.gsub([==[#4]==], '%s', '') + if #1 == 0 then + patt = string.gsub(patt, '|', ' ') + end if not u.find(patt, '()', nil, true) then patt = '()' .. patt .. '()' end - patt = string.gsub(patt, '%(%)%^', '^()') - patt = string.gsub(patt, '%$%(%)', '()$') - patt = u.gsub(patt, '{(.)}', + if #1 == 1 then + patt = string.gsub(patt, '%(%)%^', '^()') + patt = string.gsub(patt, '%$%(%)', '()$') + end + patt = u.gsub(patt, '{(.)}', function (n) return '%' .. (tonumber(n) and (tonumber(n)+1) or n) end) patt = u.gsub(patt, '{(%x%x%x%x+)}', function (n) return u.gsub(u.char(tonumber(n, 16)), '(%p)', '%%%1') - end) + end) lbkr[id] = lbkr[id] or {} - table.insert(lbkr[id], { pattern = patt, replace = { \babeltempb } }) + table.insert(lbkr[id], + { label=label, attr=attr, pattern=patt, replace={\babeltempb} }) }&% \endgroup} -% TODO. Copypaste pattern. -\gdef\babelprehyphenation#1#2#3{&% - \bbl@activateprehyphen - \begingroup - \def\babeltempa{\bbl@add@list\babeltempb}&% - \let\babeltempb\@empty - \def\bbl@tempa{#3}&% TODO. Ugly trick to preserve {}: - \bbl@replace\bbl@tempa{,}{ ,}&% - \expandafter\bbl@foreach\expandafter{\bbl@tempa}{&% - \bbl@ifsamestring{##1}{remove}&% - {\bbl@add@list\babeltempb{nil}}&% - {\directlua{ - local rep = [=[##1]=] - rep = rep:gsub('^%s*(remove)%s*$', 'remove = true') - rep = rep:gsub('^%s*(insert)%s*,', 'insert = true, ') - rep = rep:gsub('(string)%s*=%s*([^%s,]*)', Babel.capture_func) - rep = rep:gsub('(space)%s*=%s*([%d%.]+)%s+([%d%.]+)%s+([%d%.]+)', - 'space = {' .. '%2, %3, %4' .. '}') - rep = rep:gsub('(spacefactor)%s*=%s*([%d%.]+)%s+([%d%.]+)%s+([%d%.]+)', - 'spacefactor = {' .. '%2, %3, %4' .. '}') - rep = rep:gsub('(kashida)%s*=%s*([^%s,]*)', Babel.capture_kashida) - tex.print([[\string\babeltempa{{]] .. rep .. [[}}]]) - }}}&% - \directlua{ - local lbkr = Babel.linebreaking.replacements[0] - local u = unicode.utf8 - local id = \the\csname bbl@id@@#1\endcsname - &% Convert pattern: - local patt = string.gsub([==[#2]==], '%s', '') - local patt = string.gsub(patt, '|', ' ') - if not u.find(patt, '()', nil, true) then - patt = '()' .. patt .. '()' - end - &% patt = string.gsub(patt, '%(%)%^', '^()') - &% patt = string.gsub(patt, '([^%%])%$%(%)', '%1()$') - patt = u.gsub(patt, '{(.)}', - function (n) - return '%' .. (tonumber(n) and (tonumber(n)+1) or n) - end) - patt = u.gsub(patt, '{(%x%x%x%x+)}', - function (n) - return u.gsub(u.char(tonumber(n, 16)), '(%p)', '%%%1') - end) - lbkr[id] = lbkr[id] or {} - table.insert(lbkr[id], { pattern = patt, replace = { \babeltempb } }) - }&% - \endgroup} \endgroup \def\bbl@activateposthyphen{% \let\bbl@activateposthyphen\relax @@ -14867,6 +14950,7 @@ function Babel.hyphenate_replace(head, mode) for k=1, #lbkr[lang] do local p = lbkr[lang][k].pattern local r = lbkr[lang][k].replace + local attr = lbkr[lang][k].attr or -1 if Babel.debug then print('*****', p, mode) @@ -14911,8 +14995,15 @@ function Babel.hyphenate_replace(head, mode) local sc = first-1 -- Used below, too local data_nodes = {} + local enabled = true for q = 1, last-first+1 do data_nodes[q] = w_nodes[sc+q] + if enabled + and attr > -1 + and not node.has_attribute(data_nodes[q], attr) + then + enabled = false + end end -- This loop traverses the matched substring and takes the @@ -14956,7 +15047,7 @@ function Babel.hyphenate_replace(head, mode) step = crep.step or 0 end - if crep and next(crep) == nil then -- = {} + if (not enabled) or (crep and next(crep) == nil) then -- = {} last_match = save_last -- Optimization goto next diff --git a/macros/latex/required/babel/base/babel.ins b/macros/latex/required/babel/base/babel.ins index 387ab64241..1be32b20ba 100644 --- a/macros/latex/required/babel/base/babel.ins +++ b/macros/latex/required/babel/base/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{2021/11/08} +\def\filedate{2021/11/29} \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 9d0a7963cf..bf2f6910ca 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 5936dfafa1..0b0d1c2af7 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}[2021/11/08 v3.66] +\ProvidesFile{bbcompat.dtx}[2021/11/29 v3.67] % % %% File 'bbcompat.dtx' -- cgit v1.2.3