[latex3-commits] [git/LaTeX3-latex3-babel] main: Option 'attribute' in transforms. (2f32350)

Javier email at dante.de
Sat Nov 13 09:24:02 CET 2021


Repository : https://github.com/latex3/babel
On branch  : main
Link       : https://github.com/latex3/babel/commit/2f32350310245fc4c99c947f04da8f03d6b1c4d7

>---------------------------------------------------------------

commit 2f32350310245fc4c99c947f04da8f03d6b1c4d7
Author: Javier <email at localhost>
Date:   Sat Nov 13 09:24:02 2021 +0100

    Option 'attribute' in transforms.


>---------------------------------------------------------------

2f32350310245fc4c99c947f04da8f03d6b1c4d7
 README.md    |   6 ++++--
 babel.dtx    |  62 ++++++++++++++++++++++++++++++++++++++++++++---------------
 babel.ins    |   2 +-
 babel.pdf    | Bin 855301 -> 855836 bytes
 bbcompat.dtx |   2 +-
 5 files changed, 52 insertions(+), 20 deletions(-)

diff --git a/README.md b/README.md
index 8570d97..c91a1b6 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-## Babel 3.66.2551
+## Babel 3.66.2555
 
 This package manages culturally-determined typographical (and other)
 rules, and hyphenation patterns for a wide range of languages. Many
@@ -47,7 +47,9 @@ respective authors.
 ### Summary of Latest changes
 ```
 3.67   2021-11-?? (dev)
-       * \IfBabelSelectorTF
+       * \IfBabelSelectorTF executes code conditionally based on the
+         selector type (select, foreign, etc.).
+       * Transforms can be turned on and off based on node attributes.
 
 3.66   2021-11-08
        * Transforms for Greek:
diff --git a/babel.dtx b/babel.dtx
index f10e2a5..3350e9a 100644
--- a/babel.dtx
+++ b/babel.dtx
@@ -32,7 +32,7 @@
 %
 % \iffalse
 %<*filedriver>
-\ProvidesFile{babel.dtx}[2021/11/09 v3.66.2551 The Babel package]
+\ProvidesFile{babel.dtx}[2021/11/13 v3.66.2555 The Babel package]
 \documentclass{ltxdoc}
 \GetFileInfo{babel.dtx}
 \usepackage{fontspec}
@@ -5063,8 +5063,8 @@ help from Bernd Raichle, for which I am grateful.
 % \section{Tools}
 %
 %    \begin{macrocode}
-%<<version=3.66.2551>>
-%<<date=2021/11/09>>
+%<<version=3.66.2555>>
+%<<date=2021/11/13>>
 %    \end{macrocode}
 %
 % \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -14235,13 +14235,15 @@ end
 \catcode`\~=12
 \catcode`\%=12
 \catcode`\&=14
-\gdef\babelposthyphenation#1#2#3{&%
+\gdef\babelposthyphenation{&%
+  \@ifnextchar[\bbl at posthyphenation{\bbl at posthyphenation[]}}
+\gdef\bbl at posthyphenation[#1]#2#3#4{&%
   \bbl at activateposthyphen
   \begingroup
     \def\babeltempa{\bbl at add@list\babeltempb}&%
     \let\babeltempb\@empty
-    \def\bbl at tempa{#3}&% TODO. Ugly trick to preserve {}:
-    \bbl at replace\bbl at tempa{,}{ ,}&%
+    \def\bbl at tempa{#4}&%
+    \bbl at replace\bbl at tempa{,}{ ,}&% TODO. Ugly trick to preserve {}
     \expandafter\bbl at foreach\expandafter{\bbl at tempa}{&%
       \bbl at ifsamestring{##1}{remove}&%
         {\bbl at add@list\babeltempb{nil}}&%
@@ -14255,12 +14257,22 @@ end
            rep = rep:gsub('(string)%s*=%s*([^%s,]*)', Babel.capture_func)          
            tex.print([[\string\babeltempa{{]] .. rep .. [[}}]])
          }}}&%
+    \let\bbl at kv@attr\relax
+    \bbl at forkv{#1}&% TODO: For the moment, assume attribute=
+       {\edef\bbl at kv@attr{##2}&%
+        \edef\bbl at kv@attr{\expandafter\bbl at stripslash\bbl at kv@attr}}&%
     \directlua{
       local lbkr = Babel.linebreaking.replacements[1]
       local u = unicode.utf8
-      local id = \the\csname l@#1\endcsname
+      local id = \the\csname l@#2\endcsname
+      lbkr[id] = lbkr[id] or {}
+      \ifx\bbl at kv@attr\relax &% A bit hackish
+        lbkr[id].attr = -1
+      \else
+        lbkr[id].attr = luatexbase.registernumber'\bbl at kv@attr'
+      \fi
       &% Convert pattern:
-      local patt = string.gsub([==[#2]==], '%s', '')
+      local patt = string.gsub([==[#3]==], '%s', '')
       if not u.find(patt, '()', nil, true) then
         patt = '()' .. patt .. '()'
       end
@@ -14274,18 +14286,19 @@ end
              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}
 % TODO. Copypaste pattern. 
-\gdef\babelprehyphenation#1#2#3{&%
+\gdef\babelprehyphenation{&%
+  \@ifnextchar[\bbl at prehyphenation{\bbl at prehyphenation[]}}
+\gdef\bbl at prehyphenation[#1]#2#3#4{&%
   \bbl at activateprehyphen
   \begingroup
     \def\babeltempa{\bbl at add@list\babeltempb}&%
     \let\babeltempb\@empty
-    \def\bbl at tempa{#3}&% TODO. Ugly trick to preserve {}:
-    \bbl at replace\bbl at tempa{,}{ ,}&%
+    \def\bbl at tempa{#4}&%
+    \bbl at replace\bbl at tempa{,}{ ,}&% TODO. Ugly trick to preserve {}
     \expandafter\bbl at foreach\expandafter{\bbl at tempa}{&%
       \bbl at ifsamestring{##1}{remove}&%
         {\bbl at add@list\babeltempb{nil}}&%
@@ -14301,12 +14314,22 @@ end
            rep = rep:gsub('(kashida)%s*=%s*([^%s,]*)', Babel.capture_kashida)
            tex.print([[\string\babeltempa{{]] .. rep .. [[}}]])
          }}}&%
+    \let\bbl at kv@attr\relax
+    \bbl at forkv{#1}&% TODO: For the moment, assume attribute=
+       {\edef\bbl at kv@attr{##2}&%
+        \edef\bbl at kv@attr{\expandafter\bbl at stripslash\bbl at kv@attr}}&%
     \directlua{
       local lbkr = Babel.linebreaking.replacements[0]
       local u = unicode.utf8
-      local id = \the\csname bbl at id@@#1\endcsname
+      local id = \the\csname bbl at id@@#2\endcsname
+      lbkr[id] = lbkr[id] or {}
+      \ifx\bbl at kv@attr\relax &% A bit hackish
+        lbkr[id].attr = -1
+      \else
+        lbkr[id].attr = luatexbase.registernumber'\bbl at kv@attr'
+      \fi
       &% Convert pattern:
-      local patt = string.gsub([==[#2]==], '%s', '')
+      local patt = string.gsub([==[#3]==], '%s', '')
       local patt = string.gsub(patt, '|', ' ')
       if not u.find(patt, '()', nil, true) then
         patt = '()' .. patt .. '()'
@@ -14321,7 +14344,6 @@ end
              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}
@@ -14890,6 +14912,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].attr or -1
 
       if Babel.debug then
         print('*****', p, mode)
@@ -14934,8 +14957,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
@@ -14979,7 +15009,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/babel.ins b/babel.ins
index 28a91e2..96793ec 100644
--- a/babel.ins
+++ b/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/09}
+\def\filedate{2021/11/13}
 \def\batchfile{babel.ins}
 \input docstrip.tex
 
diff --git a/babel.pdf b/babel.pdf
index b2a6f27..e5ee43b 100644
Binary files a/babel.pdf and b/babel.pdf differ
diff --git a/bbcompat.dtx b/bbcompat.dtx
index 47b44ab..d5dadca 100644
--- a/bbcompat.dtx
+++ b/bbcompat.dtx
@@ -30,7 +30,7 @@
 %
 % \iffalse
 %<*dtx>
-\ProvidesFile{bbcompat.dtx}[2021/11/09 v3.66.2551]
+\ProvidesFile{bbcompat.dtx}[2021/11/13 v3.66.2555]
 %</dtx>
 %
 %% File 'bbcompat.dtx'





More information about the latex3-commits mailing list.