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 a_hidecontent = attributes.system("hidecontent")
10local specialskips = nodes.specialskipcodes
11local glue_code = nodes.nodecodes.glue
12local nuts = nodes.nuts
13local getattr = nuts.getattr
14local getnext = nuts.getnext
15local setnext = nuts.setnext
16local getprev = nuts.getprev
17local setlist = nuts.setlist
18local setlink = nuts.setlink
19local nextnode = nuts.traversers.node
20local flushlist = nuts.flushlist
21local dimensions = nuts.rangedimensions
22local hpack = nuts.hpack
23local setwhd = nuts.setwhd
24local setattrlist = nuts.setattrlist
25local enableaction = nodes.tasks.enableaction
26
27function nodes.handlers.wipe(head,groupcode,line)
28 if getattr(line,a_hidecontent) then
29 flushlist(head)
30 setlist(line)
31 else
32
33 local b, e = nil, nil
34 local function wipe()
35 local h = hpack()
36 local n = getnext(e)
37 setwhd(h,dimensions(line,b,n))
38 setlink(getprev(b),h,n)
39 setattrlist(h,b)
40 setnext(b)
41 flushlist(b)
42 b = nil
43 e = nil
44 end
45 for n, id, subtype in nextnode, head do
46 if id == glue_code and specialskips[subtype] then
47 if b then
48 wipe()
49 end
50 elseif getattr(n,a_hidecontent) then
51 if not b then
52 b = n
53 end
54 e = n
55 elseif b then
56 wipe()
57 end
58 end
59 if b then
60
61 wipe()
62 end
63 setlist(line,head)
64 end
65 return nil
66end
67
68interfaces.implement {
69 name = "enablehidecontent",
70 onlyonce = true,
71 actions = function()
72 enableaction("contributers","nodes.handlers.wipe")
73 end,
74}
75 |