math-spa.lua /size: 2356 b    last modification: 2020-07-01 14:35
1
if
not
modules
then
modules
=
{
}
end
modules
[
'
math-spa
'
]
=
{
2
version
=
1
.
001
,
3
comment
=
"
companion to math-ini.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 9
-- for the moment (when testing) we use a penalty 1
10 11
local
penalty_code
=
nodes
.
nodecodes
.
penalty
12
local
glue_code
=
nodes
.
nodecodes
.
glue
13 14
local
nuts
=
nodes
.
nuts
15
local
tonut
=
nodes
.
tonut
16
local
tonode
=
nodes
.
tonode
17 18
local
getid
=
nuts
.
getid
19
local
getnext
=
nuts
.
getnext
20
local
getwidth
=
nuts
.
getwidth
21
local
setglue
=
nuts
.
setglue
22
local
getpenalty
=
nuts
.
getpenalty
23
local
setpenalty
=
nuts
.
setpenalty
24
local
getdimensions
=
nuts
.
dimensions
25
local
nextglue
=
nuts
.
traversers
.
glue
26 27
local
texsetdimen
=
tex
.
setdimen
28 29
local
v_none
=
interfaces
.
variables
.
none
30
local
v_auto
=
interfaces
.
variables
.
auto
31 32
local
method
=
v_none
33
local
distance
=
0
34 35
function
noads
.
handlers
.
align
(
h
)
36
if
method
~
=
v_none
then
37
if
method
=
=
v_auto
then
38
local
s
=
h
39
while
s
do
40
local
id
=
getid
(
s
)
41
local
n
=
getnext
(
s
)
42
if
id
=
=
penalty_code
and
getpenalty
(
s
)
=
=
1
then
43
setpenalty
(
s
,
0
)
44
if
n
and
getid
(
n
)
=
=
glue_code
then
45
s
=
n
46
n
=
getnext
(
s
)
47
end
48
local
w
=
getdimensions
(
h
,
n
)
+
distance
49
texsetdimen
(
"
global
"
,
"
d_strc_math_indent
"
,
w
)
50
break
51
end
52
s
=
n
53
end
54
else
55
texsetdimen
(
"
global
"
,
"
d_strc_math_indent
"
,
distance
)
56
end
57
for
n
in
nextglue
,
h
do
58
setglue
(
n
,
getwidth
(
n
)
,
0
,
0
)
59
end
60
else
61
-- texsetdimen("global","d_strc_math_indent",0)
62
end
63
end
64 65
interfaces
.
implement
{
66
name
=
"
setmathhang
"
,
67
arguments
=
{
68
{
69
{
"
method
"
,
"
string
"
}
,
70
{
"
distance
"
,
"
dimension
"
}
,
71
}
72
}
,
73
actions
=
function
(
t
)
74
method
=
t
.
method
or
v_none
75
distance
=
t
.
distance
or
0
76
end
77
}
78 79
interfaces
.
implement
{
80
name
=
"
resetmathhang
"
,
81
actions
=
function
(
t
)
82
method
=
v_none
83
distance
=
0
84
end
85
}
86 87