diff options
author | Norbert Preining <preining@logic.at> | 2021-04-08 21:22:57 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2021-04-08 21:22:57 +0000 |
commit | e5535dfde43899758ac8b4b8744aaa29668294d8 (patch) | |
tree | 7d834d3cdf862e4f0d25c223a38d91a7eddaddbb /Master/texmf-dist/tex/generic/babel/luababel.def | |
parent | ef47f55736fd1defd37f3b0554392947bd6f4ce2 (diff) |
babel (9apr21)
git-svn-id: svn://tug.org/texlive/trunk@58797 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/babel/luababel.def')
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/luababel.def | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/Master/texmf-dist/tex/generic/babel/luababel.def b/Master/texmf-dist/tex/generic/babel/luababel.def index 0d00d5b238d..31f874fc4c5 100644 --- a/Master/texmf-dist/tex/generic/babel/luababel.def +++ b/Master/texmf-dist/tex/generic/babel/luababel.def @@ -333,10 +333,10 @@ Babel.linebreaking = Babel.linebreaking or {} Babel.linebreaking.before = {} Babel.linebreaking.after = {} - Babel.locale = {} % Free to use, indexed with \localeid + Babel.locale = {} % Free to use, indexed by \localeid function Babel.linebreaking.add_before(func) tex.print([[\noexpand\csname bbl@luahyphenate\endcsname]]) - table.insert(Babel.linebreaking.before , func) + table.insert(Babel.linebreaking.before, func) end function Babel.linebreaking.add_after(func) tex.print([[\noexpand\csname bbl@luahyphenate\endcsname]]) @@ -951,17 +951,15 @@ end local locale = node.get_attribute(item, Babel.attr_locale) if lang == locale or lang == nil then - if (item.char ~= 124) then &% ie, not | = space - lang = lang or locale - word_string = word_string .. unicode.utf8.char(item.char) - word_nodes[#word_nodes+1] = item - end + lang = lang or locale + word_string = word_string .. unicode.utf8.char(item.char) + word_nodes[#word_nodes+1] = item else break end elseif item.id == 12 and item.subtype == 13 then - word_string = word_string .. '|' + word_string = word_string .. ' ' word_nodes[#word_nodes+1] = item &% Ignore leading unrecognized nodes, too. @@ -975,7 +973,7 @@ end &% Here and above we remove some trailing chars but not the &% corresponding nodes. But they aren't accessed. - if word_string:sub(-1) == '|' then + if word_string:sub(-1) == ' ' then word_string = word_string:sub(1,-2) end word_string = unicode.utf8.gsub(word_string, Babel.us_char .. '+$', '') @@ -1160,6 +1158,16 @@ end if Babel.debug then Babel.debug_hyph(w, w_nodes, sc, first, last, last_match) + local ss = '' + for itt in node.traverse(head) do + if itt.id == 29 then + ss = ss .. unicode.utf8.char(itt.char) + else + ss = ss .. '{' .. itt.id .. '}' + end + end + print('*****************', ss) + end local crep = r[rc] @@ -1251,7 +1259,7 @@ end crep.space[2] * quad, crep.space[3] * quad) if mode == 0 then - placeholder = '|' + placeholder = ' ' end head, new = node.insert_before(head, item, d) @@ -1263,7 +1271,7 @@ end crep.spacefactor[2] * base_font.parameters['space_stretch'], crep.spacefactor[3] * base_font.parameters['space_shrink']) if mode == 0 then - placeholder = '|' + placeholder = ' ' end head, new = node.insert_before(head, item, d) @@ -1313,7 +1321,15 @@ end &% The following functions belong to the next macro function Babel.capture_func(key, cap) local ret = "[[" .. cap:gsub('{([0-9])}', "]]..m[%1]..[[") .. "]]" - ret = ret:gsub('{([0-9])|([^|]+)|(.-)}', Babel.capture_func_map) + local cnt + local u = unicode.utf8 + ret, cnt = ret:gsub('{([0-9])|([^|]+)|(.-)}', Babel.capture_func_map) + if cnt == 0 then + ret = u.gsub(ret, '{(%x%x%x%x+)}', + function (n) + return u.char(tonumber(n, 16)) + end) + end ret = ret:gsub("%[%[%]%]%.%.", '') ret = ret:gsub("%.%.%[%[%]%]", '') return key .. [[=function(m) return ]] .. ret .. [[ end]] @@ -1325,6 +1341,15 @@ end &% Handle the {n|abc|ABC} syntax in captures function Babel.capture_func_map(capno, from, to) + local u = unicode.utf8 + from = u.gsub(from, '{(%x%x%x%x+)}', + function (n) + return u.char(tonumber(n, 16)) + end) + to = u.gsub(to, '{(%x%x%x%x+)}', + function (n) + return u.char(tonumber(n, 16)) + end) local froms = {} for s in string.utfcharacters(from) do table.insert(froms, s) @@ -1411,6 +1436,7 @@ end local id = \the\csname bbl@id@@#1\endcsname &% Convert pattern: local patt = string.gsub([==[#2]==], '%s', '') + local patt = string.gsub(patt, '|', ' ') if not u.find(patt, '()', nil, true) then patt = '()' .. patt .. '()' end |