summaryrefslogtreecommitdiff
path: root/macros/latex/required/babel/base/babel.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/required/babel/base/babel.dtx')
-rw-r--r--macros/latex/required/babel/base/babel.dtx201
1 files changed, 101 insertions, 100 deletions
diff --git a/macros/latex/required/babel/base/babel.dtx b/macros/latex/required/babel/base/babel.dtx
index c633f24b9e..3d8eddc505 100644
--- a/macros/latex/required/babel/base/babel.dtx
+++ b/macros/latex/required/babel/base/babel.dtx
@@ -32,7 +32,7 @@
%
% \iffalse
%<*filedriver>
-\ProvidesFile{babel.dtx}[2022/09/17 v3.80 The Babel package]
+\ProvidesFile{babel.dtx}[2022/10/04 v3.81 The Babel package]
\documentclass{ltxdoc}
\GetFileInfo{babel.dtx}
\usepackage{fontspec}
@@ -943,11 +943,9 @@ list of characters as their arguments.
The command |\shorthandoff| sets the |\catcode| for each of the
characters in its argument to other (12); the command |\shorthandon|
sets the |\catcode| to active (13). Both commands only work on `known'
-shorthand characters.
-
-% TODO - Is the following true ????
-% If a character is not known to be a shorthand character its category
-% code will be left unchanged.
+shorthand characters, and an error will be raised otherwise. You can
+check if a character is a shorthand with |\ifbabelshorthand| (see
+below).
\New{3.9a} However, |\shorthandoff| does not behave as
you would expect with characters like |~| or |^|, because they
@@ -2311,19 +2309,6 @@ to select fonts in addition to the three basic families.
\end{warning}
\begin{troubleshooting}
- \trouble{Package fontspec Warning: 'Language 'LANG' not available for
- font 'FONT' with script 'SCRIPT' 'Default' language used instead'}
- \textit{Package fontspec Warning: 'Language 'LANG' not available for
- font 'FONT' with script 'SCRIPT' 'Default' language used instead'}.
-
- \textbf{This is \textit{not} an error.} This warning is shown by
- \textsf{fontspec}, not by \babel. It can be irrelevant for English,
- but not for many other languages, including Urdu and Turkish. This is
- a useful and harmless warning, and if everything is fine with your
- document the best thing you can do is just to ignore it altogether.
-\end{troubleshooting}
-
-\begin{troubleshooting}
\trouble{Package babel Info: The following fonts are not babel
standard families} \textit{Package babel Info: The following fonts
are not babel standard families}.
@@ -2623,7 +2608,8 @@ the script, no matter which language is active. Although somewhat
inconsistent, this makes setting a language up easier in most typical
cases.
-\Describe{onchar=}{\texttt{ids} $\string|$ \texttt{fonts}}
+\Describe{onchar=}{\texttt{ids} $\string|$ \texttt{fonts}
+ $\string|$ \texttt{letters}}
\New{3.38} This option is much like an ‘event’ called when a character
belonging to the script of this locale is found (as its name implies,
it acts on characters, not on spaces). There are currently two
@@ -2634,6 +2620,10 @@ locale (as set with |\babelfont|). This option is not compatible with
|mapfont|. Characters can be added or modified with
|\babelcharproperty|.
+\New{3.81} Option |letters| restricts the ‘actions’ to letters, in the
+\TeX{} sense (i.~e., with catcode 11). Digits and punctuation are then
+considered part of current locale (as set by a selector).
+
\begin{note}
An alternative approach with \luatex{} and Harfbuzz is the font
option |RawFeature={multiscript=auto}|. It does not switch the
@@ -2657,7 +2647,8 @@ Currently used only in Southeast Asian scrips, like Thai. Ignored if 0
See section~\ref{transforms}.
\Describe{justification=}{\texttt{kashida} $\string|$
-\texttt{elongated} $\string|$ \texttt{unhyphenated}}
+\texttt{elongated} $\string|$ \texttt{unhyphenated}
+$\string|$ \texttt{padding}}
\New{3.59} There are currently three options, mainly for the Arabic
script. It sets the linebreaking and justification method, which can be
based on the the \textsc{arabic tatweel} character or in the
@@ -2666,6 +2657,11 @@ explanation see the
\href{https://latex3.github.io/babel/news/whats-new-in-babel-3.59.html}%
{\babel\ site}.
+\New{3.81} The option |padding| has been devised primarily for Tibetan.
+It’s still somewhat experimental. Again, there is an explanation in the
+\href{https://latex3.github.io/babel/news/whats-new-in-babel-3.81.html}%
+ {\babel\ site}.
+
\Describe{linebreaking=}{}
\New{3.59} Just a synonymous for \texttt{justification}.
@@ -4107,6 +4103,10 @@ For example:
\babelcharproperty{`)}{linebreak}{cl} % or id, op, cl, ns, ex, in, hy
\end{verbatim}
+Please, refer to the Unicode standard (Annex \#9 and Annex \#14) for
+the meaning of the available codes. For example, |en| is ‘European
+number’ and |id| is ‘ideographic’.
+
\New{3.39} Another property is |locale|, which adds characters to the
list used by |onchar| in |\babelprovide|, or, if the last argument is
empty, removes them. The last argument is the locale name:
@@ -5176,8 +5176,8 @@ help from Bernd Raichle, for which I am grateful.
% \section{Tools}
%
% \begin{macrocode}
-%<<version=3.80>>
-%<<date=2022/09/17>>
+%<<version=3.81>>
+%<<date=2022/10/04>>
% \end{macrocode}
%
% \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -5304,7 +5304,8 @@ help from Bernd Raichle, for which I am grateful.
% To check if a macro is defined, we create a new macro, which does
% the same as |\@ifundefined|. However, in an $\epsilon$-tex engine,
% it is based on |\ifcsname|, which is more efficient, and does not
-% waste memory.
+% waste memory. Defined inside a group, to avoid \cs{ifcsname} being
+% implicitly set to |\relax| by the |\csname| test.
%
% \begin{macrocode}
\begingroup
@@ -5314,7 +5315,7 @@ help from Bernd Raichle, for which I am grateful.
\else
\expandafter\@secondoftwo
\fi}
- \bbl@ifunset{ifcsname}% TODO. A better test?
+ \bbl@ifunset{ifcsname}%
{}%
{\gdef\bbl@ifunset#1{%
\ifcsname#1\endcsname
@@ -6135,7 +6136,6 @@ help from Bernd Raichle, for which I am grateful.
request the languages explicitly}%
{See the manual for further details.}%
\fi
-% TODO. Option to search if loaded, with \LocaleForEach
\let\bbl@auxname\languagename % Still necessary. TODO
\bbl@ifunset{bbl@bcp@map@\languagename}{}% Move uplevel??
{\edef\languagename{\@nameuse{bbl@bcp@map@\languagename}}}%
@@ -6427,19 +6427,8 @@ help from Bernd Raichle, for which I am grateful.
% TODO. name@map must be here?
\bbl@provide@locale
\bbl@iflanguage\languagename{%
- \expandafter\ifx\csname date\languagename\endcsname\relax
- \bbl@error
- {Unknown language '\languagename'. Either you have\\%
- misspelled its name, it has not been installed,\\%
- or you requested it in a previous run. Fix its name,\\%
- install it or just rerun the file, respectively. In\\%
- some cases, you may need to remove the aux file}%
- {You may proceed, but expect wrong results}%
- \else
- % set type
- \let\bbl@select@type\z@
- \expandafter\bbl@switch\expandafter{\languagename}%
- \fi}}
+ \let\bbl@select@type\z@
+ \expandafter\bbl@switch\expandafter{\languagename}}}
\def\babel@aux#1#2{%
\select@language{#1}%
\bbl@foreach\BabelContentsFiles{% \relax -> don't assume vertical mode
@@ -6493,7 +6482,7 @@ help from Bernd Raichle, for which I am grateful.
\bbl@id@assign
% switch captions, date
% No text is supposed to be added here, so we remove any
- % spurious spaces.
+ % spurious spaces.
\bbl@bsphack
\ifcase\bbl@select@type
\csname captions#1\endcsname\relax
@@ -6540,9 +6529,10 @@ help from Bernd Raichle, for which I am grateful.
\bbl@xin@{/u}{/\bbl@tempa}%
\ifin@\else\bbl@xin@{/e}{/\bbl@tempa}\fi % elongated forms
\ifin@\else\bbl@xin@{/k}{/\bbl@tempa}\fi % only kashida
+ \ifin@\else\bbl@xin@{/p}{/\bbl@tempa}\fi % padding (eg, Tibetan)
\ifin@\else\bbl@xin@{/v}{/\bbl@tempa}\fi % variable font
\ifin@
- % unhyphenated/kashida/elongated = allow stretching
+ % unhyphenated/kashida/elongated/padding = allow stretching
\language\l@unhyphenated
\babel@savevariable\emergencystretch
\emergencystretch\maxdimen
@@ -6709,17 +6699,6 @@ help from Bernd Raichle, for which I am grateful.
% TODO. name@map here?
\bbl@provide@locale
\bbl@iflanguage\languagename{%
- \expandafter\ifx\csname date\languagename\endcsname\relax
- \bbl@warning % TODO - why a warning, not an error?
- {Unknown language '#1'. Either you have\\%
- misspelled its name, it has not been installed,\\%
- or you requested it in a previous run. Fix its name,\\%
- install it or just rerun the file, respectively. In\\%
- some cases, you may need to remove the aux file.\\%
- I'll proceed, but expect wrong results.\\%
- Reported}%
- \fi
- % set type
\let\bbl@select@type\@ne
\expandafter\bbl@switch\expandafter{\languagename}}}
% \end{macrocode}
@@ -6944,7 +6923,7 @@ help from Bernd Raichle, for which I am grateful.
\@nameuse{#2}%
\edef\bbl@tempa{#1}%
\bbl@sreplace\bbl@tempa{name}{}%
- \bbl@warning{% TODO.
+ \bbl@warning{%
\@backslashchar#1 not set for '\languagename'. Please,\\%
define it after the language has been loaded\\%
(typically in the preamble) with:\\%
@@ -7039,8 +7018,7 @@ help from Bernd Raichle, for which I am grateful.
% The macro |\initiate@active@char| below takes all the necessary
% actions to make its argument a shorthand character. The real work
% is performed once for each character. But first we define a little
-% tool. TODO. Always used with additional expansions. Move them here?
-% Move the macro to basic?
+% tool.
%
% \begin{macrocode}
\def\bbl@withactive#1#2{%
@@ -7175,7 +7153,7 @@ help from Bernd Raichle, for which I am grateful.
%
% \begin{macrocode}
\bbl@trace{Defining babelensure}
-\newcommand\babelensure[2][]{% TODO - revise test files
+\newcommand\babelensure[2][]{%
\AddBabelHook{babel-ensure}{afterextras}{%
\ifcase\bbl@select@type
\bbl@cl{e}%
@@ -8695,21 +8673,12 @@ help from Bernd Raichle, for which I am grateful.
%
% \paragraph{Tools}
%
-% But first, a couple of tools. The first one makes global a local
-% variable. This is not the best solution, but it works.
+% But first, a tool. It makes global a local variable. This is not the
+% best solution, but it works.
%
% \begin{macrocode}
\bbl@trace{Multiencoding strings}
\def\bbl@toglobal#1{\global\let#1#1}
-\def\bbl@recatcode#1{% TODO. Used only once?
- \@tempcnta="7F
- \def\bbl@tempa{%
- \ifnum\@tempcnta>"FF\else
- \catcode\@tempcnta=#1\relax
- \advance\@tempcnta\@ne
- \expandafter\bbl@tempa
- \fi}%
- \bbl@tempa}
% \end{macrocode}
%
% The second one. We need to patch |\@uclclist|, but it is done once
@@ -8789,7 +8758,14 @@ help from Bernd Raichle, for which I am grateful.
\@onlypreamble\StartBabelCommands
\def\StartBabelCommands{%
\begingroup
- \bbl@recatcode{11}%
+ \@tempcnta="7F
+ \def\bbl@tempa{%
+ \ifnum\@tempcnta>"FF\else
+ \catcode\@tempcnta=11
+ \advance\@tempcnta\@ne
+ \expandafter\bbl@tempa
+ \fi}%
+ \bbl@tempa
<@Macros local to BabelCommands@>
\def\bbl@provstring##1##2{%
\providecommand##1{##2}%
@@ -9119,7 +9095,7 @@ help from Bernd Raichle, for which I am grateful.
% separates these two steps.
%
% \begin{macrocode}
-\newcommand\setlocalecaption{% TODO. Catch typos. What about ensure?
+\newcommand\setlocalecaption{% TODO. Catch typos.
\@ifstar\bbl@setcaption@s\bbl@setcaption@x}
\def\bbl@setcaption@x#1#2#3{% language caption-name string
\bbl@trim@def\bbl@tempa{#2}%
@@ -9855,7 +9831,15 @@ help from Bernd Raichle, for which I am grateful.
Babel.linebreaking.add_before(Babel.locale_map)
Babel.loc_to_scr = {}
Babel.chr_to_loc = Babel.chr_to_loc or {}
- end}%
+ end
+ Babel.locale_props[\the\localeid].letters = false
+ }%
+ \bbl@xin@{ letters }{ \bbl@KVP@onchar\space}%
+ \ifin@
+ \directlua{
+ Babel.locale_props[\the\localeid].letters = true
+ }%
+ \fi
\bbl@xin@{ ids }{ \bbl@KVP@onchar\space}%
\ifin@
\ifx\bbl@starthyphens\@undefined % Needed if no explicit selection
@@ -9958,7 +9942,8 @@ help from Bernd Raichle, for which I am grateful.
\let\bbl@KVP@linebreaking\bbl@KVP@justification
\fi
\ifx\bbl@KVP@linebreaking\@nnil\else
- \bbl@xin@{,\bbl@KVP@linebreaking,}{,elongated,kashida,cjk,unhyphenated,}%
+ \bbl@xin@{,\bbl@KVP@linebreaking,}%
+ {,elongated,kashida,cjk,padding,unhyphenated,}%
\ifin@
\bbl@csarg\xdef
{lnbrk@\languagename}{\expandafter\@car\bbl@KVP@linebreaking\@nil}%
@@ -9967,6 +9952,8 @@ help from Bernd Raichle, for which I am grateful.
\bbl@xin@{/e}{/\bbl@cl{lnbrk}}%
\ifin@\else\bbl@xin@{/k}{/\bbl@cl{lnbrk}}\fi
\ifin@\bbl@arabicjust\fi
+ \bbl@xin@{/p}{/\bbl@cl{lnbrk}}%
+ \ifin@\AtBeginDocument{\bbl@tibetanjust}\fi
% == Line breaking: hyphenate.other.(locale|script) ==
\ifx\bbl@lbkflag\@empty
\bbl@ifunset{bbl@hyotl@\languagename}{}%
@@ -12058,9 +12045,7 @@ help from Bernd Raichle, for which I am grateful.
\ifx\RTLfootnotetext\@undefined
\AtEndOfPackage{%
\EnableBabelHook{babel-bidi}%
- \ifx\fontspec\@undefined
- \bbl@loadfontspec % bidi needs fontspec
- \fi
+ \bbl@loadfontspec % bidi needs fontspec
\usepackage#1{bidi}}%
\fi}
\ifnum\bbl@bidimode>200
@@ -12940,24 +12925,17 @@ help from Bernd Raichle, for which I am grateful.
%<<*Font selection>>
\bbl@trace{Font handling with fontspec}
\ifx\ExplSyntaxOn\@undefined\else
- \ExplSyntaxOn
- \catcode`\ =10
+ \def\bbl@fs@warn@nx#1#2{% \bbl@tempfs is the original macro
+ \in@{,#1,}{,no-script,language-not-exist,}%
+ \ifin@\else\bbl@tempfs@nx{#1}{#2}\fi}
+ \def\bbl@fs@warn@nxx#1#2#3{%
+ \in@{,#1,}{,no-script,language-not-exist,}%
+ \ifin@\else\bbl@tempfs@nxx{#1}{#2}{#3}\fi}
\def\bbl@loadfontspec{%
- \usepackage{fontspec}% TODO. Apply patch always
- \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
+ \let\bbl@loadfontspec\relax
+ \ifx\fontspec\@undefined
+ \usepackage{fontspec}%
+ \fi}%
\fi
\@onlypreamble\babelfont
\newcommand\babelfont[2][]{% 1=langs/scripts 2=fam
@@ -12969,9 +12947,7 @@ help from Bernd Raichle, for which I am grateful.
\fi}%
\edef\bbl@tempa{#1}%
\def\bbl@tempb{#2}% Used by \bbl@bblfont
- \ifx\fontspec\@undefined
- \bbl@loadfontspec
- \fi
+ \bbl@loadfontspec
\EnableBabelHook{babel-fontspec}% Just calls \bbl@switchfont
\bbl@bblfont}
\newcommand\bbl@bblfont[2][]{% 1=features 2=fontname, @font=rm|sf|tt
@@ -13126,8 +13102,15 @@ help from Bernd Raichle, for which I am grateful.
{\\\newfontscript{\bbl@cl{sname}}{\bbl@cl{sotf}}}%
\<keys_if_exist:nnF>{fontspec-opentype}{Language/\bbl@cl{lname}}%
{\\\newfontlanguage{\bbl@cl{lname}}{\bbl@cl{lotf}}}%
+ \let\\\bbl@tempfs@nx\<__fontspec_warning:nx>%
+ \let\<__fontspec_warning:nx>\\\bbl@fs@warn@nx
+ \let\\\bbl@tempfs@nxx\<__fontspec_warning:nxx>%
+ \let\<__fontspec_warning:nxx>\\\bbl@fs@warn@nxx
\\\renewfontfamily\\#4%
[\bbl@cl{lsys},#2]}{#3}% ie \bbl@exp{..}{#3}
+ \bbl@exp{%
+ \let\<__fontspec_warning:nx>\\\bbl@tempfs@nx
+ \let\<__fontspec_warning:nxx>\\\bbl@tempfs@nxx}%
\begingroup
#4%
\xdef#1{\f@family}% eg, \bbl@rmdflt@lang{FreeSerif(0)}
@@ -14378,6 +14361,11 @@ function Babel.locale_map(head)
(item.char >= 0x1DC0 and item.char <= 0x1DFF) then
toloc = toloc_save
end
+ if toloc and Babel.locale_props[toloc] and
+ Babel.locale_props[toloc].letters and
+ tex.getcatcode(item.char) \string~= 11 then
+ toloc = nil
+ end
if toloc and toloc > -1 then
if Babel.locale_props[toloc].lg then
item.lang = Babel.locale_props[toloc].lg
@@ -14388,7 +14376,7 @@ function Babel.locale_map(head)
end
toloc_save = toloc
end
- elseif not inmath and item.id == 7 then
+ elseif not inmath and item.id == 7 then % Apply recursively
item.replace = item.replace and Babel.locale_map(item.replace)
item.pre = item.pre and Babel.locale_map(item.pre)
item.post = item.post and Babel.locale_map(item.post)
@@ -14486,10 +14474,11 @@ end
\@ifnextchar[{\bbl@settransform{0}}{\bbl@settransform{0}[]}}
\gdef\babelposthyphenation{&%
\@ifnextchar[{\bbl@settransform{1}}{\bbl@settransform{1}[]}}
+\gdef\bbl@postlinebreak{\bbl@settransform{2}[]} &% WIP
\gdef\bbl@settransform#1[#2]#3#4#5{&%
\ifcase#1
\bbl@activateprehyphen
- \else
+ \or
\bbl@activateposthyphen
\fi
\begingroup
@@ -14505,7 +14494,7 @@ end
rep = rep:gsub('^%s*(remove)%s*$', 'remove = true')
rep = rep:gsub('^%s*(insert)%s*,', 'insert = true, ')
rep = rep:gsub('(string)%s*=%s*([^%s,]*)', Babel.capture_func)
- if #1 == 0 then
+ if #1 == 0 or #1 == 2 then
rep = rep:gsub('(space)%s*=%s*([%d%.]+)%s+([%d%.]+)%s+([%d%.]+)',
'space = {' .. '%2, %3, %4' .. '}')
rep = rep:gsub('(spacefactor)%s*=%s*([%d%.]+)%s+([%d%.]+)%s+([%d%.]+)',
@@ -14518,6 +14507,16 @@ end
end
tex.print([[\string\babeltempa{{]] .. rep .. [[}}]])
}}}&%
+ \bbl@foreach\babeltempb{&%
+ \bbl@forkv{{##1}}{&%
+ \in@{,####1,}{,nil,step,data,remove,insert,string,no,pre,&%
+ no,post,penalty,kashida,space,spacefactor,}&%
+ \ifin@\else
+ \bbl@error
+ {Bad option '####1' in a transform.\\&%
+ I’ll ignore it but expect more errors}&%
+ {See the manual for further info.}&%
+ \fi}}&%
\let\bbl@kv@attribute\relax
\let\bbl@kv@label\relax
\bbl@forkv{#2}{\bbl@csarg\edef{kv@##1}{##2}}&%
@@ -14528,7 +14527,7 @@ end
local lbkr = Babel.linebreaking.replacements[#1]
local u = unicode.utf8
local id, attr, label
- if #1 == 0 then
+ if #1 == 0 or #1 == 2 then
id = \the\csname bbl@id@@#3\endcsname\space
else
id = \the\csname l@#3\endcsname\space
@@ -14543,7 +14542,7 @@ end
\fi
&% Convert pattern:
local patt = string.gsub([==[#4]==], '%s', '')
- if #1 == 0 then
+ if #1 == 0 or #1 == 2 then
patt = string.gsub(patt, '|', ' ')
end
if not u.find(patt, '()', nil, true) then
@@ -15078,8 +15077,9 @@ end
% \begin{macrocode}
%<*transforms>
Babel.linebreaking.replacements = {}
-Babel.linebreaking.replacements[0] = {} -- pre
+Babel.linebreaking.replacements[0] = {} -- pre
Babel.linebreaking.replacements[1] = {} -- post
+Babel.linebreaking.replacements[2] = {} -- post-line WIP
-- Discretionaries contain strings as nodes
function Babel.str_to_nodes(fn, matches, base)
@@ -15231,6 +15231,7 @@ Babel.us_char = string.char(31)
function Babel.hyphenate_replace(head, mode)
local u = unicode.utf8
local lbkr = Babel.linebreaking.replacements[mode]
+ if mode == 2 then mode = 0 end -- WIP
local word_head = head