summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/lang-wrd.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/lang-wrd.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/lang-wrd.lua16
1 files changed, 9 insertions, 7 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/lang-wrd.lua b/Master/texmf-dist/tex/context/base/mkiv/lang-wrd.lua
index 9fbced2ce95..7363dbb3168 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/lang-wrd.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/lang-wrd.lua
@@ -31,6 +31,7 @@ local numbers = languages.numbers
local registered = languages.registered
local nuts = nodes.nuts
+local tonut = nuts.tonut
----- getfield = nuts.getfield
local getnext = nuts.getnext
@@ -42,8 +43,8 @@ local setattr = nuts.setattr
local getlang = nuts.getlang
local ischar = nuts.ischar
-local nextnode = nuts.traversers.node
------ nextglyph = nuts.traversers.glyph
+local traverse_nodes = nuts.traverse
+----- traverse_ids = nuts.traverse_id
local wordsdata = words.data
local chardata = characters.data
@@ -144,13 +145,14 @@ end
-- there is an n=1 problem somewhere in nested boxes
local function mark_words(head,whenfound) -- can be optimized and shared
- local current, language = head, nil, nil, 0
+ local current, language, done = tonut(head), nil, nil, 0, false
local str, s, nds, n = { }, 0, { }, 0 -- n could also be a table, saves calls
local function action()
if s > 0 then
local word = concat(str,"",1,s)
local mark = whenfound(language,word)
if mark then
+ done = true
for i=1,n do
mark(nds[i])
end
@@ -196,7 +198,7 @@ local function mark_words(head,whenfound) -- can be optimized and shared
-- n = n + 1
-- nds[n] = current
-- --
- -- for current in nextglyph, r do
+ -- for current in traverse_ids(glyph_code,r) do
-- local code = getchar(current)
-- n = n + 1
-- nds[n] = current
@@ -215,7 +217,7 @@ local function mark_words(head,whenfound) -- can be optimized and shared
if s > 0 then
action()
end
- return head
+ return head, done
end
local methods = { }
@@ -283,7 +285,7 @@ local function sweep(language,str)
end
methods[1] = function(head)
- for n in nextnode, head do
+ for n in traverse_nodes(head) do
setattr(n,a_color,unsetvalue) -- hm, not that selective (reset color)
end
return mark_words(head,sweep)
@@ -378,7 +380,7 @@ local function sweep(language,str)
end
methods[3] = function(head)
- for n in nextnode, head do
+ for n in traverse_nodes(head) do
setattr(n,a_color,unsetvalue)
end
return mark_words(head,sweep)