diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/babel/babel.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/babel/babel.dtx | 174 |
1 files changed, 126 insertions, 48 deletions
diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx index 3d4e18dab31..16acec62d46 100644 --- a/Master/texmf-dist/source/latex/babel/babel.dtx +++ b/Master/texmf-dist/source/latex/babel/babel.dtx @@ -31,7 +31,7 @@ % % \iffalse %<*filedriver> -\ProvidesFile{babel.dtx}[2018/04/25 v3.19 The Babel package] +\ProvidesFile{babel.dtx}[2018/05/02 v3.20 The Babel package] \documentclass{ltxdoc} \GetFileInfo{babel.dtx} \usepackage{fontspec} @@ -260,7 +260,9 @@ addition, you may want to set the font and input encodings. 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: + example because typically you will need them (however, the package + \textsf{inputenc} may be omitted with \LaTeX{} $\ge$ 2018-04-01 if + the encoding is UTF-8): \begin{verbatim} \documentclass{article} @@ -375,8 +377,9 @@ detail: |\selectlanguage| is used for blocks of text, while |\foreignlanguage| is for chunks of text inside paragraphs. \begin{example} -A full bilingual document follows. The main language is |french|, -which is activated when the document begins. +A full bilingual document follows. The main language is |french|, which +is activated when the document begins. The package \textsf{inputenc} +may be omitted with \LaTeX{} $\ge$ 2018-04-01 if the encoding is UTF-8. \begin{verbatim} \documentclass{article} @@ -1879,8 +1882,8 @@ sometimes necessary, but not always trivial. \renewcommand\contentsname{Foo}% } \end{verbatim} - As of 3.15, there is no need to hide spaces with \texttt{\%} -(\babel{} removes them), but it is advisable to do it. +As of 3.15, there is no need to hide spaces with \texttt{\%% +} (\babel{} removes them), but it is advisable to do it. \item The new way, which is found in |bulgarian|, |azerbaijani|, |spanish|, |french|, |turkish|, |icelandic|, |vietnamese| and a few more, as well as in languages created with |\babelprovide| and its @@ -1909,7 +1912,7 @@ unselected: |\noextras|\m{lang}. fits your needs? You may then define quickly a language with the help of the following macro in the preamble. -\Describe\babelprovide{\oarg{options}\marg{language-name}} +\Describe{\babelprovide}{\oarg{options}\marg{language-name}} Defines the internal structure of the language with some defaults: the hyphen rules, if not available, are set to the current ones, left and @@ -2012,9 +2015,32 @@ relevant. |ini|-based languages). \end{note} +\subsection{Digits} + +\New{3.20} A few |ini| files define a field named |digits.native|. When +it is present, two macros are created: |\<language>digits| and +|\<language>counter| (only \xetex{} and \luatex{}). With the first, a +string of ‘Latin’ digits are converted to the native digits of that +language; the second takes a counter name as argument. With option +|maparabic| in |\babelprovide|, |\arabic| is redefined to produce the +native digits (this is done \textit{globally}, to avoid inconsistencies +in, for example, page numbering). + +For example: +\begin{verbatim} +\babelprovide[import=te]{telugu} % Telugu better with XeTeX + % Or also, if you want: + % \babelprovide[import=te, maparabic]{telugu} +\babelfont{rm}{Gautami} +\begin{document} +\telugudigits{1234} +\telugucounter{section} +\end{document} +\end{verbatim} + \subsection{Getting the current language name} -\Describe\languagename{} +\Describe{\languagename}{} The control sequence |\languagename| contains the name of the current language. @@ -2024,7 +2050,7 @@ current language. Heiko Oberdiek. \end{warning} -\Describe\iflanguage{\marg{language}\marg{true}\marg{false}} +\Describe{\iflanguage}{\marg{language}\marg{true}\marg{false}} If more than one language is used, it might be necessary to know which language is active at a specific time. This can be checked by a call @@ -2042,7 +2068,7 @@ respectively. \subsection{Hyphenation tools} -\Describe\babelhyphen{% +\Describe{\babelhyphen}{% \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}\marg{type}} \DescribeOther\babelhyphen{% \colorbox{thegrey}{\ttfamily\hskip-.2em*\hskip-.2em}\marg{text}} @@ -3737,8 +3763,8 @@ help from Bernd Raichle, for which I am grateful. % little bit of literate programming. % % \begin{macrocode} -%<<version=3.19>> -%<<date=2018/04/25>> +%<<version=3.20>> +%<<date=2018/05/02>> % \end{macrocode} % % \section{Tools} @@ -4205,24 +4231,6 @@ help from Bernd Raichle, for which I am grateful. \bbl@languages \fi \ifodd\bbl@engine - \def\bbl@loadbidi#1{% - \let\bbl@beforeforeign\leavevmode - \AtEndOfPackage{\EnableBabelHook{babel-bidi}}% - \RequirePackage{luatexbase}% - \directlua{ - require('babel-bidi.lua') - require('babel-bidi-#1.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) - }} \let\bbl@tempa\relax \@ifpackagewith{babel}{bidi=basic}% {\def\bbl@tempa{basic}}% @@ -7613,6 +7621,8 @@ help from Bernd Raichle, for which I am grateful. % the language is selected} % \changes{babel~3.19}{2018/04/23}{New option - mapfont. Currently % only with direction} +% \changes{babel~3.20}{2018/05/01}{Handle native digits (TeX level). +% New option - maparabic.} % % \begin{macrocode} \bbl@trace{Creating languages and reading ini files} @@ -7627,6 +7637,7 @@ help from Bernd Raichle, for which I am grateful. \let\bbl@KVP@dir\@nil \let\bbl@KVP@hyphenrules\@nil \let\bbl@KVP@mapfont\@nil + \let\bbl@KVP@maparabic\@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 @@ -7676,7 +7687,48 @@ help from Bernd Raichle, for which I am grateful. \fi \bbl@exp{\\\bbl@add\\\bbl@mapselect{\\\bbl@mapdir{\languagename}}}% \fi + \ifcase\bbl@engine\else + \bbl@ifunset{bbl@dgnat@\languagename}{}% + {\expandafter\ifx\csname bbl@dgnat@\languagename\endcsname\@empty\else + \expandafter\expandafter\expandafter + \bbl@setdigits\csname bbl@dgnat@\languagename\endcsname + \ifx\bbl@KVP@maparabic\@nil\else + \expandafter\let\expandafter\@arabic + \csname bbl@counter@\languagename\endcsname + \fi + \fi}% + \fi \let\languagename\bbl@savelangname} +\def\bbl@setdigits#1#2#3#4#5{% + \bbl@exp{% + \def\<\languagename digits>####1{% ie, \langdigits + \<bbl@digits@\languagename>####1\\\@nil}% + \def\<\languagename counter>####1{% ie, \langcounter + \\\expandafter\<bbl@counter@\languagename>% + \\\csname c@####1\endcsname}% + \def\<bbl@counter@\languagename>####1{% ie, \bbl@counter@lang + \\\expandafter\<bbl@digits@\languagename>% + \\\number####1\\\@nil}}% + \def\bbl@tempa##1##2##3##4##5{% + \bbl@exp{% Wow, quite a lot of hashes! :-( + \def\<bbl@digits@\languagename>########1{% + \\\ifx########1\\\@nil % ie, \bbl@digits@lang + \\\else + \\\ifx0########1#1% + \\\else\\\ifx1########1#2% + \\\else\\\ifx2########1#3% + \\\else\\\ifx3########1#4% + \\\else\\\ifx4########1#5% + \\\else\\\ifx5########1##1% + \\\else\\\ifx6########1##2% + \\\else\\\ifx7########1##3% + \\\else\\\ifx8########1##4% + \\\else\\\ifx9########1##5% + \\\else########1% + \\\fi\\\fi\\\fi\\\fi\\\fi\\\fi\\\fi\\\fi\\\fi\\\fi + \\\expandafter\<bbl@digits@\languagename>% + \\\fi}}}% + \bbl@tempa} % \end{macrocode} % % Depending on whether or not the language exists, we define two macros. @@ -7858,10 +7910,12 @@ help from Bernd Raichle, for which I am grateful. \bbl@exportkey{sbcp}{identification.script.tag.bcp47}{}% \bbl@exportkey{sotf}{identification.script.tag.opentype}{DFLT}} \let\bbl@secline@typography\bbl@inikv +\let\bbl@secline@numbers\bbl@inikv \def\bbl@after@ini{% \bbl@exportkey{lfthm}{typography.lefthyphenmin}{2}% \bbl@exportkey{rgthm}{typography.righthyphenmin}{3}% \bbl@exportkey{hyphr}{typography.hyphenrules}{}% + \bbl@exportkey{dgnat}{numbers.digits.native}{}% \bbl@xin@{0.9}{\@nameuse{bbl@@kv@identification.version}}% \ifin@ \bbl@warning{% @@ -17594,6 +17648,9 @@ Babel.characters={ % % TODO: math mode (as weak L?) % +% \changes{babel~3.20}{2018/05/01}{Adapted to exhyphens in luatex >= +% 1.07. Fix - now attr@dir is mod 3.} +% % \begin{macrocode} %<*basic-r> Babel = Babel or {} @@ -17655,15 +17712,22 @@ function Babel.bidi(head, ispar) for item in node.traverse(head) do -- three cases: glyph, dir, otherwise - if item.id == node.id'glyph' then + if item.id == node.id'glyph' + or (item.id == 7 and item.subtype == 2) then - local chardata = characters[item.char] + local itemchar + if item.id == 7 and item.subtype == 2 then + itemchar = item.replace.char + else + itemchar = item.char + end + local chardata = characters[itemchar] dir = chardata and chardata.d or nil if not dir then for nn, et in ipairs(ranges) do - if item.char < et[1] then + if itemchar < et[1] then break - elseif item.char <= et[2] then + elseif itemchar <= et[2] then dir = et[3] break end @@ -17683,7 +17747,7 @@ function Babel.bidi(head, ispar) attr_dir = 0 for at in node.traverse(item.attr) do if at.number == luatexbase.registernumber'bbl@attr@dir' then - attr_dir = at.value + attr_dir = at.value % 3 end end if attr_dir == 1 then @@ -17856,6 +17920,8 @@ end % \end{macrocode} % % And here the Lua code for |bidi=basic|: +% \changes{babel~3.20}{2018/05/01}{Adapted to exhyphens in luatex >= +% 1.07. Fix - nsm in mapfont (eg, Arabic vowels)} % % \begin{macrocode} %<*basic> @@ -17959,28 +18025,40 @@ function Babel.bidi(head, ispar, hdir) -- current one is not added until we start processing the neutrals. -- three cases: glyph, dir, otherwise - if item.id == GLYPH then + if item.id == GLYPH + or (item.id == 7 and item.subtype == 2) then - local chardata = characters[item.char] + local d_font = nil + local item_r + if item.id == 7 and item.subtype == 2 then + item_r = item.replace -- automatic discs have just 1 glyph + else + item_r = item + end + local chardata = characters[item_r.char] d = chardata and chardata.d or nil - if not d then + if not d or d == 'nsm' then for nn, et in ipairs(ranges) do - if item.char < et[1] then + if item_r.char < et[1] then break - elseif item.char <= et[2] then - d = et[3] + elseif item_r.char <= et[2] then + if not d then d = et[3] + elseif d == 'nsm' then d_font = et[3] + end 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] + d_font = d_font or d + + d_font = (d_font == 'l' and 0) or + (d_font == 'nsm' and 0) or + (d_font == 'r' and 1) or + (d_font == 'al' and 2) or + (d_font == 'an' and 2) or nil + if d_font and fontmap and fontmap[d_font][item_r.font] then + item_r.font = fontmap[d_font][item_r.font] end if new_d then |