[latex3-commits] [git/LaTeX3-latex3-babel] master: \babelposthyphenation - insert for discretionaries (d75524a)

Javier email at dante.de
Mon Nov 23 17:56:08 CET 2020


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

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

commit d75524a130453c883f92cf9d1abe107047f711bd
Author: Javier <email at localhost>
Date:   Mon Nov 23 17:56:08 2020 +0100

    \babelposthyphenation - insert for discretionaries


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

d75524a130453c883f92cf9d1abe107047f711bd
 README.md    |   4 +--
 babel.dtx    |  81 ++++++++++++++++++++++++++++++++++-------------------------
 babel.ins    |   2 +-
 babel.pdf    | Bin 815299 -> 815893 bytes
 bbcompat.dtx |   2 +-
 5 files changed, 51 insertions(+), 38 deletions(-)

diff --git a/README.md b/README.md
index 73e183f..fccd8fb 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-## Babel 3.51.2198
+## Babel 3.51.2200
 
 This package manages culturally-determined typographical (and other)
 rules, and hyphenation patterns for a wide range of languages.  Many
@@ -44,7 +44,7 @@ respective authors.
 ### Latest changes
 ```
 3.52   2020-12-??
-       - Improved \babelprehyphenation
+       - Improved \babelprehyphenation and \babelprehyphenation.
        - Fixes:
          - A couple of issues with \localeinfo and \getlocaleproperty
            (#102, #105).
diff --git a/babel.dtx b/babel.dtx
index 99fe21d..72c0f43 100644
--- a/babel.dtx
+++ b/babel.dtx
@@ -31,7 +31,7 @@
 %
 % \iffalse
 %<*filedriver>
-\ProvidesFile{babel.dtx}[2020/11/21 v3.51.2198 The Babel package]
+\ProvidesFile{babel.dtx}[2020/11/23 v3.51.2200 The Babel package]
 \documentclass{ltxdoc}
 \GetFileInfo{babel.dtx}
 \usepackage{fontspec}
@@ -4823,8 +4823,8 @@ help from Bernd Raichle, for which I am grateful.
 % \section{Tools}
 %
 %    \begin{macrocode}
-%<<version=3.51.2198>>
-%<<date=2020/11/21>>
+%<<version=3.51.2200>>
+%<<date=2020/11/23>>
 %    \end{macrocode}
 %
 % \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -5234,9 +5234,17 @@ help from Bernd Raichle, for which I am grateful.
 \ProvidesPackage{babel}[<@date@> <@version@> The Babel package]
 \@ifpackagewith{babel}{debug}
   {\providecommand\bbl at trace[1]{\message{^^J[ #1 ]}}%
-   \let\bbl at debug\@firstofone}
+   \let\bbl at debug\@firstofone
+   \ifx\directlua\@undefined\else
+     \directlua{ Babel = Babel or {}
+       Babel.debug = true }%
+   \fi}
   {\providecommand\bbl at trace[1]{}%
-   \let\bbl at debug\@gobble}
+   \let\bbl at debug\@gobble
+   \ifx\directlua\@undefined\else
+     \directlua{ Babel = Babel or {}
+       Babel.debug = false }%
+   \fi}
 <@Basic macros@>
   % Temporarily repeat here the code for errors
   \def\bbl at error#1#2{%
@@ -13806,12 +13814,9 @@ end
 
         local last_match = 0
 
-        & print('====' .. p)
-
         &% For every match. 
         while true do
           local new  &% used when inserting and removing nodes
-          local changed = 0
           local refetch = false
 
           local matches = { u.match(w, p, last_match) }
@@ -13821,15 +13826,16 @@ end
           &% number with the position), and keep actual captures
           &% (from (...)), if any, in matches.
           local first = table.remove(matches, 1)
-          local last =  table.remove(matches, #matches)
-          local save_last = last
-          
-          &% print('*')
-          &% print(first, last, w)
+          local last  = table.remove(matches, #matches)
+          local save_last = last &% with A()BC()D, points to D
 
           &% Fix offsets, from bytes to unicode. Explained above.
           first = u.len(w:sub(1, first-1)) + 1
-          last  = u.len(w:sub(1, last-1))
+          last  = u.len(w:sub(1, last-1)) &% now last points to C
+          
+          if Babel.debug then
+            print('', 'sc', 'first', 'last', 'last_m', 'w')
+          end
 
           &% This loop traverses the matched substring and takes the
           &% corresponding action stored in the replacement list.
@@ -13848,23 +13854,21 @@ end
               char_base = wn[crep.data+first-1]
             end
 
+            if Babel.debug then
+              print('*', sc, first, last, last_match, w)
+            end
+
             if crep and next(crep) == nil then &% {}
               &% pass
 
             elseif crep == nil then &% remove
-              changed = changed + 1
-              &% print('*')
-              &% print(sc, last_match, w)
               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)
-              &% print(sc, last_match, w)
               sc = sc - 1
 
             elseif mode == 1 and crep and (crep.pre or crep.no or crep.post) then
-              changed = changed + 1              
-              refetch = true
               d = node.new(7, 0)   &% (disc, discretionary)
               d.pre     = Babel.str_to_nodes(crep.pre, matches, char_base)
               d.post    = Babel.str_to_nodes(crep.post, matches, char_base)
@@ -13876,14 +13880,19 @@ end
                 d.penalty = crep.penalty or tex.exhyphenpenalty
               end
               head, new = node.insert_before(head, char_node, d)
-              node.remove(head, char_node)
               if sc == 1 then
                 word_head = new
               end
+              if crep.insert then           
+                last_match = save_last
+              else
+                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)
+              end
 
             elseif mode == 0 and crep and crep.penalty then         
-              if crep.insert then         
-                changed = changed + 1
                 d = node.new(14, 0)   &% (penalty, userpenalty)          
                 d.attr = char_base.attr
                 d.penalty = crep.penalty
@@ -13891,11 +13900,16 @@ end
                 if sc == 1 then
                   word_head = new
                 end           
-                last_match = save_last &% is utf8.offset(w, sc+1) ok?
-              end
+                if crep.insert then
+                  last_match = save_last &% is utf8.offset(w, sc+1) ok?
+                else
+                  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)
+                end
 
             elseif crep and crep.string then
-              changed = changed + 1
               local str = crep.string(matches)
               if str == '' then 
                 refetch = true
@@ -13932,14 +13946,13 @@ end
             end  &% if char and char.string
           end  &% for char in match
 
-          if changed > 20 then  &% TODO. Useful?
-            texio.write('Too many changes. Ignoring the rest.')
-          elseif changed > 0 then
-            if refetch then
-              w, wn, nw, lang = Babel.fetch_subtext[mode](word_head)
-            else           
-              refetch = true
-            end              
+          if Babel.debug then
+            print('/', sc, first, last, last_match, w)
+          end
+
+          &% TODO. refetch must be eventually unnecesary
+          if refetch then
+            w, wn, nw, lang = Babel.fetch_subtext[mode](word_head)
           end              
 
         end  &% for match
diff --git a/babel.ins b/babel.ins
index 3bae242..7cc69b8 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{2020/11/21}
+\def\filedate{2020/11/23}
 \def\batchfile{babel.ins}
 \input docstrip.tex
 
diff --git a/babel.pdf b/babel.pdf
index a07d953..8f7407e 100644
Binary files a/babel.pdf and b/babel.pdf differ
diff --git a/bbcompat.dtx b/bbcompat.dtx
index 73dc94a..b979db5 100644
--- a/bbcompat.dtx
+++ b/bbcompat.dtx
@@ -30,7 +30,7 @@
 %
 % \iffalse
 %<*dtx>
-\ProvidesFile{bbcompat.dtx}[2020/11/21 v3.51.2198]
+\ProvidesFile{bbcompat.dtx}[2020/11/23 v3.51.2200]
 %</dtx>
 %
 %% File 'bbcompat.dtx'





More information about the latex3-commits mailing list.