1if not modules then modules = { } end modules ['typo-hid'] = {
2 version = 1.001,
3 comment = "companion to typo-hid.mkiv",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9local nuts = nodes.nuts
10local getattr = nuts.getattr
11local getnext = nuts.getnext
12local setnext = nuts.setnext
13local getprev = nuts.getprev
14local setlist = nuts.setlist
15local setlink = nuts.setlink
16local nextnode = nuts.traversers.node
17local flushlist = nuts.flushlist
18local dimensions = nuts.rangedimensions
19local hpack = nuts.hpack
20local setwhd = nuts.setwhd
21local setattrlist = nuts.setattrlist
22local enableaction = nodes.tasks.enableaction
23
24local specialskips = nodes.specialskipcodes
25
26local glue_code <const> = nodes.nodecodes.glue
27
28local a_hidecontent <const> = attributes.system("hidecontent")
29
30function nodes.handlers.wipe(head,groupcode,line)
31 if getattr(line,a_hidecontent) then
32 flushlist(head)
33 setlist(line)
34 else
35
36 local b, e = nil, nil
37 local function wipe()
38 local h = hpack()
39 local n = getnext(e)
40 setwhd(h,dimensions(line,b,n))
41 setlink(getprev(b),h,n)
42 setattrlist(h,b)
43 setnext(b)
44 flushlist(b)
45 b = nil
46 e = nil
47 end
48 for n, id, subtype in nextnode, head do
49 if id == glue_code and specialskips[subtype] then
50 if b then
51 wipe()
52 end
53 elseif getattr(n,a_hidecontent) then
54 if not b then
55 b = n
56 end
57 e = n
58 elseif b then
59 wipe()
60 end
61 end
62 if b then
63
64 wipe()
65 end
66 setlist(line,head)
67 end
68 return nil
69end
70
71interfaces.implement {
72 name = "enablehidecontent",
73 onlyonce = true,
74 actions = function()
75 enableaction("contributers","nodes.handlers.wipe")
76 end,
77}
78 |