blob: bfe0051bdfd29fc263f181b5e474b7cb79ee0d3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
if not modules then modules = { } end modules ['node-tst'] = {
version = 1.001,
comment = "companion to node-ini.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
}
local nodes, node = nodes, node
local chardata = characters.data
local nodecodes = nodes.nodecodes
local skipcodes = nodes.skipcodes
local glue_code = nodecodes.glue
local penalty_code = nodecodes.penalty
local kern_code = nodecodes.kern
local glyph_code = nodecodes.glyph
local whatsit_code = nodecodes.whatsit
local hlist_code = nodecodes.hlist
local leftskip_code = skipcodes.leftskip
local rightskip_code = skipcodes.rightskip
local abovedisplayshortskip_code = skipcodes.abovedisplayshortskip
local belowdisplayshortskip_code = skipcodes.belowdisplayshortskip
local find_node_tail = node.tail or node.slide
function nodes.leftmarginwidth(n) -- todo: three values
while n do
local id = n.id
if id == glue_code then
return n.subtype == leftskip_code and n.spec.width or 0
elseif id == whatsit_code then
n = n.next
elseif id == hlist_code then
return n.width
else
break
end
end
return 0
end
function nodes.rightmarginwidth(n)
if n then
n = find_node_tail(n)
while n do
local id = n.id
if id == glue_code then
return n.subtype == rightskip_code and n.spec.width or 0
elseif id == whatsit_code then
n = n.prev
else
break
end
end
end
return false
end
function nodes.somespace(n,all)
if n then
local id = n.id
if id == glue_code then
return (all or (n.spec.width ~= 0)) and glue_code
elseif id == kern_code then
return (all or (n.kern ~= 0)) and kern
elseif id == glyph_code then
local category = chardata[n.char].category
-- maybe more category checks are needed
return (category == "zs") and glyph_code
end
end
return false
end
function nodes.somepenalty(n,value)
if n then
local id = n.id
if id == penalty_code then
if value then
return n.penalty == value
else
return true
end
end
end
return false
end
function nodes.is_display_math(head)
local n = head.prev
while n do
local id = n.id
if id == penalty_code then
elseif id == glue_code then
if n.subtype == abovedisplayshortskip_code then
return true
end
else
break
end
n = n.prev
end
n = head.next
while n do
local id = n.id
if id == penalty_code then
elseif id == glue_code then
if n.subtype == belowdisplayshortskip_code then
return true
end
else
break
end
n = n.next
end
return false
end
|