[latex3-commits] [git/LaTeX3-latex3-babel] master: Syntax {XXXX} in transform pattern for any char. (fea24cf)

Javier email at dante.de
Tue Mar 23 16:35:29 CET 2021


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

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

commit fea24cf0f9f48125ee8731b331666748eb83d8b0
Author: Javier <email at localhost>
Date:   Tue Mar 23 16:35:29 2021 +0100

    Syntax {XXXX} in transform pattern for any char.


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

fea24cf0f9f48125ee8731b331666748eb83d8b0
 README.md                                   |   2 +-
 babel.dtx                                   |  40 +++++++++++++++++-----------
 babel.ins                                   |   2 +-
 babel.pdf                                   | Bin 823156 -> 823323 bytes
 bbcompat.dtx                                |   2 +-
 locale/es/babel-es.ini                      |   7 +++++
 news-guides/news/whats-new-in-babel-3.56.md |  21 +++++++++++++--
 7 files changed, 53 insertions(+), 21 deletions(-)

diff --git a/README.md b/README.md
index 18809a6..c327e4b 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-## Babel 3.55.2319
+## Babel 3.55.2320
 
 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 bfcd1ee..7d36329 100644
--- a/babel.dtx
+++ b/babel.dtx
@@ -31,7 +31,7 @@
 %
 % \iffalse
 %<*filedriver>
-\ProvidesFile{babel.dtx}[2021/03/22 v3.55.2319 The Babel package]
+\ProvidesFile{babel.dtx}[2021/03/23 v3.55.2320 The Babel package]
 \documentclass{ltxdoc}
 \GetFileInfo{babel.dtx}
 \usepackage{fontspec}
@@ -4856,8 +4856,8 @@ help from Bernd Raichle, for which I am grateful.
 % \section{Tools}
 %
 %    \begin{macrocode}
-%<<version=3.55.2319>>
-%<<date=2021/03/22>>
+%<<version=3.55.2320>>
+%<<date=2021/03/23>>
 %    \end{macrocode}
 %
 % \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -11716,7 +11716,7 @@ help from Bernd Raichle, for which I am grateful.
         \in@{.0$}{#2$}&%
         \ifin@
             \bbl at add\bbl at release@transforms{&%
-              \relax\bbl at transforms@aux#1{french}{#3}}&%
+              \relax\bbl at transforms@aux#1{\languagename}{#3}}&%
           \else
             \bbl at add\bbl at release@transforms{, {#3}}&%
         \fi
@@ -14264,6 +14264,7 @@ end
     \directlua{
       local lbkr = Babel.linebreaking.replacements[1]
       local u = unicode.utf8
+      local id = \the\csname l@#1\endcsname
       &% Convert pattern:
       local patt = string.gsub([==[#2]==], '%s', '')
       if not u.find(patt, '()', nil, true) then
@@ -14272,12 +14273,15 @@ 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)
-      lbkr[\the\csname l@#1\endcsname] = lbkr[\the\csname l@#1\endcsname] or {}
-      table.insert(lbkr[\the\csname l@#1\endcsname],
-                   { pattern = patt, replace = { \babeltempb } })
+             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)
+      lbkr[id] = lbkr[id] or {}
+      table.insert(lbkr[id], { pattern = patt, replace = { \babeltempb } })
     }&%
   \endgroup}
 % TODO. Copypaste pattern. 
@@ -14304,6 +14308,7 @@ end
     \directlua{
       local lbkr = Babel.linebreaking.replacements[0]
       local u = unicode.utf8
+      local id = \the\csname bbl at id@@#1\endcsname
       &% Convert pattern:
       local patt = string.gsub([==[#2]==], '%s', '')
       if not u.find(patt, '()', nil, true) then
@@ -14312,12 +14317,15 @@ end
       &% patt = string.gsub(patt, '%(%)%^', '^()')
       &% patt = string.gsub(patt, '([^%%])%$%(%)', '%1()$')
       patt = u.gsub(patt, '{(.)}', 
-                function (n)
-                  return '%' .. (tonumber(n) and (tonumber(n)+1) or n)
-                end)
-      lbkr[\the\csname bbl at id@@#1\endcsname] = lbkr[\the\csname  bbl at id@@#1\endcsname] or {}
-      table.insert(lbkr[\the\csname bbl at id@@#1\endcsname],
-                   { pattern = patt, replace = { \babeltempb } })
+             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)
+      lbkr[id] = lbkr[id] or {}
+      table.insert(lbkr[id], { pattern = patt, replace = { \babeltempb } })
     }&%
   \endgroup}
 \endgroup
diff --git a/babel.ins b/babel.ins
index 5236551..e20a3ca 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/22}
+\def\filedate{2021/03/23}
 \def\batchfile{babel.ins}
 \input docstrip.tex
 
diff --git a/babel.pdf b/babel.pdf
index ba84818..fa17f8d 100644
Binary files a/babel.pdf and b/babel.pdf differ
diff --git a/bbcompat.dtx b/bbcompat.dtx
index ea8696a..55dae16 100644
--- a/bbcompat.dtx
+++ b/bbcompat.dtx
@@ -30,7 +30,7 @@
 %
 % \iffalse
 %<*dtx>
-\ProvidesFile{bbcompat.dtx}[2021/03/22 v3.55.2319]
+\ProvidesFile{bbcompat.dtx}[2021/03/23 v3.55.2320]
 %</dtx>
 %
 %% File 'bbcompat.dtx'
diff --git a/locale/es/babel-es.ini b/locale/es/babel-es.ini
index 5ed832d..733293f 100644
--- a/locale/es/babel-es.ini
+++ b/locale/es/babel-es.ini
@@ -183,3 +183,10 @@ plusSign = +
 superscriptingExponent = ×
 
 [counters]
+
+[transforms.prehyphenation]
+; Experimental. Don't use in production
+percent.space.1.0 = { {d}{0025} }
+percent.space.1.1 = {}
+percent.space.1.2 = { insert, spacefactor = .5 .3 .5, data = 1 }
+percent.space.1.3 = {}
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 89b9353..1f94074 100644
--- a/news-guides/news/whats-new-in-babel-3.56.md
+++ b/news-guides/news/whats-new-in-babel-3.56.md
@@ -68,14 +68,31 @@ space.punctuation.1.3 = { insert, spacefactor=.8 .3 .8, data = 1 }
 space.punctuation.1.4 = {}
 ```
 
-`0` is the pattern. It must be activated with `transforms` in
-`\babelprovide`, eg:
+`0` is the pattern. The replacements are `1`, `2`, etc. It must be
+activated with `transforms` in `\babelprovide`, eg:
 
 ```tex
 \babelprovide[transforms = space.punctuation, import]{...}
 ```
+
+A single transform (with a single name) may consist in a collection of
+rules (a typical case would be a transliteration scheme). Every rule in
+the collection is numbered (the first `.1.` in the example). There can be even
+rules in the two sections for transforms (`transforms.prehyphenation`
+and `transforms.posthyphenation`; in such a case, restart with `1` in
+the second section).
+
 (*To be expanded.*)
 
+## Arbitrary characters in patterns
+
+The brace syntax has been extended to insert any character (for
+example, `%`). Just write the hex code with at least 4 ‘hex digits’.
+For example, `{d}{0025}` matches a digit followed by a `%`.
+
+Remember you can still enter characters with the old good `^^` syntax,
+which they are converted at the TeX level; this `{}` extension is
+handled by lua directly, so catcodes are not taken into account.
 
 ## Fixes
 





More information about the latex3-commits mailing list.