task-ini.lua /size: 15 Kb    last modification: 2021-10-28 13:50
1if not modules then modules = { } end modules ['task-ini'] = {
2    version   = 1.001,
3    comment   = "companion to task-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-- this is a temporary solution, we need to isolate some modules and then
10-- the load order can determine the trickery to be applied to node lists
11--
12-- we can disable more handlers and enable then when really used (*)
13--
14-- todo: two finalizers: real shipout (can be imposed page) and page shipout (individual page)
15--
16-- todo: consider moving the kernel kerning/ligaturing functions in the main font loop because
17-- there we know if they are needed; doesn't save time but; if we overload unh* commands to
18-- not apply the font handler, we can remove all checks for subtypes 255
19
20local tasks           = nodes.tasks
21local appendaction    = tasks.appendaction
22local disableaction   = tasks.disableaction
23local enableaction    = tasks.enableaction
24local freezegroup     = tasks.freezegroup
25local freezecallbacks = callbacks.freeze
26
27------------("processors",   "before",      "nodes.properties.attach",                          nil, "nut",    "enabled"   )
28
29appendaction("processors",   "normalizers", "typesetters.periodkerns.handler",                  nil, "nut",    "disabled"  )
30appendaction("processors",   "normalizers", "languages.replacements.handler",                   nil, "nut",    "disabled"  )
31appendaction("processors",   "normalizers", "typesetters.wrappers.handler",                     nil, "nut",    "disabled"  )
32appendaction("processors",   "normalizers", "typesetters.characters.handler",                   nil, "nut",    "enabled"   )
33appendaction("processors",   "normalizers", "fonts.collections.process",                        nil, "nut",    "disabled"  )
34appendaction("processors",   "normalizers", "fonts.checkers.missing",                           nil, "nut",    "disabled"  )
35
36appendaction("processors",   "characters",  "scripts.autofontfeature.handler",                  nil, "nut",    "disabled"  )
37appendaction("processors",   "characters",  "scripts.splitters.handler",                        nil, "nut",    "disabled"  )
38appendaction("processors",   "characters",  "typesetters.cleaners.handler",                     nil, "nut",    "disabled"  )
39appendaction("processors",   "characters",  "typesetters.directions.handler",                   nil, "nut",    "disabled"  )
40appendaction("processors",   "characters",  "typesetters.cases.handler",                        nil, "nut",    "disabled"  )
41appendaction("processors",   "characters",  "typesetters.breakpoints.handler",                  nil, "nut",    "disabled"  )
42appendaction("processors",   "characters",  "scripts.injectors.handler",                        nil, "nut",    "disabled"  )
43
44appendaction("processors",   "words",       "languages.words.check",                            nil, "nut",    "disabled"  )
45appendaction("processors",   "words",       "languages.hyphenators.handler",                    nil, "nut",    "enabled"   )
46appendaction("processors",   "words",       "typesetters.initials.handler",                     nil, "nut",    "disabled"  )
47appendaction("processors",   "words",       "typesetters.firstlines.handler",                   nil, "nut",    "disabled"  )
48
49appendaction("processors",   "fonts",       "builders.paragraphs.solutions.splitters.split",    nil, "nut",    "disabled"  )
50appendaction("processors",   "fonts",       "nodes.handlers.characters",                        nil, "nut",    "enabled"   )
51appendaction("processors",   "fonts",       "nodes.injections.handler",                         nil, "nut",    "enabled"   )
52appendaction("processors",   "fonts",       "typesetters.fontkerns.handler",                    nil, "nut",    "disabled"  )
53appendaction("processors",   "fonts",       "nodes.handlers.protectglyphs",                     nil, "nonut",  "enabled"   )
54appendaction("processors",   "fonts",       "builders.kernel.ligaturing",                       nil, "nut",    "disabled"  )
55appendaction("processors",   "fonts",       "builders.kernel.kerning",                          nil, "nut",    "disabled"  )
56appendaction("processors",   "fonts",       "nodes.handlers.show",                              nil, "nut",    "disabled"  )
57appendaction("processors",   "fonts",       "nodes.handlers.stripping",                         nil, "nut",    "disabled"  )
58appendaction("processors",   "fonts",       "nodes.handlers.flatten",                           nil, "nut",    "disabled"  )
59appendaction("processors",   "fonts",       "fonts.goodies.colorschemes.coloring",              nil, "nut",    "disabled"  )
60
61appendaction("processors",   "lists",       "typesetters.rubies.check",                         nil, "nut",    "disabled"  )
62appendaction("processors",   "lists",       "typesetters.characteralign.handler",               nil, "nut",    "disabled"  )
63appendaction("processors",   "lists",       "typesetters.spacings.handler",                     nil, "nut",    "disabled"  )
64appendaction("processors",   "lists",       "typesetters.kerns.handler",                        nil, "nut",    "disabled"  )
65appendaction("processors",   "lists",       "typesetters.digits.handler",                       nil, "nut",    "disabled"  )
66appendaction("processors",   "lists",       "typesetters.italics.handler",                      nil, "nut",    "disabled"  )
67appendaction("processors",   "lists",       "languages.visualizediscretionaries",               nil, "nut",    "disabled"  )
68appendaction("processors",   "lists",       "nodes.handlers.migrate",                           nil, "nut",    "disabled"  )
69
70appendaction("processors",   "after",       "typesetters.marksuspects",                         nil, "nut",    "disabled"  )
71
72appendaction("shipouts",     "normalizers", "nodes.handlers.cleanuppage",                       nil, "nut",    "production")
73appendaction("shipouts",     "normalizers", "typesetters.showsuspects",                         nil, "nut",    "disabled"  )
74appendaction("shipouts",     "normalizers", "typesetters.margins.finalhandler",                 nil, "nut",    "disabled"  )
75appendaction("shipouts",     "normalizers", "builders.paragraphs.expansion.trace",              nil, "nut",    "disabled"  )
76appendaction("shipouts",     "normalizers", "typesetters.alignments.handler",                   nil, "nut",    "disabled"  )
77appendaction("shipouts",     "normalizers", "nodes.references.handler",                         nil, "nut",    "production")
78appendaction("shipouts",     "normalizers", "nodes.destinations.handler",                       nil, "nut",    "production")
79appendaction("shipouts",     "normalizers", "nodes.rules.handler",                              nil, "nut",    "disabled"  )
80appendaction("shipouts",     "normalizers", "nodes.shifts.handler",                             nil, "nut",    "disabled"  )
81appendaction("shipouts",     "normalizers", "structures.tags.handler",                          nil, "nut",    "disabled"  )
82appendaction("shipouts",     "normalizers", "nodes.handlers.accessibility",                     nil, "nut",    "disabled"  )
83appendaction("shipouts",     "normalizers", "nodes.handlers.backgrounds",                       nil, "nut",    "disabled"  )
84appendaction("shipouts",     "normalizers", "typesetters.rubies.attach",                        nil, "nut",    "disabled"  )
85------------("shipouts",     "normalizers", "nodes.properties.delayed",                         nil, "nut",    "production")
86
87appendaction("shipouts",     "finishers",   "nodes.visualizers.handler",                        nil, "nut",    "disabled"  )
88appendaction("shipouts",     "finishers",   "attributes.colors.handler",                        nil, "nut",    "disabled"  )
89appendaction("shipouts",     "finishers",   "attributes.transparencies.handler",                nil, "nut",    "disabled"  )
90appendaction("shipouts",     "finishers",   "attributes.colorintents.handler",                  nil, "nut",    "disabled"  )
91appendaction("shipouts",     "finishers",   "attributes.negatives.handler",                     nil, "nut",    "disabled"  )
92appendaction("shipouts",     "finishers",   "attributes.effects.handler",                       nil, "nut",    "disabled"  )
93appendaction("shipouts",     "finishers",   "attributes.alternates.handler",                    nil, "nut",    "disabled"  )
94appendaction("shipouts",     "finishers",   "attributes.viewerlayers.handler",                  nil, "nut",    "disabled"  )
95
96appendaction("shipouts",     "wrapup",      "nodes.handlers.export",                            nil, "nut",    "disabled"  )  -- always last
97appendaction("shipouts",     "wrapup",      "luatex.synctex.collect",                           nil, "nut",    "disabled"  )
98
99appendaction("math",         "normalizers", "noads.handlers.showtree",                          nil, "nonut",  "disabled"  )
100appendaction("math",         "normalizers", "noads.handlers.unscript",                          nil, "nonut",  "enabled"   )
101appendaction("math",         "normalizers", "noads.handlers.unstack",                           nil, "nonut",  "disabled"  )
102appendaction("math",         "normalizers", "noads.handlers.variants",                          nil, "nonut",  "enabled"   )
103appendaction("math",         "normalizers", "noads.handlers.relocate",                          nil, "nonut",  "enabled"   )
104appendaction("math",         "normalizers", "noads.handlers.families",                          nil, "nonut",  "enabled"   )
105appendaction("math",         "normalizers", "noads.handlers.render",                            nil, "nonut",  "enabled"   )
106appendaction("math",         "normalizers", "noads.handlers.collapse",                          nil, "nonut",  "disabled"  )
107appendaction("math",         "normalizers", "noads.handlers.fixscripts",                        nil, "nonut",  "enabled"   )
108appendaction("math",         "normalizers", "noads.handlers.domains",                           nil, "nonut",  "disabled"  )
109appendaction("math",         "normalizers", "noads.handlers.autofences",                        nil, "nonut",  "disabled"  )
110appendaction("math",         "normalizers", "noads.handlers.resize",                            nil, "nonut",  "enabled"   )
111------------("math",         "normalizers", "noads.handlers.respace",                           nil, "nonut",  "enabled"   )
112appendaction("math",         "normalizers", "noads.handlers.alternates",                        nil, "nonut",  "enabled"   )
113appendaction("math",         "normalizers", "noads.handlers.tags",                              nil, "nonut",  "disabled"  )
114appendaction("math",         "normalizers", "noads.handlers.italics",                           nil, "nonut",  "disabled"  )
115appendaction("math",         "normalizers", "noads.handlers.kernpairs",                         nil, "nonut",  "disabled"  )
116appendaction("math",         "normalizers", "noads.handlers.classes",                           nil, "nonut",  "disabled"  )
117
118appendaction("math",         "builders",    "builders.kernel.mlisttohlist",                     nil, "nut",    "enabled"   )  -- mandate
119appendaction("math",         "builders",    "typesetters.directions.processmath",               nil, "nut",    "disabled"  )
120appendaction("math",         "builders",    "noads.handlers.makeup",                            nil, "nonut",  "disabled"  )
121appendaction("math",         "builders",    "noads.handlers.align",                             nil, "nonut",  "enabled"   )
122
123appendaction("finalizers",   "lists",       "typesetters.paragraphs.normalize",                 nil, "nut",    "enabled"   ) -- "disabled"
124appendaction("finalizers",   "lists",       "nodes.handlers.showhyphenation",                   nil, "nut",    "disabled"  )
125appendaction("finalizers",   "lists",       "nodes.handlers.visualizehyphenation",              nil, "nut",    "disabled"  )
126
127appendaction("finalizers",   "lists",       "typesetters.margins.localhandler",                 nil, "nut",    "disabled"  )
128appendaction("finalizers",   "lists",       "builders.paragraphs.keeptogether",                 nil, "nut",    "disabled"  )
129appendaction("finalizers",   "fonts",       "builders.paragraphs.solutions.splitters.optimize", nil, "nonut",  "disabled"  )
130appendaction("finalizers",   "lists",       "builders.paragraphs.tag",                          nil, "nut",    "disabled"  )
131appendaction("finalizers",   "lists",       "nodes.linefillers.handler",                        nil, "nut",    "disabled"  )
132
133
134appendaction("contributers", "normalizers", "nodes.handlers.flattenline",                       nil, "nut",    "disabled"  )
135appendaction("contributers", "normalizers", "nodes.handlers.textbackgrounds",                   nil, "nut",    "disabled"  )
136
137
138appendaction("vboxbuilders", "normalizers", "nodes.handlers.backgroundsvbox",                   nil, "nut",    "disabled"  )
139------------("vboxbuilders", "normalizers", "typesetters.margins.localhandler",                 nil, "nut",    "disabled"  )
140appendaction("vboxbuilders", "normalizers", "builders.vspacing.vboxhandler",                    nil, "nut",    "enabled"   )
141appendaction("vboxbuilders", "normalizers", "builders.profiling.vboxhandler",                   nil, "nut",    "disabled"  )
142appendaction("vboxbuilders", "normalizers", "typesetters.checkers.handler",                     nil, "nut",    "disabled"  )
143
144appendaction("mvlbuilders",  "normalizers", "nodes.handlers.backgroundspage",                   nil, "nut",    "disabled"  )
145appendaction("mvlbuilders",  "normalizers", "typesetters.margins.globalhandler",                nil, "nut",    "disabled"  )
146appendaction("mvlbuilders",  "normalizers", "nodes.handlers.migrate",                           nil, "nut",    "disabled"  )
147appendaction("mvlbuilders",  "normalizers", "builders.vspacing.pagehandler",                    nil, "nut",    "enabled"   )
148appendaction("mvlbuilders",  "normalizers", "builders.profiling.pagehandler",                   nil, "nut",    "disabled"  )
149appendaction("mvlbuilders",  "normalizers", "typesetters.checkers.handler",                     nil, "nut",    "disabled"  )
150
151appendaction("everypar",     "normalizers", "nodes.handlers.checkparcounter",                   nil, "nut",    "disabled"  )
152
153-- some protection
154
155freezecallbacks("find_.*_file", "find file using resolver")
156freezecallbacks("read_.*_file", "read file at once")
157freezecallbacks("open_.*_file", "open file for reading")
158
159-- experimental:
160
161freezegroup("processors",   "normalizers")
162freezegroup("processors",   "characters")
163freezegroup("processors",   "words")
164freezegroup("processors",   "fonts")
165freezegroup("processors",   "lists")
166
167freezegroup("finalizers",   "normalizers")
168freezegroup("finalizers",   "fonts")
169freezegroup("finalizers",   "lists")
170
171freezegroup("math",         "normalizers")
172freezegroup("math",         "builders")
173
174freezegroup("shipouts",     "normalizers")
175freezegroup("shipouts",     "finishers")
176freezegroup("shipouts",     "wrapup")
177
178freezegroup("mvlbuilders",  "normalizers")
179freezegroup("vboxbuilders", "normalizers")
180
181-----------("parbuilders",  "lists")
182-----------("pagebuilders", "lists")
183
184freezegroup("math",         "normalizers")
185freezegroup("math",         "builders")
186
187freezegroup("everypar",     "normalizers")
188
189-- new: disabled here
190
191directives.register("nodes.basepass", function(v)
192    if v then
193         enableaction("processors",  "builders.kernel.ligaturing")
194         enableaction("processors",  "builders.kernel.kerning")
195    else
196         disableaction("processors", "builders.kernel.ligaturing")
197         disableaction("processors", "builders.kernel.kerning")
198    end
199end)
200