1if not modules then modules = { } end modules ['node-par'] = {
2 version = 1.001,
3 comment = "companion to node-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
9local starttiming = statistics.starttiming
10local stoptiming = statistics.stoptiming
11
12local sequencers = utilities.sequencers
13
14
15
16
17
18
19do
20
21 local actions = nodes.tasks.actions("everypar")
22
23 local function everypar(head,mode)
24 starttiming(builders)
25 head = actions(head,mode)
26 stoptiming(builders)
27 return head
28 end
29
30 callbacks.register("insert_par",everypar,"after paragraph start")
31
32end
33
34
35
36
37
38do
39
40 local actions = sequencers.new {
41 name = "paragraph",
42 arguments = "mode,indented,context",
43 returnvalues = "indented",
44 results = "indented",
45 }
46
47 sequencers.appendgroup(actions,"before")
48 sequencers.appendgroup(actions,"system")
49 sequencers.appendgroup(actions,"after" )
50
51 local function paragraph(mode,indented,context)
52 local runner = actions.runner
53 if runner then
54 starttiming(builders)
55 indented = runner(mode,indented,context)
56 stoptiming(builders)
57 end
58 return indented
59 end
60
61 callbacks.register("begin_paragraph",paragraph,"before paragraph start")
62
63end
64
65
66
67
68
69
70
71do
72
73 local actions = sequencers.new {
74 name = "paragraphcontext",
75 arguments = "context",
76 returnvalues = "ignore",
77 results = "ignore",
78 }
79
80
81 sequencers.appendgroup(actions,"system")
82
83
84 local function parcontext(parcontext)
85 local runner = actions.runner
86 if runner then
87 starttiming(builders)
88 local ignore = runner(parcontext)
89 stoptiming(builders)
90 return ignore
91 end
92 end
93
94 callbacks.register("paragraph_context",parcontext,"when the context is dealt with")
95
96end
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119 |