[latex3-commits] [latex3/babel] main: Support for interchar (WIP). (35eb3d9)
github at latex-project.org
github at latex-project.org
Wed Nov 1 09:17:16 CET 2023
Repository : https://github.com/latex3/babel
On branch : main
Link : https://github.com/latex3/babel/commit/35eb3d94c726ace85a2d25b7935b2ab0dcc85e7a
>---------------------------------------------------------------
commit 35eb3d94c726ace85a2d25b7935b2ab0dcc85e7a
Author: Javier <email at localhost>
Date: Wed Nov 1 09:17:16 2023 +0100
Support for interchar (WIP).
>---------------------------------------------------------------
35eb3d94c726ace85a2d25b7935b2ab0dcc85e7a
README.md | 7 ++--
babel-code.pdf | Bin 635805 -> 639323 bytes
babel.dtx | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
babel.ins | 2 +-
babel.pdf | Bin 413338 -> 414055 bytes
bbcompat.dtx | 2 +-
config-lua.lua | 0
7 files changed, 108 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index 3373157..00d64f9 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
-## Babel 3.96
+## Babel 3.96.30536
-2023-10-25
+2023-11-01
This package manages culturally-determined typographical (and other)
rules, and hyphenation patterns for a wide range of languages. Many
@@ -48,6 +48,9 @@ respective authors.
### Summary of latest changes
```
+3.97 (dev)
+ * Support for 'interchar' (xetex).
+
3.96 2023-10-25
* Added LGI to non-ASCII encodings.
* New macro: \asciiencoding.
diff --git a/babel-code.pdf b/babel-code.pdf
index 7d0d603..c9a67be 100644
Binary files a/babel-code.pdf and b/babel-code.pdf differ
diff --git a/babel.dtx b/babel.dtx
index 8346f33..20501d1 100644
--- a/babel.dtx
+++ b/babel.dtx
@@ -32,7 +32,7 @@
%
% \iffalse
%<*filedriver>
-\ProvidesFile{babel.dtx}[2023/10/25 v3.96 The Babel package]
+\ProvidesFile{babel.dtx}[2023/11/01 v3.96.30536 The Babel package]
\documentclass{ltxdoc}
\GetFileInfo{babel.dtx}
\usepackage{fontspec}
@@ -5426,6 +5426,24 @@ is true with any of these two environment selectors.
Its natural place of use is in hooks or in |\extras|\m{language}.
+\subsection{Support for \xetex{} interchar}
+
+(To be filled.)
+
+\begin{example}
+ Not very useful, but illustrative (taken from the unfortunately
+ obsolete \textsf{interchar} package, by Zou Ho). It colorizes the
+ letters ‘e’ and ‘s’.
+\begin{verbatim}
+\usepackage{color}
+\BabelCharClass{english}{colored}{es}
+\BabelInterChar{english}{default}{colored}{\bgroup\color{red}}
+\BabelInterChar{english}{boundary}{colored}{\bgroup\color{red}}
+\BabelInterChar{english}{colored}{default}{\egroup}
+\BabelInterChar{english}{colored}{boundary}{\egroup}
+\end{verbatim}
+\end{example}
+
\else
\DocInput{babel.dtx}
@@ -5563,8 +5581,8 @@ wouldn’t exist.
% \section{Tools}
%
% \begin{macrocode}
-%<<version=3.96>>
-%<<date=2023/10/25>>
+%<<version=3.96.30536>>
+%<<date=2023/11/01>>
% \end{macrocode}
%
% \textbf{Do not use the following macros in \texttt{ldf} files. They
@@ -5757,7 +5775,7 @@ wouldn’t exist.
\bbl at trim{\expandafter\bbl at kvcmd\expandafter{\bbl at forkv@a}}{#2}{#4}}
% \end{macrocode}
%
-% A \textit{for} loop. Each item (trimmed), is |#1|. It cannot be
+% A \textit{for} loop. Each item (trimmed) is |#1|. It cannot be
% nested (it's doable, but we don't need it).
%
% \begin{macrocode}
@@ -13747,6 +13765,84 @@ wouldn’t exist.
\DisableBabelHook{babel-fontspec}
<@Font selection@>
\def\bbl at provide@extra#1{}
+% \end{macrocode}
+%
+% \section{Support for interchar}
+%
+% WIP.
+%
+% XeTeX predefines some values, so we skip them and define some user
+% names for these global classes.
+%
+% \begin{macrocode}
+\ifnum\xe at alloc@intercharclass<\thr@@
+ \xe at alloc@intercharclass\thr@@
+\fi
+\chardef\bbl at xeclass@default@=\z@
+\chardef\bbl at xeclass@cjkideograms@=\@ne
+\chardef\bbl at xeclass@cjkleftpunctuation@=\tw@
+\chardef\bbl at xeclass@cjkrightpunctuation@=\thr@@
+\chardef\bbl at xeclass@boundary@=4095
+\chardef\bbl at xeclass@ignored@=4096
+% \end{macrocode}
+%
+% The machinery is activated with a hook (enabled only if actually
+% used). Here |\bbl at tempc| is pre-set with |\bbl at usingxeclass|, defined
+% below. The standard mechanism based on |\originalTeX| to save, set
+% and restore values is used. TODO: Single hook or per language?
+%
+% \begin{macrocode}
+\AddBabelHook{babel-interchar}{beforeextras}{%
+ \let\bbl at elt\bbl at setcharclass
+ \@nameuse{bbl at xechars@\languagename}}
+\DisableBabelHook{babel-interchar}
+\def\bbl at setcharclass#1{% TODO. Or defined directly in the hook?
+ \babel at savevariable{\XeTeXcharclass\string`#1}%
+ \XeTeXcharclass\string`#1 \bbl at tempc}
+% \end{macrocode}
+%
+% Now the two user macros. Char classes are declared implicitly, and
+% then the macro to be executed at the |babel-interchar| hook is
+% created. The list of chars to be handled by the hook defined above
+% has internally the form
+% |\bbl at usingxeclass\bbl at xeclass@punct at english||\bbl at elt{.}|%
+% |\bbl at elt{,}| (etc.), where |\bbl at usingxeclass| stores the class to be
+% applied to the subsequent characters. The \cs{ifcat} part deals with
+% the alternative way to enter characters as macros (eg, |\}|).
+%
+% \begin{macrocode}
+\def\BabelCharClass#1#2#3{%
+ \EnableBabelHook{babel-interchar}%
+ \bbl at csarg\newXeTeXintercharclass{xeclass@#2@#1}%
+ \let\bbl at elt\relax
+ \def\bbl at tempb##1{%
+ \ifx##1\@empty\else
+ \bbl at elt{\ifcat\noexpand##1\relax\bbl at stripslash##1\else\string##1\fi}%
+ \expandafter\bbl at tempb
+ \fi}%
+ \bbl at ifunset{bbl at xechars@#1}%
+ {\toks@{%
+ \babel at savevariable\XeTeXinterchartokenstate
+ \XeTeXinterchartokenstate\@ne
+ }}%
+ {\toks@\expandafter\expandafter\expandafter{%
+ \csname bbl at xechars@#1\endcsname}}
+ \bbl at csarg\edef{xechars@#1}{%
+ \the\toks@
+ \bbl at usingxeclass\csname bbl at xeclass@#2@#1\endcsname
+ \bbl at tempb#3\@empty}}
+\protected\def\bbl at usingxeclass#1{\let\bbl at tempc#1}
+% \end{macrocode}
+%
+% And finally, the command with the code to be inserted. If the language
+% doesn’t define a class, then use the global one, as defined above.
+%
+% \begin{macrocode}
+\def\BabelInterChar#1#2#3#4{%
+ \XeTeXinterchartoks
+ \@nameuse{bbl at xeclass@#2@\bbl at ifunset{bbl at xeclass@#2@#1}{}{#1}}
+ \@nameuse{bbl at xeclass@#3@\bbl at ifunset{bbl at xeclass@#3@#1}{}{#1}}
+ = {#4}}
%</xetex>
% \end{macrocode}
%
@@ -14227,7 +14323,7 @@ wouldn’t exist.
end
}
\endgroup
-\ifx\newattribute\@undefined\else
+\ifx\newattribute\@undefined\else % Test for plain
\newattribute\bbl at attr@locale
\directlua{ Babel.attr_locale = luatexbase.registernumber'bbl at attr@locale' }
\AddBabelHook{luatex}{beforeextras}{%
diff --git a/babel.ins b/babel.ins
index b08918a..4a31737 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{2023/10/25}
+\def\filedate{2023/11/01}
\def\batchfile{babel.ins}
\input docstrip.tex
diff --git a/babel.pdf b/babel.pdf
index 4d1628d..6057c98 100644
Binary files a/babel.pdf and b/babel.pdf differ
diff --git a/bbcompat.dtx b/bbcompat.dtx
index e534dab..b55ca1d 100644
--- a/bbcompat.dtx
+++ b/bbcompat.dtx
@@ -30,7 +30,7 @@
%
% \iffalse
%<*dtx>
-\ProvidesFile{bbcompat.dtx}[2023/10/25 v3.96]
+\ProvidesFile{bbcompat.dtx}[2023/11/01 v3.96.30536]
%</dtx>
%
%% File 'bbcompat.dtx'
More information about the latex3-commits
mailing list.