[latex3-commits] [git/LaTeX3-latex3-babel] master: \babelprehyphenation: 'insert' optimized; fixes in 'data'. (2b50811)

Javier email at dante.de
Mon Mar 8 18:51:15 CET 2021


Repository : https://github.com/latex3/babel
On branch  : master
Link       : https://github.com/latex3/babel/commit/2b50811eeec3823490fe3548d245f95288ba5eb4

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

commit 2b50811eeec3823490fe3548d245f95288ba5eb4
Author: Javier <email at localhost>
Date:   Mon Mar 8 18:51:15 2021 +0100

    \babelprehyphenation: 'insert' optimized; fixes in 'data'.


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

2b50811eeec3823490fe3548d245f95288ba5eb4
 README.md                                   |   5 ++-
 babel.dtx                                   |  57 +++++++++++++++++-----------
 babel.ins                                   |   2 +-
 babel.pdf                                   | Bin 819803 -> 820602 bytes
 bbcompat.dtx                                |   2 +-
 news-guides/news/whats-new-in-babel-3.56.md |   9 +++--
 6 files changed, 45 insertions(+), 30 deletions(-)

diff --git a/README.md b/README.md
index ef4ec0f..e90e11d 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-## Babel 3.55.2304
+## Babel 3.55.2305
 
 This package manages culturally-determined typographical (and other)
 rules, and hyphenation patterns for a wide range of languages. Many
@@ -48,6 +48,9 @@ respective authors.
 ```
 3.56   2021-03-23??
        * Key 'space' in \babelprehyphenation.
+       * Multiple 'insert's allowed.
+       * Fixes:
+         - 'insert' and 'data' not always set/get the expected node.
          
 3.55   2021-03-03??
        * Captions for Uyghur.
diff --git a/babel.dtx b/babel.dtx
index f98e764..24b897e 100644
--- a/babel.dtx
+++ b/babel.dtx
@@ -31,7 +31,7 @@
 %
 % \iffalse
 %<*filedriver>
-\ProvidesFile{babel.dtx}[2021/03/07 v3.55.2304 The Babel package]
+\ProvidesFile{babel.dtx}[2021/03/08 v3.55.2305 The Babel package]
 \documentclass{ltxdoc}
 \GetFileInfo{babel.dtx}
 \usepackage{fontspec}
@@ -4849,8 +4849,8 @@ help from Bernd Raichle, for which I am grateful.
 % \section{Tools}
 %
 %    \begin{macrocode}
-%<<version=3.55.2304>>
-%<<date=2021/03/07>>
+%<<version=3.55.2305>>
+%<<date=2021/03/08>>
 %    \end{macrocode}
 %
 % \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -13949,26 +13949,39 @@ end
             print('', 'sc', 'first', 'last', 'last_m', '#w', rc, 'w')
           end
 
+          &% This loop stores in n small table the nodes
+          &% corresponding to the pattern. Used by 'data' to provide a
+          &% predictable behavior with 'insert' (now wn is modified on
+          &% the fly), and also access to 'remove'd nodes.
+          local sc = first-1           &% Used below, too
+          local data_nodes = {}
+          
+          for q = 1, last-first+1 do
+            data_nodes[q] = wn[sc+q]
+          end
+          
           &% This loop traverses the matched substring and takes the
           &% corresponding action stored in the replacement list.
           &% sc = the position in substr nodes / string
           &% rc = the replacement table index
-          local sc = first-1
           local rc = 0
+
           while rc < last-first+1 do &% for each replacement
             if Babel.debug then
-              print('.....')
+              print('.....', #data_nodes)
             end
             sc = sc + 1
             rc = rc + 1
 
             if Babel.debug then
               local ss = ''
-              for pp = 1, 10 do
-                if wn[pp].id == 29 then
-                  ss = ss .. unicode.utf8.char(wn[pp].char)
-                else
-                  ss = ss .. '='
+              for pp = 1, 20 do
+                if wn[pp] then
+                  if wn[pp].id == 29 then
+                    ss = ss .. unicode.utf8.char(wn[pp].char)
+                  else
+                    ss = ss .. '{' .. wn[pp].id .. '}'
+                  end
                 end
               end
               print(ss)
@@ -13981,23 +13994,22 @@ end
             local placeholder = Babel.us_char
 
             if crep and crep.data then
-              char_base = wn[crep.data+first-1]
+              char_base = data_nodes[crep.data]
             end
 
             if Babel.debug then
-              if char_node.id == 29 then print('++', char_node.char) end
               print('*', sc, first, last, last_match, char_node.id, rc, w)
             end
 
-            if crep and next(crep) == nil then &% {}
+            if crep and next(crep) == nil then &% = {}
               last_match = save_last
 
-            elseif crep == nil then &% remove
+            elseif crep == nil then &% = remove
               node.remove(head, char_node)
               table.remove(wn, sc)
               w = u.sub(w, 1, sc-1) .. u.sub(w, sc+1)
               last_match = utf8.offset(w, sc)
-              sc = sc - 1  &% Nothing has been inserted
+              sc = sc - 1  &% Nothing has been inserted.
 
             elseif mode == 1 and crep and (crep.pre or crep.no or crep.post) then
               local d = node.new(7, 0)   &% (disc, discretionary)
@@ -14014,8 +14026,10 @@ end
               end_replacement = true
 
             elseif crep and crep.space then
-              &% local quad = 655360      &% 10 pt = 655360 = 10 * 65536
-              quad = font.getfont(char_base.font).size
+              local quad = 655360      &% 10 pt = 655360 = 10 * 65536
+              if char_base.font then
+                local quad = font.getfont(char_base.font).size
+              end 
               local d = node.new(12, 13)      &% (glue, spaceskip)
               node.setglue(d, crep.space[1] * quad,
                               crep.space[2] * quad,
@@ -14071,12 +14085,10 @@ end
                 word_head = head
               end
               if crep.insert then
-                &% TODO. For this to work, it seem we need 'split' rc 
-                &% w = u.sub(w, 1, sc-1) .. placeholder .. u.sub(w, sc)
-                last_match = save_last
+                w = u.sub(w, 1, sc-1) .. placeholder .. u.sub(w, sc)
+                table.insert(wn, sc, new)
                 last = last + 1
-                sc = sc - 1
-                refetch = true &% Temp: restore refetch :(
+                last_match = save_last
               else
                 node.remove(head, char_node)
                 w = u.sub(w, 1, sc-1) .. placeholder .. u.sub(w, sc+1)
@@ -14106,7 +14118,6 @@ end
     end  &% for substring
     return head
   end
-
   &% This table stores capture maps, numbered consecutively
   Babel.capture_maps = {}
 
diff --git a/babel.ins b/babel.ins
index 709b00a..89d04e5 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/03/07}
+\def\filedate{2021/03/08}
 \def\batchfile{babel.ins}
 \input docstrip.tex
 
diff --git a/babel.pdf b/babel.pdf
index 23b1bd7..8384a1e 100644
Binary files a/babel.pdf and b/babel.pdf differ
diff --git a/bbcompat.dtx b/bbcompat.dtx
index 62ff6f0..de70e9f 100644
--- a/bbcompat.dtx
+++ b/bbcompat.dtx
@@ -30,7 +30,7 @@
 %
 % \iffalse
 %<*dtx>
-\ProvidesFile{bbcompat.dtx}[2021/03/07 v3.55.2304]
+\ProvidesFile{bbcompat.dtx}[2021/03/08 v3.55.2305]
 %</dtx>
 %
 %% File 'bbcompat.dtx'
diff --git a/news-guides/news/whats-new-in-babel-3.56.md b/news-guides/news/whats-new-in-babel-3.56.md
index e6017c0..438065a 100644
--- a/news-guides/news/whats-new-in-babel-3.56.md
+++ b/news-guides/news/whats-new-in-babel-3.56.md
@@ -1,10 +1,10 @@
-# What's new in babel 3.55
+# What's new in babel 3.56
 
 (Under development.)
 
 ## Inserting spaces (with `luatex`)
 
-Some languages require readjusting the space before or after somo
+Some languages require readjusting the space before or after some
 characters (a well-known case is French). There is a new key to add a
 space, with takes 3 numbers for the natural width, the `plus` and the
 `minus` in em units. You may need to set where the quad value is taken
@@ -40,7 +40,8 @@ necessary when a space is added.
 ## Fixes
 
 * When writing the previous feature, some anomalous behavior when
-  inserting items (either with a multi-letter `string` or with
-  `insert`). The fix is not efficient, but at least now it should work.
+  inserting items was detecte, either with a multi-letter `string` or
+  with `insert`. In these cases, `data` was somewhat unpredictable,
+  too.
 
  
\ No newline at end of file





More information about the latex3-commits mailing list.