[latex3-commits] [git/LaTeX3-latex3-babel] master: \babelprehyphenation: new 'space', fixes with 'ìnsert' (8bee69f)

Javier email at dante.de
Sun Mar 7 11:58:26 CET 2021


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

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

commit 8bee69fae3dce6b1aaee472205a2e45955c02158
Author: Javier <email at localhost>
Date:   Sun Mar 7 11:58:26 2021 +0100

    \babelprehyphenation: new 'space', fixes with 'ìnsert'


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

8bee69fae3dce6b1aaee472205a2e45955c02158
 README.md                                   |  11 ++++--
 babel.dtx                                   |  57 +++++++++++++++++++++++-----
 babel.ins                                   |   2 +-
 babel.pdf                                   | Bin 818518 -> 819803 bytes
 bbcompat.dtx                                |   2 +-
 news-guides/news/whats-new-in-babel-3.56.md |  46 ++++++++++++++++++++++
 6 files changed, 102 insertions(+), 16 deletions(-)

diff --git a/README.md b/README.md
index 1ec95e1..ef4ec0f 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-## Babel 3.55
+## Babel 3.55.2304
 
 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 <https://ctan.org/pkg/babel>.
 
-Changes in version 3.55 are described in:
+Changes in version 3.56 are described in:
 
-https://github.com/latex3/babel/blob/master/news-guides/news/whats-new-in-babel-3.55.md
+https://github.com/latex3/babel/blob/master/news-guides/news/whats-new-in-babel-3.56.md
 
 Apart from the manual, you can find information on some aspects of babel at:
 
@@ -46,6 +46,9 @@ respective authors.
 
 ### Summary of Latest changes
 ```
+3.56   2021-03-23??
+       * Key 'space' in \babelprehyphenation.
+         
 3.55   2021-03-03??
        * Captions for Uyghur.
        * Fixes:
@@ -57,5 +60,5 @@ respective authors.
 
 ### Previous changes
 
-See https://github.com/latex3/babel/blob/master/news-guides/news/
+See https://github.com/latex3/babel/blob/master/news-guides/README.md#whats-new
 
diff --git a/babel.dtx b/babel.dtx
index e91394c..f98e764 100644
--- a/babel.dtx
+++ b/babel.dtx
@@ -31,7 +31,7 @@
 %
 % \iffalse
 %<*filedriver>
-\ProvidesFile{babel.dtx}[2021/03/03 v3.55 The Babel package]
+\ProvidesFile{babel.dtx}[2021/03/07 v3.55.2304 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>>
-%<<date=2021/03/03>>
+%<<version=3.55.2304>>
+%<<date=2021/03/07>>
 %    \end{macrocode}
 %
 % \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -13946,7 +13946,7 @@ end
 
           if Babel.debug then
             print(p)
-            print('', 'sc', 'first', 'last', 'last_m', 'w')
+            print('', 'sc', 'first', 'last', 'last_m', '#w', rc, 'w')
           end
 
           &% This loop traverses the matched substring and takes the
@@ -13961,17 +13961,32 @@ end
             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 .. '='
+                end
+              end
+              print(ss)
+            end
+
             local crep = r[rc]
             local char_node = wn[sc]
             local char_base = char_node
             local end_replacement = false
+            local placeholder = Babel.us_char
 
             if crep and crep.data then
               char_base = wn[crep.data+first-1]
             end
 
             if Babel.debug then
-              print('*', sc, first, last, last_match, w)
+              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 &% {}
@@ -13998,6 +14013,17 @@ end
               head, new = node.insert_before(head, char_node, d)
               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 d = node.new(12, 13)      &% (glue, spaceskip)
+              node.setglue(d, crep.space[1] * quad,
+                              crep.space[2] * quad,
+                              crep.space[3] * quad)
+              placeholder = '|'
+              head, new = node.insert_before(head, char_node, d)
+              end_replacement = true
+
             elseif crep and crep.penalty then
               local d = node.new(14, 0)   &% (penalty, userpenalty)
               d.attr = char_base.attr
@@ -14030,7 +14056,7 @@ end
                   n.char = s
                   if sc == 1 then
                     head, new = node.insert_before(head, char_node, n)
-                    word_head = new
+                    word_head = head
                   else
                     node.insert_before(head, char_node, n)
                   end
@@ -14039,23 +14065,28 @@ end
               end  &% string length
             end  &% if char and char.string (ie replacement cases)
             
-            &% Shared by disc and penalty.
+            &% Shared by disc, space and penalty.
             if end_replacement then
               if sc == 1 then
-                word_head = new
+                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
+                last = last + 1
+                sc = sc - 1
+                refetch = true &% Temp: restore refetch :(
               else
                 node.remove(head, char_node)
-                w = u.sub(w, 1, sc-1) .. Babel.us_char .. u.sub(w, sc+1)
+                w = u.sub(w, 1, sc-1) .. placeholder .. u.sub(w, sc+1)
                 last_match = utf8.offset(w, sc)
               end
             end
           end  &% for each replacement
 
           if Babel.debug then
-            print('/', sc, first, last, last_match, w)
+            print('/', sc, first, last, last_match, #w, rc,  w)
           end
 
           &% TODO. refetch will be eventually unnecesary.
@@ -14064,6 +14095,10 @@ end
           end
 
         end  &% for match
+
+        if Babel.debug then
+           print('//', sc, first, last, last_match, '#w', rc,  w)
+        end
       end  &% for patterns
 
       ::next::
@@ -14172,6 +14207,8 @@ end
            local rep = [[##1]]
            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' .. '}')
            tex.print([[\string\babeltempa{{]] .. rep .. [[}}]])
          }}}&%
     \directlua{
diff --git a/babel.ins b/babel.ins
index 29d689b..709b00a 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/03}
+\def\filedate{2021/03/07}
 \def\batchfile{babel.ins}
 \input docstrip.tex
 
diff --git a/babel.pdf b/babel.pdf
index 89135c5..23b1bd7 100644
Binary files a/babel.pdf and b/babel.pdf differ
diff --git a/bbcompat.dtx b/bbcompat.dtx
index 9109219..62ff6f0 100644
--- a/bbcompat.dtx
+++ b/bbcompat.dtx
@@ -30,7 +30,7 @@
 %
 % \iffalse
 %<*dtx>
-\ProvidesFile{bbcompat.dtx}[2021/03/03 v3.55]
+\ProvidesFile{bbcompat.dtx}[2021/03/07 v3.55.2304]
 %</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
new file mode 100644
index 0000000..e6017c0
--- /dev/null
+++ b/news-guides/news/whats-new-in-babel-3.56.md
@@ -0,0 +1,46 @@
+# What's new in babel 3.55
+
+(Under development.)
+
+## Inserting spaces (with `luatex`)
+
+Some languages require readjusting the space before or after somo
+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
+from with `data`:
+```tex
+\babelprehyphenation{french}{ «{a} }{
+  {},
+  { insert, penalty = 10000 }, 
+  { insert, space=.2 .05 0, data = 1 },
+  {}
+}
+\babelprehyphenation{french}{ «|{a} }{
+  {},
+  { insert, penalty = 10000 },
+  { space=.2 .05 0, data = 1 },
+  {}
+}
+```
+Alternatively, the first one can be defined as follows if it comes
+before the second declaration (because the pattern of the latter
+then matches):
+```tex
+\babelprehyphenation{french}{ «{a} }{
+  {},
+  { insert, space=.2 .05 0, data = 1 },
+  {}
+}
+```
+
+As you can see, now multiple insertions are allowed, which is often
+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.
+
+ 
\ No newline at end of file





More information about the latex3-commits mailing list.