[latex3-commits] [git/LaTeX3-latex3-babel] master: Enable standard LaTeX syntax for ini files. Also: (fdbdea2)

Javier email at dante.de
Tue Sep 22 16:34:44 CEST 2020


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

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

commit fdbdea21b9f69016195bd6f5df26c2874c363c30
Author: Javier <email at localhost>
Date:   Tue Sep 22 16:34:44 2020 +0200

    Enable standard LaTeX syntax for ini files. Also:
    
    * Some refactoring in read at ini
    * Patch fontspec to avoid 'Language X not availiable'


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

fdbdea21b9f69016195bd6f5df26c2874c363c30
 README.md    |  14 +++-
 babel.dtx    | 234 ++++++++++++++++++++++++++++++++++++++++-------------------
 babel.ins    |   2 +-
 babel.pdf    | Bin 803286 -> 806523 bytes
 bbcompat.dtx |   2 +-
 5 files changed, 173 insertions(+), 79 deletions(-)

diff --git a/README.md b/README.md
index 46f331e..9da1c1d 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-## Babel 3.48
+## Babel 3.48.2138
 
 This package manages culturally-determined typographical (and other)
 rules, and hyphenation patterns for a wide range of languages.  Many
@@ -7,11 +7,11 @@ lualatex out of the box.  A few even work with plain formats.
 
 The latest stable version is available on <https://ctan.org/pkg/babel>.
 
-Changes in version 3.48 are described in:
+Changes in version 3.49 are described in:
 
-https://github.com/latex3/babel/wiki/What's-new-in-babel-3.48
+https://github.com/latex3/babel/wiki/What's-new-in-babel-3.49
 
-Included is a set of ini files for about 200 languages. 
+Included is a set of ini files for about 250 languages. 
 
 The best way to install and/or update it is with the help of package
 managers.
@@ -44,6 +44,11 @@ respective authors.
 ### Latest changes
 
 ```
+3.49   2020-09-22
+       - Allow standard LaTeX syntax to recognize locales based on ini
+         files in the most common cases.
+       - Fixes:
+       
 3.48   2020-09-01
        - New (tentative) tools to customize some labels (like chapters
          in CJK and Hungarian). 
@@ -53,6 +58,7 @@ respective authors.
          - \babelshorthand didn't work with some dialects (#91).
          - \selectlanguage and otherlanguage raised an error inside
            tabular.
+https://github.com/latex3/babel/wiki/What's-new-in-babel-3.48       
 
 3.47   2020-07-13
        - Fixes:
diff --git a/babel.dtx b/babel.dtx
index 51153eb..a4942a1 100644
--- a/babel.dtx
+++ b/babel.dtx
@@ -31,7 +31,7 @@
 %
 % \iffalse
 %<*filedriver>
-\ProvidesFile{babel.dtx}[2020/09/01 v3.48 The Babel package]
+\ProvidesFile{babel.dtx}[2020/09/22 v3.48.2138 The Babel package]
 \documentclass{ltxdoc}
 \GetFileInfo{babel.dtx}
 \usepackage{fontspec}
@@ -330,9 +330,9 @@ in UTF-8 and a so-called Unicode font must be loaded (in this example
 
 \setengine{luatex/xetex}
 \begin{verbatim}
-\documentclass{article}
+\documentclass[russian]{article}
 
-_\usepackage[russian]{babel}_
+_\usepackage{babel}_
 
 \babelfont{rm}{DejaVu Serif}
 
@@ -547,8 +547,8 @@ until required, so that it can be used just in case.
   A trivial document is:
 \setengine{luatex/xetex}
 \begin{verbatim}
-\documentclass{article}
-\usepackage[english]{babel}
+\documentclass[english]{article}
+\usepackage{babel}
 
 \babelfont[russian]{rm}{FreeSerif}
 
@@ -1389,8 +1389,8 @@ need to set explicitly the script to either |deva| or |dev2|, eg:
   be used in conjunction with the |ldf| for |japanese|, because the
   following piece of code loads \textsf{luatexja}:
 \begin{verbatim}
-\documentclass{ltjbook}
-\usepackage[japanese]{babel}
+\documentclass[japanese]{ltjbook}
+\usepackage{babel}
 \end{verbatim}
 \item[Latin, Greek, Cyrillic] Combining chars with the default
  \luatex{} font renderer might be wrong; on then other hand, with the
@@ -4744,8 +4744,8 @@ help from Bernd Raichle, for which I am grateful.
 % \section{Tools}
 %
 %    \begin{macrocode}
-%<<version=3.48>>
-%<<date=2020/09/01>>
+%<<version=3.48.2138>>
+%<<date=2020/09/22>>
 %    \end{macrocode}
 %
 % \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -5273,17 +5273,24 @@ help from Bernd Raichle, for which I am grateful.
 %    \begin{macrocode}
 \bbl at trace{key=value and another general options}
 \bbl at csarg\let{tempa\expandafter}\csname opt at babel.sty\endcsname
-\def\bbl at tempb#1.#2{%
+\def\bbl at tempb#1.#2{%  Remove trailing dot
    #1\ifx\@empty#2\else,\bbl at afterfi\bbl at tempb#2\fi}%
-\def\bbl at tempd#1.#2\@nnil{%
+\def\bbl at tempd#1.#2\@nnil{%  TODO. Refactor lists?
   \ifx\@empty#2%
     \edef\bbl at tempc{\ifx\bbl at tempc\@empty\else\bbl at tempc,\fi#1}%
   \else
-    \in@{=}{#1}\ifin@
-      \edef\bbl at tempc{\ifx\bbl at tempc\@empty\else\bbl at tempc,\fi#1.#2}%
+    \in@{,ini,}{,#1,}%
+    \ifin@
+      \edef\bbl at tempc{%
+        \ifx\bbl at tempc\@empty\else\bbl at tempc,\fi#1.\bbl at tempb#2}%
     \else
-      \edef\bbl at tempc{\ifx\bbl at tempc\@empty\else\bbl at tempc,\fi#1}%
-      \bbl at csarg\edef{mod@#1}{\bbl at tempb#2}%
+      \in@{=}{#1}%
+      \ifin@
+        \edef\bbl at tempc{\ifx\bbl at tempc\@empty\else\bbl at tempc,\fi#1.#2}%
+      \else    
+        \edef\bbl at tempc{\ifx\bbl at tempc\@empty\else\bbl at tempc,\fi#1}%
+        \bbl at csarg\edef{mod@#1}{\bbl at tempb#2}%
+      \fi
     \fi
   \fi}
 \let\bbl at tempc\@empty
@@ -5310,6 +5317,10 @@ help from Bernd Raichle, for which I am grateful.
 % Don't use. Experimental. TODO.
 \newif\ifbbl at single
 \DeclareOption{selectors=off}{\bbl at singletrue}
+\chardef\bbl at iniflag\z@
+\DeclareOption{ini=*}{\chardef\bbl at iniflag\@ne}     % main -> +1
+\DeclareOption{ini.+=*}{\chardef\bbl at iniflag\tw@}   % add = 2
+\DeclareOption{ini.*=*}{\chardef\bbl at iniflag\thr@@} % add + main
 <@More package options@>
 %    \end{macrocode}
 %
@@ -6278,7 +6289,7 @@ help from Bernd Raichle, for which I am grateful.
       \AtEndOfPackage{%
         \EnableBabelHook{babel-bidi}%
         \ifx\fontspec\@undefined
-          \usepackage{fontspec}% bidi needs fontspec
+          \bbl at loadfontspec % bidi needs fontspec
         \fi
         \usepackage#1{bidi}}%
     \fi}
@@ -6287,10 +6298,8 @@ help from Bernd Raichle, for which I am grateful.
       \bbl at tentative{bidi=bidi}
       \bbl at loadxebidi{}
     \or
-      \bbl at tentative{bidi=bidi-r}
       \bbl at loadxebidi{[rldocument]}
     \or
-      \bbl at tentative{bidi=bidi-l}
       \bbl at loadxebidi{}
     \fi
   \fi
@@ -6566,7 +6575,7 @@ help from Bernd Raichle, for which I am grateful.
     {\bbl at error{%
        Unknown option `\CurrentOption'. Either you misspelled it\\%
        or the language definition file \CurrentOption.ldf was not found}{%
-       Valid options are: shorthands=, KeepShorthandsActive,\\%
+       Valid options are, among others: shorthands=, KeepShorthandsActive,\\%
        activeacute, activegrave, noconfigs, safe=, main=, math=\\%
        headfoot=, strings=, config=, hyphenmap=, or a language name.}}}
 %    \end{macrocode}
@@ -6578,9 +6587,9 @@ help from Bernd Raichle, for which I am grateful.
 %
 %    \begin{macrocode}
 \def\bbl at try@load at lang#1#2#3{%
-    \IfFileExists{\CurrentOption.ldf}%
-      {\bbl at load@language{\CurrentOption}}%
-      {#1\bbl at load@language{#2}#3}}
+  \IfFileExists{\CurrentOption.ldf}%
+    {\bbl at load@language{\CurrentOption}}%
+    {#1\bbl at load@language{#2}#3}}
 \DeclareOption{afrikaans}{\bbl at try@load at lang{}{dutch}{}}
 \DeclareOption{hebrew}{%
   \input{rlbabel.def}%
@@ -6631,38 +6640,83 @@ help from Bernd Raichle, for which I am grateful.
 % file are the same.
 %
 %    \begin{macrocode}
-\bbl at for\bbl at tempa\bbl at language@opts{%
-  \bbl at ifunset{ds@\bbl at tempa}%
-    {\edef\bbl at tempb{%
-       \noexpand\DeclareOption
-         {\bbl at tempa}%
-         {\noexpand\bbl at load@language{\bbl at tempa}}}%
-     \bbl at tempb}%
-     \@empty}
+\let\bbl at tempc\relax
+\bbl at foreach\bbl at language@opts{%
+  \ifcase\bbl at iniflag
+    \bbl at ifunset{ds@#1}%
+      {\DeclareOption{#1}{\bbl at load@language{#1}}}%
+      {}%
+  \or
+    \@gobble % case 2 same as 1
+  \or
+    \bbl at ifunset{ds@#1}%
+      {\IfFileExists{#1.ldf}{}%
+        {\IfFileExists{babel-#1.tex}{}{\DeclareOption{#1}{}}}}%
+      {}%
+    \bbl at ifunset{ds@#1}%
+      {\def\bbl at tempc{#1}%
+       \DeclareOption{#1}{%
+         \ifnum\bbl at iniflag>\@ne
+           \bbl at ldfinit
+           \babelprovide[import]{#1}%
+           \bbl at afterldf{}%
+         \else
+           \bbl at load@language{#1}%
+         \fi}}%
+      {}%
+  \or
+    \def\bbl at tempc{#1}%
+    \bbl at ifunset{ds@#1}%
+      {\DeclareOption{#1}{%
+         \bbl at ldfinit
+         \babelprovide[import]{#1}%
+         \bbl at afterldf{}}}%
+      {}%
+  \fi}
 %    \end{macrocode}
 %
 % Now, we make sure an option is explicitly declared for any
 % language set as global option, by checking if an |ldf|
 % exists. The previous step was, in fact, somewhat redundant, but
-% that way we minimize accesing the file system just to see if the
+% that way we minimize accessing the file system just to see if the
 % option could be a language.
 %
 %    \begin{macrocode}
+\let\bbl at tempb\@nnil
 \bbl at foreach\@classoptionslist{%
   \bbl at ifunset{ds@#1}%
-    {\IfFileExists{#1.ldf}%
-      {\DeclareOption{#1}{\bbl at load@language{#1}}}%
-      {}}%
+    {\IfFileExists{#1.ldf}{}%
+      {\IfFileExists{babel-#1.tex}{}{\DeclareOption{#1}{}}}}%
+    {}%
+  \bbl at ifunset{ds@#1}%
+    {\def\bbl at tempb{#1}%
+     \DeclareOption{#1}{%
+       \ifnum\bbl at iniflag>\@ne
+         \bbl at ldfinit
+         \babelprovide[import]{#1}%
+         \bbl at afterldf{}%
+       \else
+         \bbl at load@language{#1}%
+       \fi}}%
     {}}
 %    \end{macrocode}
 %
 %    If a main language has been set, store it for the third pass.
 %
 %    \begin{macrocode}
+\ifnum\bbl at iniflag=\z@\else
+  \ifx\bbl at opt@main\@nnil
+    \ifx\bbl at tempc\relax
+      \let\bbl at opt@main\bbl at tempb
+    \else
+      \let\bbl at opt@main\bbl at tempc
+    \fi
+  \fi
+\fi
 \ifx\bbl at opt@main\@nnil\else
   \expandafter
   \let\expandafter\bbl at loadmain\csname ds@\bbl at opt@main\endcsname
-  \DeclareOption{\bbl at opt@main}{}
+  \expandafter\let\csname ds@\bbl at opt@main\endcsname\@empty
 \fi
 %    \end{macrocode}
 %
@@ -6708,10 +6762,16 @@ help from Bernd Raichle, for which I am grateful.
       option. Reported}%
   \fi
 \else
-  \DeclareOption{\bbl at opt@main}{\bbl at loadmain}
-  \ExecuteOptions{\bbl at opt@main}
-  \DeclareOption*{}
-  \ProcessOptions*
+  \ifodd\bbl at iniflag  % case 1,3
+    \bbl at ldfinit
+    \bbl at exp{\\\babelprovide[import,main]{\bbl at opt@main}}
+    \bbl at afterldf{}%
+  \else % case 0,2
+    \chardef\bbl at iniflag\z@  % Force ldf 
+    \expandafter\let\csname ds@\bbl at opt@main\endcsname\bbl at loadmain
+    \DeclareOption*{}%
+    \ProcessOptions*
+  \fi
 \fi
 \def\AfterBabelLanguage{%
   \bbl at error
@@ -7229,7 +7289,7 @@ help from Bernd Raichle, for which I am grateful.
       \let\bbl at select@type\z@
       \expandafter\bbl at switch\expandafter{\languagename}%
     \fi}}
-\def\babel at aux#1#2{%
+\def\babel at aux#1#2{% TODO. See how to avoid undefined nil's
   \select at language{#1}%
   \bbl at foreach\BabelContentsFiles{%
     \@writefile{##1}{\babel at toc{#1}{#2}}}}% %% TODO - ok in plain?
@@ -8757,7 +8817,8 @@ help from Bernd Raichle, for which I am grateful.
 %    A user level command to change the language from which shorthands
 %    are used. Unfortunately, \babel{} currently does not keep track
 %    of defined groups, and therefore there is no way to catch a
-%    possible change in casing [TODO. Unclear].
+%    possible change in casing to fix it in the same way languages names
+%    are fixed. [TODO].
 %
 %    \begin{macrocode}
 \def\languageshorthands#1{\def\language at group{#1}}
@@ -9643,13 +9704,12 @@ help from Bernd Raichle, for which I am grateful.
 % order as defined.  Finally, the string is set.
 %
 %    \begin{macrocode}
-\def\bbl at setstring#1#2{%
+\def\bbl at setstring#1#2{% eg, \prefacename{<string>}
   \bbl at forlang\bbl at tempa{%
     \edef\bbl at LC{\bbl at tempa\bbl at stripslash#1}%
     \bbl at ifunset{\bbl at LC}% eg, \germanchaptername
-      {\global\expandafter  % TODO - con \bbl at exp ?
-       \bbl at add\csname\bbl at G\bbl at tempa\expandafter\endcsname\expandafter
-         {\expandafter\bbl at scset\expandafter#1\csname\bbl at LC\endcsname}}%
+      {\bbl at exp{%
+         \global\\\bbl at add\<\bbl at G\bbl at tempa>{\\\bbl at scset\\#1\<\bbl at LC>}}}%
       {}%
     \def\BabelString{#2}%
     \bbl at usehooks{stringprocess}{}%
@@ -10631,8 +10691,6 @@ help from Bernd Raichle, for which I am grateful.
 % first macro is the generic “localized” command.
 %
 %    \begin{macrocode}
-% TODO. Merge with \localenumeral:
-% \newcommand\localedigits{\@nameuse{\languagename digits}}
 \def\bbl at setdigits#1#2#3#4#5{%
   \bbl at exp{%
     \def\<\languagename digits>####1{%       ie, \langdigits
@@ -10831,8 +10889,10 @@ help from Bernd Raichle, for which I am grateful.
          \\\bbl at elt{\bbl at section}{\bbl at tempa}{\the\toks@}}}%
      \expandafter\bbl at inireader\bbl at tempa=#2\@@}%
     {}}%
-\def\bbl at read@ini#1#2{%
-  \bbl at csarg\edef{lini@\languagename}{#1}%
+\def\bbl at fetch@ini#1#2{%
+  \bbl at exp{\def\\\bbl at inidata{%
+    \\\bbl at elt{identification}{tag.ini}{#1}%
+    \\\bbl at elt{identification}{load.level}{#2}}}%
   \openin\bbl at readstream=babel-#1.ini
   \ifeof\bbl at readstream
     \bbl at error
@@ -10841,14 +10901,6 @@ help from Bernd Raichle, for which I am grateful.
        is not complete.}%
       {Fix the name or reinstall babel.}%
   \else
-    \bbl at exp{\def\\\bbl at inidata{%
-      \\\bbl at elt{identification}{tag.ini}{#1}%
-      \\\bbl at elt{identification}{load.level}{#2}}}%
-    \let\bbl at section\@empty
-    \let\bbl at savestrings\@empty
-    \let\bbl at savetoday\@empty
-    \let\bbl at savedate\@empty
-    \let\bbl at inireader\bbl at iniskip
     \bbl at info{Importing
                 \ifcase#2 \or font and identification \or basic \fi
                 data for \languagename\\%
@@ -10862,28 +10914,35 @@ help from Bernd Raichle, for which I am grateful.
         \expandafter\bbl at iniline\bbl at line\bbl at iniline
       \fi
     \repeat
-    \bbl at foreach\bbl at renewlist{%
-      \bbl at ifunset{bbl at renew@##1}{}{\bbl at inisec[##1]\@@}}%
-    \global\let\bbl at renewlist\@empty
-    % Ends last section. See \bbl at inisec
-    \def\bbl at elt##1##2{\bbl at inireader##1=##2\@@}%
-    \bbl at cs{renew@\bbl at section}%
-    \global\bbl at csarg\let{renew@\bbl at section}\relax
-    \bbl at cs{secpost@\bbl at section}%  
-    \bbl at csarg{\global\expandafter\let}{inidata@\languagename}\bbl at inidata
-    \bbl at exp{\\\bbl at add@list\\\bbl at ini@loaded{\languagename}}%
-    \bbl at toglobal\bbl at ini@loaded
   \fi}
+\def\bbl at read@ini#1#2{%
+  \bbl at csarg\edef{lini@\languagename}{#1}%
+  \let\bbl at section\@empty
+  \let\bbl at savestrings\@empty
+  \let\bbl at savetoday\@empty
+  \let\bbl at savedate\@empty
+  \let\bbl at inireader\bbl at iniskip
+  \bbl at fetch@ini{#1}{#2}%
+  \bbl at foreach\bbl at renewlist{%
+    \bbl at ifunset{bbl at renew@##1}{}{\bbl at inisec[##1]\@@}}%
+  \global\let\bbl at renewlist\@empty
+  % Ends last section. See \bbl at inisec
+  \def\bbl at elt##1##2{\bbl at inireader##1=##2\@@}%
+  \bbl at cs{renew@\bbl at section}%
+  \global\bbl at csarg\let{renew@\bbl at section}\relax
+  \bbl at cs{secpost@\bbl at section}%  
+  \bbl at csarg{\global\expandafter\let}{inidata@\languagename}\bbl at inidata
+  \bbl at exp{\\\bbl at add@list\\\bbl at ini@loaded{\languagename}}%
+  \bbl at toglobal\bbl at ini@loaded}
 \def\bbl at iniline#1\bbl at iniline{%
   \@ifnextchar[\bbl at inisec{\@ifnextchar;\bbl at iniskip\bbl at inipreread}#1\@@}% ]
 %    \end{macrocode}
 %
 % The special cases for comment lines and sections are handled by the
 % two following commands. In sections, we provide the posibility to
-% take extra actions at the end or at the start (TODO - but note the last
-% section is not ended). By default, key=val pairs are ignored. The
-% |secpost| ``hook'' is used only by `identification', while |secpre|
-% only by |date.gregorian.licr|.
+% take extra actions at the end or at the start. By default, key=val
+% pairs are ignored. The |secpost| ``hook'' is used only by
+% `identification', while |secpre| only by |date.gregorian.licr|.
 %
 %    \begin{macrocode}
 \def\bbl at iniskip#1\@@{}%      if starts with ;
@@ -12051,9 +12110,35 @@ help from Bernd Raichle, for which I am grateful.
 % |bbl at font| replaces hardcoded font names inside |\..family| by the
 % corresponding macro |\..default|.
 %
+% At the time of this writing, \textsf{fontspec} shows a warning about
+% there are languages not available, which some people think refers to
+% \babel{}, even if there is nothing wrong. Here is hack to patch
+% \textsf{fontspec} to avoid the misleading message, which is replaced
+% ba a more explanatory one.
+%
 %    \begin{macrocode}
 %<<*Font selection>>
 \bbl at trace{Font handling with fontspec}
+\ifx\ExplSyntaxOn\@undefined\else
+  \ExplSyntaxOn
+  \catcode`\ =10
+  \def\bbl at loadfontspec{%
+    \usepackage{fontspec}%
+    \expandafter
+    \def\csname msg~text~>~fontspec/language-not-exist\endcsname##1##2##3##4{%
+      Font '\l_fontspec_fontname_tl' is using the\\%
+      default features for language '##1'.\\%
+      That's usually fine, because many languages\\%
+      require no specific features, but if the output is\\%
+      not as expected, consider selecting another font.}
+    \expandafter
+    \def\csname msg~text~>~fontspec/no-script\endcsname##1##2##3##4{%
+      Font '\l_fontspec_fontname_tl' is using the\\%
+      default features for script '##2'.\\%
+      That's not always wrong, but if the output is\\%
+      not as expected, consider selecting another font.}}
+  \ExplSyntaxOff
+\fi
 \@onlypreamble\babelfont
 \newcommand\babelfont[2][]{%  1=langs/scripts 2=fam
   \bbl at foreach{#1}{%
@@ -12065,7 +12150,7 @@ help from Bernd Raichle, for which I am grateful.
   \edef\bbl at tempa{#1}%
   \def\bbl at tempb{#2}%  Used by \bbl at bblfont
   \ifx\fontspec\@undefined
-    \usepackage{fontspec}%
+    \bbl at loadfontspec
   \fi
   \EnableBabelHook{babel-fontspec}% Just calls \bbl at switchfont
   \bbl at bblfont}
@@ -13729,6 +13814,9 @@ end
       if not u.find(patt, '()', nil, true) then
         patt = '()' .. patt .. '()'
       end
+      patt = string.gsub(patt, '%(%)%^', '^()')
+      patt = string.gsub(patt, '%$%(%)', '()$')
+      texio.write('***************' .. patt)
       patt = u.gsub(patt, '{(.)}', 
                 function (n)
                   return '%' .. (tonumber(n) and (tonumber(n)+1) or n)
diff --git a/babel.ins b/babel.ins
index 68356b0..722bf5f 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/09/01}
+\def\filedate{2020/09/22}
 \def\batchfile{babel.ins}
 \input docstrip.tex
 
diff --git a/babel.pdf b/babel.pdf
index 7fa3c87..d886155 100644
Binary files a/babel.pdf and b/babel.pdf differ
diff --git a/bbcompat.dtx b/bbcompat.dtx
index a94e017..f8cc770 100644
--- a/bbcompat.dtx
+++ b/bbcompat.dtx
@@ -30,7 +30,7 @@
 %
 % \iffalse
 %<*dtx>
-\ProvidesFile{bbcompat.dtx}[2020/09/01 v3.48]
+\ProvidesFile{bbcompat.dtx}[2020/09/22 v3.48.2138]
 %</dtx>
 %
 %% File 'bbcompat.dtx'





More information about the latex3-commits mailing list.