1if not modules then modules = { } end modules ['attr-mkr'] = { 2 version = 1.001, 3 comment = "companion to attr-mkr.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 markers = nodes.markers or { } 10nodes.markers = markers 11 12local cache = { } 13local numbers = attributes.numbers 14local a_unknown <const> = attributes.private("marker:unknown") 15 16local nuts = nodes.nuts 17local tonut = nodes.tonut 18local setattr = nuts.setattr 19local getattr = nuts.getattr 20 21table.setmetatableindex(cache,function(t,k) 22 local k = "marker:" .. k 23 local v = numbers[k] or a_unknown 24 t[k] = v 25 return v 26end) 27 28function markers.get(n,name) 29 local a = cache[name] 30 if a then 31 getattr(tonut(n),a) 32 end 33end 34 35function markers.set(n,name,v) 36 local a = cache[name] 37 if a then 38 setattr(tonut(n),a,v) 39 end 40end 41 |