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 nodecodes = nodes.nodecodes
11local hlist_code = nodecodes.hlist
12local penalty_code = nodecodes.penalty
13
14local nuts = nodes.nuts
15local getprev = nuts.getprev
16local getid = nuts.getid
17
18local getdepth = nuts.getdepth
19local newglue = nuts.pool.glue
20local insertafter = nuts.insertafter
21
22local texgetdimen = tex.getdimen
23
24
25
26local function correct_depth(head,tail)
27 local prev = getprev(tail)
28 if getid(prev) == penalty_code then
29 prev = getprev(prev)
30 end
31 if getid(prev) == hlist_code then
32 local delta = getdepth(tail) - getdepth(prev)
33 if delta > 0 then
34 head = insertafter(head,prev,newglue(delta))
35 end
36 tex.prevdepth = getdepth(tail)
37 end
38 return head
39end
40
41local function block_baselineskip(head,tail)
42
43 tex.prevdepth = texgetdimen("ignoredepthcriterion")
44 return head
45end
46
47local preactions = {
48 [1] = correct_depth,
49 [2] = block_baselineskip,
50}
51
52local postactions = {
53 [1] = correct_depth,
54 [2] = block_baselineskip,
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
80function nodes.handlers.adjusters(head,where,tail,index)
81 if where == "preadjust" then
82 local a = preactions[index]
83 if a then
84 head = a(head,tail)
85 end
86 else
87 local a = postactions[index]
88 if a then
89 head = a(head,tail)
90 end
91 end
92 return head
93end
94 |