1if not modules then modules = { } end modules ['typo-adj'] = {
2 version = 1.001,
3 optimize = true,
4 comment = "companion to typo-adj.mkxl",
5 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
6 copyright = "PRAGMA ADE / ConTeXt Development Team",
7 license = "see context related readme files"
8}
9
10local hlist_code <const> = nodes.nodecodes.hlist
11local penalty_code <const> = nodes.nodecodes.penalty
12
13local nuts = nodes.nuts
14local getprev = nuts.getprev
15local getid = nuts.getid
16
17local getdepth = nuts.getdepth
18local newglue = nuts.pool.glue
19local insertafter = nuts.insertafter
20
21local texgetdimen = tex.getdimen
22
23
24
25local function correct_depth(head,tail)
26 local prev = getprev(tail)
27 if getid(prev) == penalty_code then
28 prev = getprev(prev)
29 end
30 if getid(prev) == hlist_code then
31 local delta = getdepth(tail) - getdepth(prev)
32 if delta > 0 then
33 head = insertafter(head,prev,newglue(delta))
34 end
35 tex.prevdepth = getdepth(tail)
36 end
37 return head
38end
39
40local function block_baselineskip(head,tail)
41
42 tex.prevdepth = texgetdimen("ignoredepthcriterion")
43 return head
44end
45
46local preactions = {
47 [1] = correct_depth,
48 [2] = block_baselineskip,
49}
50
51local postactions = {
52 [1] = correct_depth,
53 [2] = block_baselineskip,
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
79function nodes.handlers.adjusters(head,where,tail,index)
80 if where == "preadjust" then
81 local a = preactions[index]
82 if a then
83 head = a(head,tail)
84 end
85 else
86 local a = postactions[index]
87 if a then
88 head = a(head,tail)
89 end
90 end
91 return head
92end
93 |