summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/node-acc.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/node-acc.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/mkiv/node-acc.lua72
1 files changed, 27 insertions, 45 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/node-acc.lua b/Master/texmf-dist/tex/context/base/mkiv/node-acc.lua
index e6c6176026e..03f6d747634 100644
--- a/Master/texmf-dist/tex/context/base/mkiv/node-acc.lua
+++ b/Master/texmf-dist/tex/context/base/mkiv/node-acc.lua
@@ -8,6 +8,7 @@ if not modules then modules = { } end modules ['node-acc'] = {
local nodes, node = nodes, node
+local nodecodes = nodes.nodecodes
local tasks = nodes.tasks
local nuts = nodes.nuts
@@ -15,7 +16,6 @@ local tonut = nodes.tonut
local tonode = nodes.tonode
local getid = nuts.getid
-local getsubtype = nuts.getsubtype
local getattr = nuts.getattr
local getlist = nuts.getlist
local getchar = nuts.getchar
@@ -28,28 +28,21 @@ local setsubtype = nuts.setsubtype
local getwidth = nuts.getwidth
local setwidth = nuts.setwidth
-local nextglyph = nuts.traversers.glyph
-local nextnode = nuts.traversers.node
-
+----- traverse_nodes = nuts.traverse
+local traverse_id = nuts.traverse_id
----- copy_node = nuts.copy
local insert_after = nuts.insert_after
local copy_no_components = nuts.copy_no_components
-local nodecodes = nodes.nodecodes
-local gluecodes = nodes.gluecodes
-
local glue_code = nodecodes.glue
----- kern_code = nodecodes.kern
local glyph_code = nodecodes.glyph
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist
-local userskip_code = gluecodes.user
-local spaceskip_code = gluecodes.spaceskip
-local xspaceskip_code = gluecodes.xspaceskip
-
local a_characters = attributes.private("characters")
+local threshold = 65536 -- not used
local nofreplaced = 0
-- todo: nbsp etc
@@ -57,9 +50,6 @@ local nofreplaced = 0
-- todo: maybe cache as we now create many nodes
-- todo: check for subtype related to spacing (13/14 but most seems to be user anyway)
-local trace = false trackers.register("backend.spaces", function(v) trace = v end)
-local slot = nil
-
local function injectspaces(head)
local p, p_id
local n = head
@@ -67,42 +57,32 @@ local function injectspaces(head)
local id = getid(n)
if id == glue_code then
if p and getid(p) == glyph_code then
- local s = getsubtype(n)
- if s == spaceskip_code or s == xspaceskip_code then
- -- unless we don't care about the little bit of overhead
- -- we can just: local g = copy_node(g)
- local g = copy_no_components(p)
- local a = getattr(n,a_characters)
- setchar(g,slot)
- setlink(p,g,n)
- setwidth(n,getwidth(n) - getwidth(g))
- -- setsubtype(n,userskip_code)
- if a then
- setattr(g,a_characters,a)
- end
- setattr(n,a_characters,0)
- nofreplaced = nofreplaced + 1
+ -- unless we don't care about the little bit of overhead
+ -- we can just: local g = copy_node(g)
+ local g = copy_no_components(p)
+ local a = getattr(n,a_characters)
+ setchar(g,32)
+ setlink(p,g,n)
+ setwidth(n,getwidth(n) - getwidth(g))
+ if a then
+ setattr(g,a_characters,a)
end
+ setattr(n,a_characters,0)
+ nofreplaced = nofreplaced + 1
end
elseif id == hlist_code or id == vlist_code then
- injectspaces(getlist(n),slot)
+ injectspaces(getlist(n),attribute)
end
p_id = id
p = n
n = getnext(n)
end
- return head
+ return head, true -- always done anyway
end
nodes.handlers.accessibility = function(head)
- if trace then
- if not slot then
- slot = fonts.helpers.privateslot("visualspace")
- end
- else
- slot = 32
- end
- return injectspaces(head,slot)
+ local head, done = injectspaces(tonut(head))
+ return tonode(head), done
end
statistics.register("inserted spaces in output",function()
@@ -119,7 +99,7 @@ end)
--
-- local function compact(n)
-- local t = { }
--- for n in nextglyph, n do
+-- for n in traverse_id(glyph_code,n) do
-- t[#t+1] = utfchar(getchar(n)) -- check for unicode
-- end
-- return concat(t,"")
@@ -127,7 +107,8 @@ end)
--
-- local function injectspans(head)
-- local done = false
--- for n, id in nextnode, tonuts(head) do
+-- for n in traverse_nodes(tonuts(head)) do
+-- local id = getid(n)
-- if id == disc then
-- local r = getfield(n,"replace")
-- local p = getfield(n,"pre")
@@ -153,17 +134,18 @@ end)
--
-- tasks.appendaction("processors", "words", "nodes.injectspans")
--
--- local pageliteral = nuts.pool.pageliteral
+-- local pdfpageliteral = nuts.pool.pdfpageliteral
--
-- local function injectspans(head)
-- local done = false
--- for n, id in nextnode, tonut(head) do
+-- for n in traverse_nodes(tonut(head)) do
+-- local id = getid(n)
-- if id == disc then
-- local a = getattr(n,a_hyphenated)
-- if a then
-- local str = codes[a]
--- local b = pageliteral(format("/Span << /ActualText %s >> BDC", lpdf.tosixteen(str)))
--- local e = pageliteral("EMC")
+-- local b = pdfpageliteral(format("/Span << /ActualText %s >> BDC", lpdf.tosixteen(str)))
+-- local e = pdfpageliteral("EMC")
-- insert_before(head,n,b)
-- insert_after(head,n,e)
-- done = true