diff options
author | Karl Berry <karl@freefriends.org> | 2024-06-02 20:24:10 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-06-02 20:24:10 +0000 |
commit | 5634f0473d32ab71b4fbaaf0a6870737c2cc6dcb (patch) | |
tree | 4453c5e38663179032e429935eab72d683b7c95a /Master/texmf-dist/tex/generic/babel | |
parent | f570bee4ec02755618ec0dc8f705555f50b0731c (diff) |
babel (2jun24)
git-svn-id: svn://tug.org/texlive/trunk@71407 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/babel')
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/babel-transforms.lua | 64 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/babel.def | 6 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/babel.sty | 14 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/hyphen.cfg | 6 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/luababel.def | 12 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/nil.ldf | 2 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/txtbabel.def | 4 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/xebabel.def | 4 |
8 files changed, 89 insertions, 23 deletions
diff --git a/Master/texmf-dist/tex/generic/babel/babel-transforms.lua b/Master/texmf-dist/tex/generic/babel/babel-transforms.lua index 116de257642..08ee95e770c 100644 --- a/Master/texmf-dist/tex/generic/babel/babel-transforms.lua +++ b/Master/texmf-dist/tex/generic/babel/babel-transforms.lua @@ -227,6 +227,7 @@ function Babel.hyphenate_replace(head, mode) print('=====') end local new -- used when inserting and removing nodes + local dummy_node -- used by after local matches = { u.match(w, p, last_match) } @@ -271,7 +272,8 @@ function Babel.hyphenate_replace(head, mode) -- rc = the replacement table index local rc = 0 - while rc < last-first+1 do -- for each replacement +------- TODO. dummy_node? + while rc < last-first+1 or dummy_node do -- for each replacement if Babel.debug then print('.....', rc + 1) end @@ -303,11 +305,31 @@ function Babel.hyphenate_replace(head, mode) end if crep then - step = crep.step or 0 + step = crep.step or step + end + + if crep and crep.after then + crep.insert = true + if dummy_node then + item = dummy_node + else -- TODO. if there is a node after? + d = node.copy(item_base) + head, item = node.insert_after(head, item, d) + dummy_node = item + end + end + + if crep and not crep.after and dummy_node then + node.remove(head, dummy_node) + dummy_node = nil end if (not enabled) or (crep and next(crep) == nil) then -- = {} - last_match = save_last -- Optimization + if step == 0 then + last_match = save_last -- Optimization + else + last_match = utf8.offset(w, sc+step) + end goto next elseif crep == nil or crep.remove then @@ -396,6 +418,15 @@ function Babel.hyphenate_replace(head, mode) end head, new = node.insert_before(head, item, d) + elseif crep and crep.norule then + -- 655360 = 10 pt = 10 * 65536 sp + d = node.new(2, 3) -- (rule, empty) = \no*rule + local quad = font.getfont(item_base.font).size or 655360 + d.width = crep.norule[1] * quad + d.height = crep.norule[2] * quad + d.depth = crep.norule[3] * quad + head, new = node.insert_before(head, item, d) + elseif crep and crep.spacefactor then d = node.new(12, 13) -- (glue, spaceskip) local base_font = font.getfont(item_base.font) @@ -411,9 +442,21 @@ function Babel.hyphenate_replace(head, mode) elseif mode == 0 and crep and crep.space then -- ERROR + elseif crep and crep.kern then + d = node.new(13, 1) -- (kern, user) + local quad = font.getfont(item_base.font).size or 655360 + d.attr = item_base.attr + d.kern = crep.kern * quad + head, new = node.insert_before(head, item, d) + + elseif crep and crep.node then + d = node.new(crep.node[1], crep.node[2]) + d.attr = item_base.attr + head, new = node.insert_before(head, item, d) + end -- ie replacement cases - -- Shared by disc, space and penalty. + -- Shared by disc, space(factor), kern, node and penalty. if sc == 1 then word_head = head end @@ -438,6 +481,11 @@ function Babel.hyphenate_replace(head, mode) Babel.debug_hyph(w, w_nodes, sc, first, last, last_match) end + if dummy_node then + node.remove(head, dummy_node) + dummy_node = nil + end + end -- for match end -- for patterns @@ -518,6 +566,14 @@ function Babel.capture_kashida(key, wt) return 'kashida = ' .. wt end +function Babel.capture_node(id, subtype) + local sbt = 0 + for k, v in pairs(node.subtypes(id)) do + if v == subtype then sbt = k end + end + return 'node = {' .. node.id(id) .. ', ' .. sbt .. '}' +end + -- Experimental: applies prehyphenation transforms to a string (letters -- and spaces). function Babel.string_prehyphenation(str, locale) diff --git a/Master/texmf-dist/tex/generic/babel/babel.def b/Master/texmf-dist/tex/generic/babel/babel.def index a6abaeded14..d7a24d8540c 100644 --- a/Master/texmf-dist/tex/generic/babel/babel.def +++ b/Master/texmf-dist/tex/generic/babel/babel.def @@ -40,7 +40,7 @@ \wlog{File: #1 #4 #3 <#2>}% \let\ProvidesFile\@undefined} \fi -\ProvidesFile{babel.def}[2024/05/18 v24.5 Babel common definitions] +\ProvidesFile{babel.def}[2024/06/02 v24.6 Babel common definitions] \ifx\AtBeginDocument\@undefined % TODO. change test. \def\@empty{} \def\loadlocalcfg#1{% @@ -596,8 +596,8 @@ \toks@\expandafter{\bbl@tempc#3}% \expandafter\edef\csname extras\languagename\endcsname{\the\toks@}% \fi} -\def\bbl@version{24.5} -\def\bbl@date{2024/05/18} +\def\bbl@version{24.6} +\def\bbl@date{2024/06/02} \ifx\language\@undefined \csname newcount\endcsname\language \fi diff --git a/Master/texmf-dist/tex/generic/babel/babel.sty b/Master/texmf-dist/tex/generic/babel/babel.sty index 18ccb3675bd..71582e98272 100644 --- a/Master/texmf-dist/tex/generic/babel/babel.sty +++ b/Master/texmf-dist/tex/generic/babel/babel.sty @@ -34,7 +34,7 @@ %% \NeedsTeXFormat{LaTeX2e}[2005/12/01] -\ProvidesPackage{babel}[2024/05/18 v24.5 The Babel package] +\ProvidesPackage{babel}[2024/06/02 v24.6 The Babel package] \@ifpackagewith{babel}{debug} {\providecommand\bbl@trace[1]{\message{^^J[ #1 ]}}% \let\bbl@debug\@firstofone @@ -466,8 +466,8 @@ \expandafter\@secondoftwo \fi} \fi -\def\bbl@version{24.5} -\def\bbl@date{2024/05/18} +\def\bbl@version{24.6} +\def\bbl@date{2024/06/02} \ifx\language\@undefined \csname newcount\endcsname\language \fi @@ -3963,16 +3963,16 @@ \fi \fi \fi -\ifnum\bbl@bidimode=\@ne % Any bidi= except default=1 +\ifnum\bbl@bidimode=\@ne % bidi=default \let\bbl@beforeforeign\leavevmode - \ifodd\bbl@engine + \ifodd\bbl@engine % lua \newattribute\bbl@attr@dir \directlua{ Babel.attr_dir = luatexbase.registernumber'bbl@attr@dir' } \bbl@exp{\output{\bodydir\pagedir\the\output}} \fi \AtEndOfPackage{% - \EnableBabelHook{babel-bidi}% - \ifodd\bbl@engine\else + \EnableBabelHook{babel-bidi}% pdf/lua/xe + \ifodd\bbl@engine\else % pdf/xe \bbl@xebidipar \fi} \fi diff --git a/Master/texmf-dist/tex/generic/babel/hyphen.cfg b/Master/texmf-dist/tex/generic/babel/hyphen.cfg index 01719325f44..4ed4a864950 100644 --- a/Master/texmf-dist/tex/generic/babel/hyphen.cfg +++ b/Master/texmf-dist/tex/generic/babel/hyphen.cfg @@ -38,10 +38,10 @@ \wlog{File: #1 #4 #3 <#2>}% \let\ProvidesFile\@undefined} \fi -\ProvidesFile{hyphen.cfg}[2024/05/18 v24.5 Babel hyphens] +\ProvidesFile{hyphen.cfg}[2024/06/02 v24.6 Babel hyphens] \xdef\bbl@format{\jobname} -\def\bbl@version{24.5} -\def\bbl@date{2024/05/18} +\def\bbl@version{24.6} +\def\bbl@date{2024/06/02} \ifx\AtBeginDocument\@undefined \def\@empty{} \fi diff --git a/Master/texmf-dist/tex/generic/babel/luababel.def b/Master/texmf-dist/tex/generic/babel/luababel.def index 2173499d17f..82edeff91f7 100644 --- a/Master/texmf-dist/tex/generic/babel/luababel.def +++ b/Master/texmf-dist/tex/generic/babel/luababel.def @@ -197,6 +197,7 @@ \endinput\fi % Here stops reading code for hyphen.cfg % The following is read the 2nd time it's loaded + % First, global declarations for lua \begingroup % TODO - to a lua file \catcode`\%=12 \catcode`\'=12 @@ -204,6 +205,10 @@ \catcode`\:=12 \directlua{ Babel = Babel or {} + function Babel.lua_error(e, a) + tex.print([[\noexpand\csname bbl@error\endcsname{]] .. + e .. '}{' .. (a or '') .. '}{}{}') + end function Babel.bytes(line) return line:gsub("(.)", function (chr) return unicode.utf8.char(string.byte(chr)) end) @@ -1220,7 +1225,12 @@ end local rep = [=[##1]=] rep = rep:gsub('^%s*(remove)%s*$', 'remove = true') rep = rep:gsub('^%s*(insert)%s*,', 'insert = true, ') + rep = rep:gsub('^%s*(after)%s*,', 'after = true, ') rep = rep:gsub('(string)%s*=%s*([^%s,]*)', Babel.capture_func) + rep = rep:gsub('node%s*=%s*(%a+)%s*(%a*)', Babel.capture_node) + rep = rep:gsub(&% + '(norule)%s*=%s*([%-%d%.]+)%s+([%-%d%.]+)%s+([%-%d%.]+)', + 'norule = {' .. '%2, %3, %4' .. '}') if #1 == 0 or #1 == 2 then rep = rep:gsub(&% '(space)%s*=%s*([%-%d%.]+)%s+([%-%d%.]+)%s+([%-%d%.]+)', @@ -1239,7 +1249,7 @@ end \bbl@foreach\babeltempb{&% \bbl@forkv{{##1}}{&% \in@{,####1,}{,nil,step,data,remove,insert,string,no,pre,&% - no,post,penalty,kashida,space,spacefactor,}&% + no,post,penalty,kashida,space,spacefactor,kern,node,after,}&% \ifin@\else \bbl@error{bad-transform-option}{####1}{}{}&% \fi}}&% diff --git a/Master/texmf-dist/tex/generic/babel/nil.ldf b/Master/texmf-dist/tex/generic/babel/nil.ldf index 3e4916af39a..346399ca4f2 100644 --- a/Master/texmf-dist/tex/generic/babel/nil.ldf +++ b/Master/texmf-dist/tex/generic/babel/nil.ldf @@ -33,7 +33,7 @@ %% extension |.ins|) which are part of the distribution. %% -\ProvidesLanguage{nil}[2024/05/18 v24.5 Nil language] +\ProvidesLanguage{nil}[2024/06/02 v24.6 Nil language] \LdfInit{nil}{datenil} \ifx\l@nil\@undefined \newlanguage\l@nil diff --git a/Master/texmf-dist/tex/generic/babel/txtbabel.def b/Master/texmf-dist/tex/generic/babel/txtbabel.def index fd12fc37ef3..70ae95c5d4b 100644 --- a/Master/texmf-dist/tex/generic/babel/txtbabel.def +++ b/Master/texmf-dist/tex/generic/babel/txtbabel.def @@ -35,12 +35,12 @@ \providecommand\bbl@provide@intraspace{} \bbl@trace{Redefinitions for bidi layout} -\def\bbl@sspre@caption{% +\def\bbl@sspre@caption{% TODO: Unused! \bbl@exp{\everyhbox{\\\bbl@textdir\bbl@cs{wdir@\bbl@main@language}}}} \ifx\bbl@opt@layout\@nnil\else % if layout=.. \def\bbl@startskip{\ifcase\bbl@thepardir\leftskip\else\rightskip\fi} \def\bbl@endskip{\ifcase\bbl@thepardir\rightskip\else\leftskip\fi} -\ifx\bbl@beforeforeign\leavevmode % A poor test for bidi= +\ifnum\bbl@bidimode>\z@ % TODO: always? \def\@hangfrom#1{% \setbox\@tempboxa\hbox{{#1}}% \hangindent\ifcase\bbl@thepardir\wd\@tempboxa\else-\wd\@tempboxa\fi diff --git a/Master/texmf-dist/tex/generic/babel/xebabel.def b/Master/texmf-dist/tex/generic/babel/xebabel.def index 7a667481643..9775e235b39 100644 --- a/Master/texmf-dist/tex/generic/babel/xebabel.def +++ b/Master/texmf-dist/tex/generic/babel/xebabel.def @@ -386,12 +386,12 @@ {\bbl@csarg\let{ic@#1@\languagename}\@gobble}} \providecommand\bbl@provide@intraspace{} \bbl@trace{Redefinitions for bidi layout} -\def\bbl@sspre@caption{% +\def\bbl@sspre@caption{% TODO: Unused! \bbl@exp{\everyhbox{\\\bbl@textdir\bbl@cs{wdir@\bbl@main@language}}}} \ifx\bbl@opt@layout\@nnil\else % if layout=.. \def\bbl@startskip{\ifcase\bbl@thepardir\leftskip\else\rightskip\fi} \def\bbl@endskip{\ifcase\bbl@thepardir\rightskip\else\leftskip\fi} -\ifx\bbl@beforeforeign\leavevmode % A poor test for bidi= +\ifnum\bbl@bidimode>\z@ % TODO: always? \def\@hangfrom#1{% \setbox\@tempboxa\hbox{{#1}}% \hangindent\ifcase\bbl@thepardir\wd\@tempboxa\else-\wd\@tempboxa\fi |