summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/babel/babel.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/babel/babel.dtx')
-rw-r--r--Master/texmf-dist/source/latex/babel/babel.dtx810
1 files changed, 680 insertions, 130 deletions
diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx
index b11d3d5c99d..3d4e18dab31 100644
--- a/Master/texmf-dist/source/latex/babel/babel.dtx
+++ b/Master/texmf-dist/source/latex/babel/babel.dtx
@@ -3,7 +3,7 @@
%%
%% Copyright (C) 2012-2018 Javier Bezos and Johannes L. Braams.
%% Copyright (C) 1989-2012 Johannes L. Braams and
-%% any individual authors listed elsewhere in this file.
+%% any individual authors listed elsewhere in this file.
%% All rights reserved.
%%
%% This file is part of the Babel system.
@@ -31,7 +31,7 @@
%
% \iffalse
%<*filedriver>
-\ProvidesFile{babel.dtx}[2018/02/14 v3.18 The Babel package]
+\ProvidesFile{babel.dtx}[2018/04/25 v3.19 The Babel package]
\documentclass{ltxdoc}
\GetFileInfo{babel.dtx}
\usepackage{fontspec}
@@ -85,6 +85,7 @@
\newtheorem{warning}{Warning}
\newtheorem{note}{Note}
\newtheorem{example}{Example}
+\newtheorem{troubleshooting}{Troubleshooting}
\let\bblxv\verbatim
\let\bblexv\endverbatim
\def\verbatim{\begin{shaded*}\bblxv\vskip-\baselineskip\vskip2.5\parsep}
@@ -199,7 +200,7 @@ Javier Bezos
be kept in mind that they were designed for American tastes and
typography. At one time they even contained a number of hard-wired
texts.
-
+
This manual describes \babel{}, a package that makes use of the
capabilities of \TeX\ version 3 and, to some extent, \xetex{} and
\luatex, to provide an environment in which documents can be typeset
@@ -256,8 +257,8 @@ purpose, namely, passing that language as an optional argument. In
addition, you may want to set the font and input encodings.
\begin{example}
- Here is a simple full example for “traditional” \TeX{} engines (see
- below for \xetex{} and \luatex{}). The packages |fontenc| and
+ Here is a simple full example for “traditional” \TeX{} engines
+ (see below for \xetex{} and \luatex{}). The packages |fontenc| and
|inputenc| do not belong to \babel, but they are included in the
example because typically you will need them:
\begin{verbatim}
@@ -275,10 +276,15 @@ Plus ça change, plus c'est la même chose!
\end{document}
\end{verbatim}
\end{example}
-\begin{warning}
-A common source of trouble is a wrong setting of the input
-encoding. Make sure you set the encoding actually used by your editor.
-\end{warning}
+\begin{troubleshooting}
+\trouble{Paragraph ended before \textbackslash UTFviii@three@octets was complete}
+A common source of trouble is a wrong setting of the input encoding.
+Very often you will get the following somewhat cryptic error:
+\begin{verbatim}
+! Paragraph ended before \UTFviii@three@octets was complete.
+\end{verbatim}
+Make sure you set the encoding actually used by your editor.
+\end{troubleshooting}
Another approach is making the language (\Lopt{french} in the example)
a global option in order to let other packages detect and use it:
@@ -303,6 +309,26 @@ the option and will be able to use it.
specific languages for further info.
\end{note}
+\begin{troubleshooting}
+ The following warning is about hyphenation patterns, which are
+ not under the direct control of \babel:
+\trouble{No hyphenation patterns were preloaded for (babel) the
+ language `LANG' into the format}
+\begin{verbatim}
+Package babel Warning: No hyphenation patterns were preloaded for
+(babel) the language `LANG' into the format.
+(babel) Please, configure your TeX system to add them and
+(babel) rebuild the format. Now I will use the patterns
+(babel) preloaded for \language=0 instead on input line 57.
+\end{verbatim}
+ The document will be typeset, but very likely the text will not be
+ correctly hyphenated. Some languages may be raising this warning
+ wrongly (because they are not hyphenated); it is a bug to be fixed
+ -- just ignore it. See the manual of your distribution (Mac\TeX,
+ Mik\TeX, \TeX Live, etc.) for further info about how to configure
+ it.
+\end{troubleshooting}
+
\subsection{Multilingual documents}
In multilingual documents, just use several options. The last one is
@@ -476,24 +502,6 @@ _\usepackage[russian]{babel}_
all, and therefore you removed it from the option list). In most
cases, the error vanishes when the document is typeset again, but in
more severe ones you will need to remove the |aux| file.
-
-\item The following warning is about hyphenation patterns, which are
- not under the direct control of \babel:
-\trouble{No hyphenation patterns were preloaded for (babel) the
- language `LANG' into the format}
-\begin{verbatim}
-Package babel Warning: No hyphenation patterns were preloaded for
-(babel) the language `LANG' into the format.
-(babel) Please, configure your TeX system to add them and
-(babel) rebuild the format. Now I will use the patterns
-(babel) preloaded for \language=0 instead on input line 57.
-\end{verbatim}
- The document will be typeset, but very likely the text will not be
- correctly hyphenated. Some languages may be raising this warning
- wrongly (because they are not hyphenated); it is a bug to be fixed
- -- just ignore it. See the manual of your distribution (Mac\TeX,
- Mik\TeX, \TeX Live, etc.) for further info about how to configure
- it.
\end{itemize}
\subsection{Plain}
@@ -522,7 +530,7 @@ necessary. The environments |otherlanguage|, |otherlanguage*| and
The main language is selected automatically when the |document|
environment begins.
-\Describe\selectlanguage{\marg{language}}
+\Describe{\selectlanguage}{\marg{language}}
When a user wants to switch from one language to another he can
do so using the macro |\selectlanguage|. This macro takes the
language, defined previously by a language definition file, as
@@ -552,7 +560,7 @@ This command can be used as environment, too.
code with an additional grouping level.
\end{warning}
-\Describe\foreignlanguage{\marg{language}\marg{text}}
+\Describe{\foreignlanguage}{\marg{language}\marg{text}}
The command |\foreignlanguage| takes two arguments; the second
argument is a phrase to be typeset according to the rules of the
language named in its first one. This command (1) only switches the
@@ -593,41 +601,40 @@ environment are \textit{not} ignored.
This environment was originally intended for intermixing left-to-right
typesetting with right-to-left typesetting in engines not supporting a
-change in the writing direction inside a line. However, by default it never
-complied with the documented behavior and it is just a version as
+change in the writing direction inside a line. However, by default it
+never complied with the documented behavior and it is just a version as
environment of |\foreignlanguage|.
\Describe{\begin\menv{hyphenrules}}{\marg{language}\Eenv{hyphenrules}}
-The environment \Lenv{hyphenrules} can be used to select \emph{only}
-the hyphenation rules to be used (it can be used as command,
-too). This can for instance be used to select `nohyphenation',
-provided that in \file{language.dat} the `language'
-\textsf{nohyphenation} is defined by loading \file{zerohyph.tex}. It
-deactivates language shorthands, too (but not user shorthands).
+The environment \Lenv{hyphenrules} can be used to select \emph{only} the
+hyphenation rules to be used (it can be used as command, too). This can
+for instance be used to select `nohyphenation', provided that in
+\file{language.dat} the `language' \textsf{nohyphenation} is defined by
+loading \file{zerohyph.tex}. It deactivates language shorthands, too
+(but not user shorthands).
Except for these simple uses, |hyphenrules| is discouraged and
-|otherlanguage*| (the starred version) is preferred, as the former
-does not take into account possible changes in encodings of characters
-like, say, |'| done by some languages (eg, \textsf{italian},
-\textsf{french}, \textsf{ukraineb}). To set hyphenation exceptions,
-use |\babelhyphenation| (see below).
+|otherlanguage*| (the starred version) is preferred, as the former does
+not take into account possible changes in encodings of characters like,
+say, |'| done by some languages (eg, \textsf{italian}, \textsf{french},
+\textsf{ukraineb}). To set hyphenation exceptions, use
+|\babelhyphenation| (see below).
\subsection{More on selection}
-\Describe\babeltags{\char`\{\m{tag1} \texttt{=} \m{language1}, \m{tag2}
+\Describe{\babeltags}{\char`\{\m{tag1} \texttt{=} \m{language1}, \m{tag2}
\texttt{=} \m{language2}, \dots\char`\}}
-\New{3.9i} In multilingual documents with many language switches
-the commands above can be cumbersome. With this tool shorter names can
-be defined. It adds nothing really new -- it is just syntactical
-sugar.
+\New{3.9i} In multilingual documents with many language switches the
+commands above can be cumbersome. With this tool shorter names can be
+defined. It adds nothing really new -- it is just syntactical sugar.
It defines |\text|\m{tag1}\marg{text} to be
|\foreignlanguage|\marg{language1}\marg{text}, and |\begin|\marg{tag1}
to be |\begin{otherlanguage*}|\marg{language1}, and so on. Note
|\|\m{tag1} is also allowed, but remember to set it locally inside a
-group.
+group.
\begin{example}
With
\begin{verbatim}
@@ -659,7 +666,7 @@ text
|\foreignlanguage| is).
\end{note}
-\Describe\babelensure{|[include=|\m{commands}|,exclude=|\m{commands}%
+\Describe{\babelensure}{|[include=|\m{commands}|,exclude=|\m{commands}%
|,fontenc=|\m{encoding}|]|\marg{language}}
\New{3.9i} Except in a few languages, like \textsf{russian},
@@ -2205,13 +2212,18 @@ differ in the way `weak' numeric characters are ordered (eg, Arabic
There are some package options controlling bidi writing.
-\Describe{bidi=}{\texttt{default} $\string|$ \texttt{basic-r}}
+\Describe{bidi=}{\texttt{default} $\string|$ \texttt{basic-r}
+ $\string|$ \texttt{basic}}
\New{3.14} Selects the bidi algorithm to be used. With |default| the
bidi mechanism is just activated (by default it is not), but every
change must by marked up. In \xetex{} and \pdftex{} this is the only
option. In \luatex, |basic-r| provides a simple and fast method for R
text, which handles numbers and unmarked L text within an R context.
+\New{3.19} Finally, |basic| suports both L and R text (see
+\ref{bidibasic}). (They are named \texttt{basic} mainly because they
+only consider the intrinsic direction of scripts and weak
+directionality.)
\begin{example}
The following text comes from the Arabic Wikipedia (article about
@@ -2258,57 +2270,87 @@ _\babelprovide[import=ar, main]{arabic}_
\texttt{contents} $\string|$
\texttt{footnotes} $\string|$
\texttt{captions} $\string|$
- \texttt{columns}}
+ \texttt{columns} $\string|$
+ \texttt{extras}}
-\New{3.16} \textit{To be expanded}. Selects which layout elements are
-adapted in bidi documents. You may use several options with a
-comma-separated list (eg, |layout=counters.contents.sectioning|). This
-list will be expanded in future releases (tables, captions,
-etc.). Note not all options are required by all engines.
+\New{3.16} \textit{To be expanded}. Selects which layout elements are
+adapted in bidi documents, including some text elements. You may use
+several options with a comma-separated list (eg,
+|layout=counters.contents.sectioning|). This list will be expanded in
+future releases (tables, captions, etc.). Note not all options are
+required by all engines.
\begin{description}
\renewcommand\makelabel[1]{%
\hspace\labelsep\normalfont\ttfamily\color{thered}#1}
\itemsep=-\parskip
+
\item[sectioning] makes sure the sectioning macros are typeset in the
main language, but with the title text in the current language (see
- below |\BabelPatchSection| for further details);
-\item[counters] required in all engines to reorder correctly section
- numbers and the like (eg, \m{subsection}.\m{section}); required in
- \xetex{} and \pdftex{} for counters in general, as well as in
- \luatex{} with |bidi=default|; required in \luatex{} for numeric
- footnote marks $>$9;
-\item[lists] required in \xetex{} and \pdftex{}, but only in
- multilingual documents in \luatex{};
+ below |\BabelPatchSection| for further details).
+
+\item[counters] required in all engines (except \luatex{} with
+ |bidi=basic|) to reorder section numbers and the like (eg,
+ \m{subsection}.\m{section}); required in \xetex{} and \pdftex{} for
+ counters in general, as well as in \luatex{} with |bidi=default|;
+ required in \luatex{} for numeric footnote marks $>$9 with
+ |bidi=basic-r| (but \textit{not} with |bidi=basic|); note, however,
+ it could depend on the counter format.
+
+ With |counters|, |\arabic| is not only considered L text always (with
+ |\babelsublr|, see below), but also an ``isolated'' block which does
+ not interact with the surrounding chars. So, while |1.2| in R text is
+ rendered in that order with |bidi=basic| (as a decimal number), in
+ |\arabic{c1}.\arabic{c2}| the visual order is \textit{c2.c1}. Of
+ course, you may always adjust the order by changing the language, if
+ necessary.\footnote{Next on the roadmap are counters and numeral
+ systems in general. Expect some minor readjustments.}
+
+\item[lists] required in \xetex{} and \pdftex{}, but only in
+ multilingual documents in \luatex{}.
+
\item[contents] required in \xetex{} and \pdftex{}; in \luatex{}
- toc entries are R by default if the main language is R;
+ toc entries are R by default if the main language is R.
+
\item[columns] required in \xetex{} and \pdftex{} to reverse the
column order (currently only the standard two column mode); in
\luatex{} they are R by default if the main language is R (including
- \textsf{multicol});
+ \textsf{multicol}).
+
\item[footnotes] not required in monolingual documents, but it may be
useful in multilingual documents in all engines; you may use
alternatively |\BabelFootnote| described below (what this options
does exactly is also explained there).
+
\item[captions] is similar to |sectioning|, but for |\caption|; not
required in monolingual documents with \luatex{}, but may be
required in \xetex{} and \pdftex{} in some styles (support for the
- latter two engines is still experimental); \New{3.18}
+ latter two engines is still experimental) \New{3.18}.
+
\item[tabular] required in \luatex{} for R |tabular| (it has been
tested only with simple tables, so expect some readjustments in the
future); ignored in \pdftex{} or \xetex{} (which will not support a
- similar option in the short term). \New{3.18}
+ similar option in the short term) \New{3.18},
+
+\item[extras] is used for miscelaneous readjustments which do not fit into
+ the previous groups. Currently redefines in \luatex{} |\underline| and
+ |LaTeX2e| \New{3.19}.
\end{description}
\Describe{\babelsublr}{\marg{lr-text}}
-Digits in \pdftex{} must be marked up explicitly (unlike \luatex{}
-with |bidi=basic-r| and, usually, \xetex{}). Mainly for it (although
-available in all engines, because it can be useful), this command is
-provided to set \marg{lr-text} in L mode. It's intended for what
-Unicode calls weak characters, because words are best set with the
+Digits in \pdftex{} must be marked up explicitly (unlike \luatex{} with
+|bidi=basic-r| and, usually, \xetex{}). This command is provided to set
+\marg{lr-text} in L mode if necessary. It's intended for what Unicode
+calls weak characters, because words are best set with the
corresponding language. For this reason, there is no |rl| counterpart.
+Any |\babelsublr| in \textit{explicit} L mode is ignored. However, with
+|bidi=basic| and \textit{implicit} L, it first returns to R and then
+switches to explicit L. This is by design to provide the proper behaviour
+in the most usual cases — but if you need to use |\ref| in an L text
+inside R, it must be marked up explictly.
+
\Describe{\BabelPatchSection}{\marg{section-name}}
Mainly for bidi text, but it could be useful in other
@@ -2468,10 +2510,10 @@ to you to make sure no toc type is duplicated).
\subsection{Languages supported by \babel}
-In the following table most of the languages supported by \babel\ are
-listed, together with the names of the option which you can load
-\babel\ with for each language. Note this list is open and the
-current options may be different. It does not include |ini| files.
+In the following table most of the languages supported by \babel{} with
+and |.ldf| file are listed, together with the names of the option which
+you can load \babel\ with for each language. Note this list is open and
+the current options may be different. It does not include |ini| files.
\begin{description}
\itemsep=-\parskip
@@ -2702,14 +2744,74 @@ chapters), in Hungarian ``from (1)'' is ``(1)-b\H{o}l'', but ``from
``3.$^{\textrm{\scriptsize er}}$ \'{\i}tem'', and so on.
\subsection{Tentative and experimental code}
+\label{bidibasic}
+
+\textbf{Option \texttt{bidi=basic}}
+
+\New{3.19} With this package option \textit{both} L and R text can be
+mixed without explicit markup (the latter will be only necessary in
+some special cases where the Unicode algorithm fails). It is used much
+like |bidi=basic-r|, but with R text inside L text you may want to map
+the font so that the correct features are in force. This is accomplised
+with an option in |\babelprovide|, as illustrated:
+ \begingroup
+% If you are looking at the code to see how it has been written, you
+% will be disappointed :-). The following example is built ad hoc to
+% emulate the final result to avoid dependencies, and therefore it's
+% not "real" code.
+\setmonofont[Scale=.87,Script=Arabic]{DejaVu Sans Mono} \catcode`@=13
+\def@#1{\ifcase#1\relax \egroup \or \bgroup\textdir TRT \else
+\bgroup\textdir TLT \pardir TLT \fi}
+\begin{verbatim}
+\documentclass{book}
-Handling of \textbf{``Unicode'' fonts} is problematic. There is
-\textsf{fontspec}, but special macros are required (not only the NFSS
-ones) and it doesn't provide ``orthogonal axis'' for features,
-including those related to the language (mainly language and
-script). A couple of tentative macros, were provided by \babel{}
-($\ge$3.9g) with a partial solution. These macros are now deprecated
--- use |\babelfont|.
+\usepackage[english, _bidi=basic_]{babel}
+
+\babelprovide[_mapfont=direction_]{arabic}
+
+\babelfont{rm}{Crimson}
+\babelfont[*arabic]{rm}{FreeSerif}
+
+\begin{document}
+
+Most Arabic speakers consider the two varieties to be two registers
+of one language, although the two registers can be referred to in
+Arabic as @1فصحى العصر@0 \textit{fuṣḥā l-ʻaṣr} (MSA) and
+@1فصحى التراث@0 \textit{fuṣḥā t-turāth} (CA).
+
+\end{document}
+\end{verbatim}
+\endgroup
+What |mapfont=direction| means is, ‘when a character has the same
+direction as the script for the “provided” language (|arabic| in
+this case), then change its font to that set for this language’ (here
+defined via |*arabic|, because Crimson does not provide Arabic
+letters).
+
+Boxes are “black boxes”. Numbers inside an |\hbox| (as for example
+in a |\ref|) do not know anything about the surrounding chars. So,
+|\ref{A}-\ref{B}| are not rendered in the visual order A-B, but in the
+wrong one B-A (because the hyphen does not “see” the digits inside the
+|\hbox|’es). If you need |\ref| ranges, the best option is to define
+a dedicated macro like this (to avoid explicit direction changes in the
+body; here |\texthe| must be defined to select the main language):
+\begin{verbatim}
+\newcommand\refrange[2]{\babelsublr{\texthe{\ref{#1}}-\texthe{\ref{#2}}}}
+\end{verbatim}
+
+In a future a more complete method, reading recursively boxed text, may
+be added.
+
+There are samples on GitHub, under \texttt{/required/babel/samples}:
+|lua-bidibasic.tex| and |lua-secenum.tex|.
+
+\medskip
+\textbf{Old stuff}
+
+A couple of tentative macros were provided by \babel{} ($\ge$3.9g) with
+a partial solution for ``Unicode'' fonts. These macros are now
+deprecated --- use |\babelfont|. A short description follows, for
+reference:
\begin{itemize}
\item |\babelFSstore|\marg{babel-language} sets the current three
basic families (rm, sf, tt) as the default for the language
@@ -2726,11 +2828,12 @@ So, for example:
\babelFSfeatures{turkish}{Language=Turkish}
\end{verbatim}
-\textbf{Bidi writing} is taking its \textit{first steps}.
-\textit{First steps} means exactly that. For example, in \luatex{} any
-Arabic text must be marked up explicitly in L mode. On the other hand,
-\xetex{} poses quite different challenges. Document layout (lists,
-footnotes, etc.) is not touched at all.
+\medskip
+\textbf{Bidi writing} in \luatex{} is under development, but a basic
+implementation is almost finished. On the other hand, in \xetex{} it is
+taking its first steps. The latter engine poses quite different
+challenges. An option to manage document layout in \luatex{} (lists,
+footnotes, etc.) is almost finished, but \xetex{} required more work.
See the code section for |\foreignlanguage*| (a new starred version of
|\foreignlanguage|).
@@ -3449,7 +3552,6 @@ This macro is not intended to fix wrong mappings done by Unicode
(which are the default in both \xetex{} and \luatex{}) -- if an
assignment is wrong, fix it directly.
-
\section{Changes}
\subsection{Changes in \babel\ version 3.9}
@@ -3635,15 +3737,15 @@ help from Bernd Raichle, for which I am grateful.
% little bit of literate programming.
%
% \begin{macrocode}
-%<<version=3.18>>
-%<<date=2018/02/14>>
+%<<version=3.19>>
+%<<date=2018/04/25>>
% \end{macrocode}
%
% \section{Tools}
%
-% \textbf{Do not use the following macros in ldf files. They may
-% change in the future}. This applies mainly to those recently added
-% for replacing, trimming and looping. The older ones, like
+% \textbf{Do not use the following macros in \texttt{ldf} files. They
+% may change in the future}. This applies mainly to those recently
+% added for replacing, trimming and looping. The older ones, like
% |\bbl@afterfi|, will not change.
%
% \changes{babel~3.9t}{2017/04/22}{Added new helper macros. Not all are
@@ -4056,6 +4158,9 @@ help from Bernd Raichle, for which I am grateful.
% To be improved. Moved showlanguages before base}
% \changes{babel~3.18}{2018/02/14}{Fix - prevent doble input of
% switch.def}
+% \changes{babel~3.19}{2018/04/23}{Split callback - vertical and
+% horizontal}
+% \changes{babel~3.19}{2018/04/23}{Added bidi=basic, here and passim}
%
% \begin{macrocode}
%<*package>
@@ -4100,23 +4205,49 @@ help from Bernd Raichle, for which I am grateful.
\bbl@languages
\fi
\ifodd\bbl@engine
- \@ifpackagewith{babel}{bidi=basic-r}{% must go before any \DeclareOption
+ \def\bbl@loadbidi#1{%
\let\bbl@beforeforeign\leavevmode
\AtEndOfPackage{\EnableBabelHook{babel-bidi}}%
\RequirePackage{luatexbase}%
\directlua{
require('babel-bidi.lua')
- require('babel-bidi-basic-r.lua')
+ require('babel-bidi-#1.lua')
luatexbase.add_to_callback('pre_linebreak_filter',
- Babel.pre_otfload,
- 'Babel.pre_otfload',
+ Babel.pre_otfload_v,
+ 'Babel.pre_otfload_v',
luatexbase.priority_in_callback('pre_linebreak_filter',
'luaotfload.node_processor') or nil)
luatexbase.add_to_callback('hpack_filter',
- Babel.pre_otfload,
- 'Babel.pre_otfload',
+ Babel.pre_otfload_h,
+ 'Babel.pre_otfload_h',
luatexbase.priority_in_callback('hpack_filter',
- 'luaotfload.node_processor') or nil)}}{}
+ 'luaotfload.node_processor') or nil)
+ }}
+ \let\bbl@tempa\relax
+ \@ifpackagewith{babel}{bidi=basic}%
+ {\def\bbl@tempa{basic}}%
+ {\@ifpackagewith{babel}{bidi=basic-r}%
+ {\def\bbl@tempa{basic-r}}%
+ {}}
+ \ifx\bbl@tempa\relax\else
+ \let\bbl@beforeforeign\leavevmode
+ \AtEndOfPackage{\EnableBabelHook{babel-bidi}}%
+ \RequirePackage{luatexbase}%
+ \directlua{
+ require('babel-bidi.lua')
+ require('babel-bidi-\bbl@tempa.lua')
+ luatexbase.add_to_callback('pre_linebreak_filter',
+ Babel.pre_otfload_v,
+ 'Babel.pre_otfload_v',
+ luatexbase.priority_in_callback('pre_linebreak_filter',
+ 'luaotfload.node_processor') or nil)
+ luatexbase.add_to_callback('hpack_filter',
+ Babel.pre_otfload_h,
+ 'Babel.pre_otfload_h',
+ luatexbase.priority_in_callback('hpack_filter',
+ 'luaotfload.node_processor') or nil)
+ }
+ \fi
\fi
% \end{macrocode}
%
@@ -4584,6 +4715,7 @@ help from Bernd Raichle, for which I am grateful.
You shouldn't try to proceed from here, type x to quit.}
\fi
%</package>
+%<*core>
% \end{macrocode}
%
% \section{The kernel of Babel (\texttt{babel.def}, common)}
@@ -4631,7 +4763,6 @@ help from Bernd Raichle, for which I am grateful.
% \changes{babel~3.9q}{2016/02/12}{Load lua patterns if not lualatex.}
%
% \begin{macrocode}
-%<*core>
\ifx\ldf@quit\@undefined
\else
\expandafter\endinput
@@ -7479,8 +7610,9 @@ help from Bernd Raichle, for which I am grateful.
% dates. Some refactoring in the ini reader.}
% \changes{3.15}{2017/10/30}{New keys script, language}
% \changes{3.16}{2018/01/02}{Make sure ensuring works even before
-% the language is selected}
-%
+% the language is selected}
+% \changes{babel~3.19}{2018/04/23}{New option - mapfont. Currently
+% only with direction}
%
% \begin{macrocode}
\bbl@trace{Creating languages and reading ini files}
@@ -7494,6 +7626,7 @@ help from Bernd Raichle, for which I am grateful.
\let\bbl@KVP@language\@nil
\let\bbl@KVP@dir\@nil
\let\bbl@KVP@hyphenrules\@nil
+ \let\bbl@KVP@mapfont\@nil
\bbl@forkv{#1}{\bbl@csarg\def{KVP@##1}{##2}}% TODO - error handling
\ifx\bbl@KVP@captions\@nil
\let\bbl@KVP@captions\bbl@KVP@import
@@ -7521,6 +7654,28 @@ help from Bernd Raichle, for which I am grateful.
\ifx\bbl@KVP@language\@nil\else
\bbl@csarg\edef{lname@#2}{\bbl@KVP@language}%
\fi
+ \ifx\bbl@KVP@mapfont\@nil\else
+ \bbl@ifsamestring{\bbl@KVP@mapfont}{direction}{}%
+ {\bbl@error{Option `\bbl@KVP@mapfont' unknown for\\%
+ mapfont. Use `direction'.%
+ {See the manual for details.}}}%
+ \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}%
+ \bbl@ifunset{bbl@wdir@\languagename}{\bbl@provide@dirs{\languagename}}{}%
+ \ifx\bbl@mapselect\@undefined
+ \AtBeginDocument{%
+ \expandafter\bbl@add\csname selectfont \endcsname{{\bbl@mapselect}}%
+ {\selectfont}}%
+ \def\bbl@mapselect{%
+ \let\bbl@mapselect\relax
+ \edef\bbl@prefontid{\fontid\font}}%
+ \def\bbl@mapdir##1{%
+ {\def\languagename{##1}\bbl@switchfont
+ \directlua{Babel.fontmap
+ [\the\csname bbl@wdir@##1\endcsname]%
+ [\bbl@prefontid]=\fontid\font}}}%
+ \fi
+ \bbl@exp{\\\bbl@add\\\bbl@mapselect{\\\bbl@mapdir{\languagename}}}%
+ \fi
\let\languagename\bbl@savelangname}
% \end{macrocode}
%
@@ -7707,8 +7862,8 @@ help from Bernd Raichle, for which I am grateful.
\bbl@exportkey{lfthm}{typography.lefthyphenmin}{2}%
\bbl@exportkey{rgthm}{typography.righthyphenmin}{3}%
\bbl@exportkey{hyphr}{typography.hyphenrules}{}%
- \def\bbl@tempa{0.9}%
- \bbl@csarg\ifx{@kv@identification.version}\bbl@tempa
+ \bbl@xin@{0.9}{\@nameuse{bbl@@kv@identification.version}}%
+ \ifin@
\bbl@warning{%
The `\languagename' date format may not be suitable\\%
for proper typesetting, and therefore it very likely will\\%
@@ -8782,6 +8937,7 @@ help from Bernd Raichle, for which I am grateful.
\ifodd\bbl@engine % luatex=1
\AddBabelHook{babel-bidi}{afterextras}{\bbl@switchdir}
\DisableBabelHook{babel-bidi}
+ \chardef\bbl@thepardir\z@
\def\bbl@getluadir#1{%
\directlua{
if tex.#1dir == 'TLT' then
@@ -8789,7 +8945,7 @@ help from Bernd Raichle, for which I am grateful.
elseif tex.#1dir == 'TRT' then
tex.sprint('1')
end}}
- \def\bbl@setdir#1#2#3{% 1=text/par.. 2=\textdir.. 3=0 lr/1 rl
+ \def\bbl@setluadir#1#2#3{% 1=text/par.. 2=\textdir.. 3=0 lr/1 rl
\ifcase#3\relax
\ifcase\bbl@getluadir{#1}\relax\else
#2 TLT\relax
@@ -8800,11 +8956,12 @@ help from Bernd Raichle, for which I am grateful.
\fi
\fi}
\def\bbl@textdir#1{%
- \bbl@setdir{text}\textdir{#1}% TODO - ?\linedir
- \setattribute\bbl@attr@dir{#1}}
- \def\bbl@pardir{\bbl@setdir{par}\pardir}
- \def\bbl@bodydir{\bbl@setdir{body}\bodydir}
- \def\bbl@pagedir{\bbl@setdir{page}\pagedir}
+ \bbl@setluadir{text}\textdir{#1}% TODO - ?\linedir
+ \setattribute\bbl@attr@dir{\numexpr\bbl@thepardir*3+#1}}
+ \def\bbl@pardir#1{\bbl@setluadir{par}\pardir{#1}%
+ \chardef\bbl@thepardir#1\relax}
+ \def\bbl@bodydir{\bbl@setluadir{body}\bodydir}
+ \def\bbl@pagedir{\bbl@setluadir{page}\pagedir}
\def\bbl@dirparastext{\pardir\the\textdir\relax}% %%%%
\else % pdftex=0, xetex=2
\AddBabelHook{babel-bidi}{afterextras}{\bbl@switchdir}
@@ -8884,7 +9041,7 @@ help from Bernd Raichle, for which I am grateful.
% \changes{3.16}{2018/01/02}{New macro \cs{babelsublr}}
%
% \begin{macrocode}
-\DeclareRobustCommand\babelsublr[1]{\leavevmode{\bbl@textdir\z@#1}}
+ \DeclareRobustCommand\babelsublr[1]{\leavevmode{\bbl@textdir\z@#1}}
% \end{macrocode}
%
% \subsection{Local Language Configuration}
@@ -8931,6 +9088,7 @@ help from Bernd Raichle, for which I am grateful.
\if@nobreak\ifvmode\nobreak\fi\fi}
\fi
%</core>
+%<*kernel>
% \end{macrocode}%
% \end{macro}
%
@@ -8942,7 +9100,6 @@ help from Bernd Raichle, for which I am grateful.
% counter.
%
% \begin{macrocode}
-%<*kernel>
<@Make sure ProvidesFile is defined@>
\ProvidesFile{switch.def}[<@date@> <@version@> Babel switching mechanism]
<@Load macros for plain if not LaTeX@>
@@ -9222,7 +9379,8 @@ help from Bernd Raichle, for which I am grateful.
{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}%
+ 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
\let\bbl@select@type\z@
@@ -9801,6 +9959,7 @@ help from Bernd Raichle, for which I am grateful.
preloaded for \bbl@nulllanguage\space instead}}
\let\bbl@usehooks\@gobbletwo
%</kernel>
+%<*patterns>
% \end{macrocode}
%
% \end{macro}
@@ -9864,7 +10023,6 @@ help from Bernd Raichle, for which I am grateful.
% is dumped.
%
% \begin{macrocode}
-%<*patterns>
<@Make sure ProvidesFile is defined@>
\ProvidesFile{hyphen.cfg}[<@date@> <@version@> Babel hyphens]
\xdef\bbl@format{\jobname}
@@ -10254,14 +10412,18 @@ help from Bernd Raichle, for which I am grateful.
%<<*More package options>>
\ifodd\bbl@engine
\DeclareOption{bidi=basic-r}%
+ {\ExecuteOptions{bidi=basic}}
+ \DeclareOption{bidi=basic}%
{\let\bbl@beforeforeign\leavevmode
\newattribute\bbl@attr@dir
\bbl@exp{\output{\bodydir\pagedir\the\output}}%
\AtEndOfPackage{\EnableBabelHook{babel-bidi}}}
\else
\DeclareOption{bidi=basic-r}%
+ {\ExecuteOptions{bidi=basic}}
+ \DeclareOption{bidi=basic}%
{\bbl@error
- {The bidi method `basic-r' is available only in\\%
+ {The bidi method `basic' is available only in\\%
luatex. I'll continue with `bidi=default', so\\%
expect wrong results}%
{See the manual for further details.}%
@@ -10347,9 +10509,10 @@ help from Bernd Raichle, for which I am grateful.
\<bbl@##1dflt@*\bbl@tempa>}}}%
{}}% 1=T - language, already defined
\def\bbl@tempa{%
- \bbl@warning{The current font is not a standard family.\\%
- Script and Language are not applied. Consider defining\\%
- a new family with \string\babelfont,}}%
+ \bbl@warning{The current font is not a standard family:\\%
+ \fontname\font\\%
+ Script and Language are not applied. Consider defining a\\%
+ new family with \string\babelfont. Reported}}%
\bbl@foreach\bbl@font@fams{% don't gather with prev for
\bbl@ifunset{bbl@##1dflt@\languagename}%
{\bbl@cs{famrst@##1}%
@@ -10367,20 +10530,25 @@ help from Bernd Raichle, for which I am grateful.
%
% When there are repeated keys in \textsf{fontspec}, the last value
% wins. So, we just place the ini settings at the beginning, and user
-% settings will take precedence.
+% settings will take precedence. We must deactivate temporarily
+% |\bbl@mapselect| because |\selectfont| is called internally when a
+% font is defined.
%
% \begin{macrocode}
-\def\bbl@font@set#1#2#3{%
+\def\bbl@font@set#1#2#3{% eg \bbl@rmdflt@lang \rmdefault \rmfamily
\bbl@xin@{<>}{#1}%
\ifin@
\bbl@exp{\\\bbl@fontspec@set\\#1\expandafter\@gobbletwo#1}%
\fi
\bbl@exp{%
- \def\\#2{#1}% eg, \rmdefault{\bbl@rm1dflt@lang}
+ \def\\#2{#1}% eg, \rmdefault{\bbl@rmdflt@lang}
\\\bbl@ifsamestring{#2}{\f@family}{\\#3\let\\\bbl@tempa\relax}{}}}
-\def\bbl@fontspec@set#1#2#3{%
+\def\bbl@fontspec@set#1#2#3{% eg \bbl@rmdflt@lang fnt-opt fnt-nme
+ \let\bbl@tempe\bbl@mapselect
+ \let\bbl@mapselect\relax
\bbl@exp{\<fontspec_set_family:Nnn>\\#1%
{\bbl@cs{lsys@\languagename},#2}}{#3}%
+ \let\bbl@mapselect\bbl@tempe
\bbl@toglobal#1}%
% \end{macrocode}
%
@@ -11170,9 +11338,16 @@ help from Bernd Raichle, for which I am grateful.
%
% \changes{3.18}{2018/02/14}{\cs{bbl@nextfake}, similar to the old
% \cs{nextfakemath} in Omega}
+% \changes{3.19}{2018/04/23}{Patch \cs{@eqnnum}, somewhat ad hoc. To be
+% improved.}
%
% \begin{macrocode}
\bbl@trace{Redefinitions for bidi layout}
+\ifx\@eqnnum\@undefined\else
+ \edef\@eqnnum{{%
+ \unexpanded{\ifcase\bbl@attr@dir\else\bbl@textdir\@ne\fi}%
+ \unexpanded\expandafter{\@eqnnum}}}
+\fi
\ifx\bbl@opt@layout\@nnil\endinput\fi % if no layout
\ifx\bbl@beforeforeign\leavevmode % A poor test for bidi=
\def\bbl@nextfake#1{%
@@ -11201,7 +11376,7 @@ help from Bernd Raichle, for which I am grateful.
\fi
\IfBabelLayout{tabular}
{\def\@tabular{%
- \leavevmode\hbox\bgroup\bbl@nextfake$%
+ \leavevmode\hbox\bgroup\bbl@nextfake$% %$
\let\@acol\@tabacol \let\@classz\@tabclassz
\let\@classiv\@tabclassiv \let\\\@tabularcr\@tabarray}}
{}
@@ -11245,7 +11420,7 @@ help from Bernd Raichle, for which I am grateful.
{\def\@textsuperscript#1{{% lua has separate settings for math
\m@th
\mathdir\pagedir % required with basic-r; ok with default, too
- \ensuremath {^{\mbox {\fontsize \sf@size \z@ #1}}}}}%
+ \ensuremath{^{\mbox {\fontsize \sf@size \z@ #1}}}}}%
\let\bbl@latinarabic=\@arabic
\def\@arabic#1{\babelsublr{\bbl@latinarabic#1}}%
\@ifpackagewith{babel}{bidi=default}%
@@ -11261,6 +11436,25 @@ help from Bernd Raichle, for which I am grateful.
\BabelFootnote\localfootnote\languagename{}{}%
\BabelFootnote\mainfootnote{}{}{}}
{}
+% \end{macrocode}
+%
+% Some \LaTeX{} macros use internally the math mode for text
+% formatting. They have very little in common and are grouped here, as
+% a single option.
+%
+% \changes{3.19}{2018/04/23}{New option extras for layout}
+%
+% \begin{macrocode}
+\IfBabelLayout{extras}%
+ {\def\underline#1{%
+ \relax
+ \ifmmode\@@underline{#1}%
+ \else\bbl@nextfake$\@@underline{\hbox{#1}}\m@th$\relax\fi}%
+ \DeclareRobustCommand{\LaTeXe}{\mbox{\m@th
+ \if b\expandafter\@car\f@series\@nil\boldmath\fi
+ \babelsublr{%
+ \LaTeX\kern.15em2\bbl@nextfake$_{\textstyle\varepsilon}$}}}}
+ {}
%</luatex>
% \end{macrocode}
%
@@ -17421,7 +17615,19 @@ local function dir_mark(head, from, to, outer)
node.insert_after(head, to, d)
end
-function Babel.pre_otfload(head)
+function Babel.pre_otfload_v(head)
+ -- head = Babel.numbers(head)
+ head = Babel.bidi(head, true)
+ return head
+end
+
+function Babel.pre_otfload_h(head)
+ -- head = Babel.numbers(head)
+ head = Babel.bidi(head, false)
+ return head
+end
+
+function Babel.bidi(head, ispar)
local first_n, last_n -- first and last char with nums
local last_es -- an auxiliary 'last' used with nums
local first_d, last_d -- first and last char in L/R block
@@ -17450,7 +17656,7 @@ function Babel.pre_otfload(head)
-- three cases: glyph, dir, otherwise
if item.id == node.id'glyph' then
-
+
local chardata = characters[item.char]
dir = chardata and chardata.d or nil
if not dir then
@@ -17649,6 +17855,351 @@ end
%</basic-r>
% \end{macrocode}
%
+% And here the Lua code for |bidi=basic|:
+%
+% \begin{macrocode}
+%<*basic>
+Babel = Babel or {}
+
+Babel.fontmap = Babel.fontmap or {}
+Babel.fontmap[0] = {} -- l
+Babel.fontmap[1] = {} -- r
+Babel.fontmap[2] = {} -- al/an
+
+function Babel.pre_otfload_v(head)
+ -- head = Babel.numbers(head)
+ head = Babel.bidi(head, true)
+ return head
+end
+
+function Babel.pre_otfload_h(head, gc, sz, pt, dir)
+ -- head = Babel.numbers(head)
+ head = Babel.bidi(head, false, dir)
+ return head
+end
+
+require('babel-bidi.lua')
+
+local characters = Babel.characters
+local ranges = Babel.ranges
+
+local DIR = node.id('dir')
+local GLYPH = node.id('glyph')
+
+local function insert_implicit(head, state, outer)
+ local new_state = state
+ if state.sim and state.eim and state.sim ~= state.eim then
+ dir = ((outer == 'r') and 'TLT' or 'TRT') -- ie, reverse
+ local d = node.new(DIR)
+ d.dir = '+' .. dir
+ node.insert_before(head, state.sim, d)
+ local d = node.new(DIR)
+ d.dir = '-' .. dir
+ node.insert_after(head, state.eim, d)
+ end
+ new_state.sim, new_state.eim = nil, nil
+ return head, new_state
+end
+
+local function insert_numeric(head, state)
+ local new
+ local new_state = state
+ if state.san and state.ean and state.san ~= state.ean then
+ local d = node.new(DIR)
+ d.dir = '+TLT'
+ _, new = node.insert_before(head, state.san, d)
+ if state.san == state.sim then state.sim = new end
+ local d = node.new(DIR)
+ d.dir = '-TLT'
+ _, new = node.insert_after(head, state.ean, d)
+ if state.ean == state.eim then state.eim = new end
+ end
+ new_state.san, new_state.ean = nil, nil
+ return head, new_state
+end
+
+-- \hbox with an explicit dir can lead to wrong results
+-- <R \hbox dir TLT{<R>}> and <L \hbox dir TRT{<L>}>
+
+function Babel.bidi(head, ispar, hdir)
+ local d -- d is used mainly for computations in a loop
+ local prev_d = ''
+ local new_d = false
+
+ local nodes = {}
+ local outer_first = nil
+
+ local has_en = false
+ local first_et = nil
+
+ local ATDIR = luatexbase.registernumber'bbl@attr@dir'
+
+ local save_outer
+ local temp = node.get_attribute(head, ATDIR)
+ if temp then
+ temp = temp % 3
+ save_outer = (temp == 0 and 'l') or
+ (temp == 1 and 'r') or
+ (temp == 2 and 'al')
+ elseif ispar then -- Or error? Shouldn't happen
+ save_outer = ('TRT' == tex.pardir) and 'r' or 'l'
+ else
+ save_outer = ('TRT' == hdir) and 'r' or 'l'
+ end
+ local outer = save_outer
+ local last = outer
+ -- 'al' is only taken into account in the first, current loop
+ if save_outer == 'al' then save_outer = 'r' end
+
+ local fontmap = Babel.fontmap
+
+ for item in node.traverse(head) do
+
+ -- In what follows, #node is the last (previous) node, because the
+ -- current one is not added until we start processing the neutrals.
+
+ -- three cases: glyph, dir, otherwise
+ if item.id == GLYPH then
+
+ local chardata = characters[item.char]
+ d = chardata and chardata.d or nil
+ if not d then
+ for nn, et in ipairs(ranges) do
+ if item.char < et[1] then
+ break
+ elseif item.char <= et[2] then
+ d = et[3]
+ break
+ end
+ end
+ end
+ d = d or 'l'
+
+ local temp = (d == 'l' and 0) or
+ (d == 'r' and 1) or
+ (d == 'al' and 2) or
+ (d == 'an' and 2) or nil
+ if temp and fontmap and fontmap[temp][item.font] then
+ item.font = fontmap[temp][item.font]
+ end
+
+ if new_d then
+ table.insert(nodes, {nil, (outer == 'l') and 'l' or 'r', nil})
+ attr_d = node.get_attribute(item, ATDIR)
+ attr_d = attr_d % 3
+ if attr_d == 1 then
+ outer_first = 'r'
+ last = 'r'
+ elseif attr_d == 2 then
+ outer_first = 'r'
+ last = 'al'
+ else
+ outer_first = 'l'
+ last = 'l'
+ end
+ outer = last
+ has_en = false
+ first_et = nil
+ new_d = false
+ end
+
+ elseif item.id == DIR then
+ d = nil
+ new_d = true
+
+ else
+ d = nil
+ end
+
+ -- AL <= EN/ET/ES -- W2 + W3 + W6
+ if last == 'al' and d == 'en' then
+ d = 'an' -- W3
+ elseif last == 'al' and (d == 'et' or d == 'es') then
+ d = 'on' -- W6
+ end
+
+ -- EN + CS/ES + EN -- W4
+ if d == 'en' and #nodes >= 2 then
+ if (nodes[#nodes][2] == 'es' or nodes[#nodes][2] == 'cs')
+ and nodes[#nodes-1][2] == 'en' then
+ nodes[#nodes][2] = 'en'
+ end
+ end
+
+ -- AN + CS + AN -- W4 too, because uax9 mixes both cases
+ if d == 'an' and #nodes >= 2 then
+ if (nodes[#nodes][2] == 'cs')
+ and nodes[#nodes-1][2] == 'an' then
+ nodes[#nodes][2] = 'an'
+ end
+ end
+
+ -- ET/EN -- W5 + W7->l / W6->on
+ if d == 'et' then
+ first_et = first_et or (#nodes + 1)
+ elseif d == 'en' then
+ has_en = true
+ first_et = first_et or (#nodes + 1)
+ elseif first_et then -- d may be nil here !
+ if has_en then
+ if last == 'l' then
+ temp = 'l' -- W7
+ else
+ temp = 'en' -- W5
+ end
+ else
+ temp = 'on' -- W6
+ end
+ for e = first_et, #nodes do
+ if nodes[e][1].id == GLYPH then nodes[e][2] = temp end
+ end
+ first_et = nil
+ has_en = false
+ end
+
+ if d then
+ if d == 'al' then
+ d = 'r'
+ last = 'al'
+ elseif d == 'l' or d == 'r' then
+ last = d
+ end
+ prev_d = d
+ table.insert(nodes, {item, d, outer_first})
+ else
+ -- Not sure about the following. Looks too 'ad hoc', but it's
+ -- required for numbers, so that 89 19 becomes 19 89. It also
+ -- affects n+cs/es+n.
+ if prev_d == 'an' or prev_d == 'en' then
+ table.insert(nodes, {item, 'on', nil})
+ end
+ end
+
+ outer_first = nil
+
+ end
+
+ -- TODO -- repeated here in case EN/ET is the last node. Find a
+ -- better way of doing things:
+ if first_et then -- dir may be nil here !
+ if has_en then
+ if last == 'l' then
+ temp = 'l' -- W7
+ else
+ temp = 'en' -- W5
+ end
+ else
+ temp = 'on' -- W6
+ end
+ for e = first_et, #nodes do
+ if nodes[e][1].id == GLYPH then nodes[e][2] = temp end
+ end
+ end
+
+ -- dummy node, to close things
+ table.insert(nodes, {nil, (outer == 'l') and 'l' or 'r', nil})
+
+ --------------- NEUTRAL -----------------
+
+ outer = save_outer
+ last = outer
+
+ local first_on = nil
+
+ for q = 1, #nodes do
+ local item
+
+ local outer_first = nodes[q][3]
+ outer = outer_first or outer
+ last = outer_first or last
+
+ local d = nodes[q][2]
+ if d == 'an' or d == 'en' then d = 'r' end
+ if d == 'cs' or d == 'et' or d == 'es' then d = 'on' end --- W6
+
+ if d == 'on' then
+ first_on = first_on or q
+ elseif first_on then
+ if last == d then
+ temp = d
+ else
+ temp = outer
+ end
+ for r = first_on, q - 1 do
+ nodes[r][2] = temp
+ item = nodes[r][1] -- MIRRORING
+ if item.id == GLYPH and temp == 'r' then
+ item.char = characters[item.char].m or item.char
+ end
+ end
+ first_on = nil
+ end
+
+ if d == 'r' or d == 'l' then last = d end
+ end
+
+ -------------- IMPLICIT, REORDER ----------------
+
+ outer = save_outer
+ last = outer
+
+ local state = {}
+ state.has_r = false
+
+ for q = 1, #nodes do
+
+ local item = nodes[q][1]
+
+ outer = nodes[q][3] or outer
+
+ local d = nodes[q][2]
+
+ if d == 'nsm' then d = last end -- W1
+ if d == 'en' then d = 'an' end
+ local isdir = (d == 'r' or d == 'l')
+
+ if outer == 'l' and d == 'an' then
+ state.san = state.san or item
+ state.ean = item
+ elseif state.san then
+ head, state = insert_numeric(head, state)
+ end
+
+ if outer == 'l' then
+ if d == 'an' or d == 'r' then -- im -> implicit
+ if d == 'r' then state.has_r = true end
+ state.sim = state.sim or item
+ state.eim = item
+ elseif d == 'l' and state.sim and state.has_r then
+ head, state = insert_implicit(head, state, outer)
+ elseif d == 'l' then
+ state.sim, state.eim, state.has_r = nil, nil, false
+ end
+ else
+ if d == 'an' or d == 'l' then
+ state.sim = state.sim or item
+ state.eim = item
+ elseif d == 'r' and state.sim then
+ head, state = insert_implicit(head, state, outer)
+ elseif d == 'r' then
+ state.sim, state.eim = nil, nil
+ end
+ end
+
+ if isdir then
+ last = d -- Don't search back - best save now
+ elseif d == 'on' and state.san then
+ state.san = state.san or item
+ state.ean = item
+ end
+
+ end
+
+ return node.prev(head) or head
+end
+%</basic>
+% \end{macrocode}
+%
% \section{The `nil' language}
%
% This `language' does nothing, except setting the hyphenation patterns to
@@ -18305,4 +18856,3 @@ end
% coding: utf-8
% TeX-engine: luatex
% End:
-