[latex3-commits] [git/LaTeX3-latex3-babel] main: Transforms: 'label', merged code for \babelXXXhyphentation. (a34a31f)

Javier email at dante.de
Mon Nov 15 17:56:13 CET 2021


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

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

commit a34a31fd25896fec7e5807f1e19322f942d29e1c
Author: Javier <email at localhost>
Date:   Mon Nov 15 17:56:13 2021 +0100

    Transforms: 'label', merged code for \babelXXXhyphentation.


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

a34a31fd25896fec7e5807f1e19322f942d29e1c
 README.md    |   4 +-
 babel.dtx    | 142 ++++++++++++++++++++++++-----------------------------------
 babel.ins    |   2 +-
 babel.pdf    | Bin 855836 -> 854501 bytes
 bbcompat.dtx |   2 +-
 5 files changed, 62 insertions(+), 88 deletions(-)

diff --git a/README.md b/README.md
index c91a1b6..725b16f 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,6 @@
-## Babel 3.66.2555
+## Babel 3.66.2557
+
+*(Development.)*
 
 This package manages culturally-determined typographical (and other)
 rules, and hyphenation patterns for a wide range of languages. Many
diff --git a/babel.dtx b/babel.dtx
index 3350e9a..0ab1c17 100644
--- a/babel.dtx
+++ b/babel.dtx
@@ -32,7 +32,7 @@
 %
 % \iffalse
 %<*filedriver>
-\ProvidesFile{babel.dtx}[2021/11/13 v3.66.2555 The Babel package]
+\ProvidesFile{babel.dtx}[2021/11/15 v3.66.2557 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.2555>>
-%<<date=2021/11/13>>
+%<<version=3.66.2557>>
+%<<date=2021/11/15>>
 %    \end{macrocode}
 %
 % \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -14235,14 +14235,20 @@ end
 \catcode`\~=12
 \catcode`\%=12
 \catcode`\&=14
+\gdef\babelprehyphenation{&%
+  \@ifnextchar[{\bbl at settransform{0}}{\bbl at settransform{0}[]}}
 \gdef\babelposthyphenation{&%
-  \@ifnextchar[\bbl at posthyphenation{\bbl at posthyphenation[]}}
-\gdef\bbl at posthyphenation[#1]#2#3#4{&%
-  \bbl at activateposthyphen
+  \@ifnextchar[{\bbl at settransform{1}}{\bbl at settransform{1}[]}}
+\gdef\bbl at settransform#1[#2]#3#4#5{&%
+  \ifcase#1
+    \bbl at activateprehyphen
+  \else
+    \bbl at activateposthyphen
+  \fi
   \begingroup
     \def\babeltempa{\bbl at add@list\babeltempb}&%
     \let\babeltempb\@empty
-    \def\bbl at tempa{#4}&%
+    \def\bbl at tempa{#5}&%
     \bbl at replace\bbl at tempa{,}{ ,}&% TODO. Ugly trick to preserve {}
     \expandafter\bbl at foreach\expandafter{\bbl at tempa}{&%
       \bbl at ifsamestring{##1}{remove}&%
@@ -14251,91 +14257,55 @@ 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)
+           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 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}}&%
+    \let\bbl at kv@attribute\relax
+    \let\bbl at kv@label\relax
+    \bbl at forkv{#2}{\bbl at csarg\edef{kv@##1}{##2}}&%
+    \ifx\bbl at kv@attribute\relax\else
+      \edef\bbl at kv@attribute{\expandafter\bbl at stripslash\bbl at 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@#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([==[#3]==], '%s', '')
-      if not u.find(patt, '()', nil, true) then
-        patt = '()' .. patt .. '()'
+      local id, attr, label
+      if #1 == 0 then
+        id = \the\csname bbl at id@@#3\endcsname\space
+      else
+        id = \the\csname l@#3\endcsname\space
       end
-      patt = string.gsub(patt, '%(%)%^', '^()')
-      patt = string.gsub(patt, '%$%(%)', '()$')
-      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)
-      table.insert(lbkr[id], { pattern = patt, replace = { \babeltempb } })
-    }&%
-  \endgroup}
-% TODO. Copypaste pattern. 
-\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{#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}}&%
-        {\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 .. [[}}]])
-         }}}&%
-    \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@@#2\endcsname
-      lbkr[id] = lbkr[id] or {}
-      \ifx\bbl at kv@attr\relax &% A bit hackish
-        lbkr[id].attr = -1
+      \ifx\bbl at kv@attribute\relax
+        attr = -1
       \else
-        lbkr[id].attr = luatexbase.registernumber'\bbl at kv@attr'
+        attr = luatexbase.registernumber'\bbl at kv@attribute'
+      \fi
+      \ifx\bbl at kv@label\relax\else  &% Same refs:
+        label = [==[\bbl at kv@label]==]
       \fi
       &% Convert pattern:
-      local patt = string.gsub([==[#3]==], '%s', '')
-      local patt = string.gsub(patt, '|', ' ')
+      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, '([^%%])%$%(%)', '%1()$')
+      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)
@@ -14344,7 +14314,9 @@ end
              function (n)
                return u.gsub(u.char(tonumber(n, 16)), '(%p)', '%%%1')
              end)            
-      table.insert(lbkr[id], { pattern = patt, replace = { \babeltempb } })
+      lbkr[id] = lbkr[id] or {}
+      table.insert(lbkr[id],
+        { label=label, attr=attr, pattern=patt, replace={\babeltempb} })
     }&%
   \endgroup}
 \endgroup
@@ -14912,7 +14884,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
+      local attr = lbkr[lang][k].attr or -1
 
       if Babel.debug then
         print('*****', p, mode)
@@ -14961,9 +14933,9 @@ function Babel.hyphenate_replace(head, mode)
         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
+              and attr > -1
+              and not node.has_attribute(data_nodes[q], attr)
+            then
             enabled = false
           end
         end
diff --git a/babel.ins b/babel.ins
index 96793ec..db68123 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/13}
+\def\filedate{2021/11/15}
 \def\batchfile{babel.ins}
 \input docstrip.tex
 
diff --git a/babel.pdf b/babel.pdf
index e5ee43b..2aad0e8 100644
Binary files a/babel.pdf and b/babel.pdf differ
diff --git a/bbcompat.dtx b/bbcompat.dtx
index d5dadca..dc361e5 100644
--- a/bbcompat.dtx
+++ b/bbcompat.dtx
@@ -30,7 +30,7 @@
 %
 % \iffalse
 %<*dtx>
-\ProvidesFile{bbcompat.dtx}[2021/11/13 v3.66.2555]
+\ProvidesFile{bbcompat.dtx}[2021/11/15 v3.66.2557]
 %</dtx>
 %
 %% File 'bbcompat.dtx'





More information about the latex3-commits mailing list.