diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/node-par.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/node-par.lua | 63 |
1 files changed, 39 insertions, 24 deletions
diff --git a/Master/texmf-dist/tex/context/base/node-par.lua b/Master/texmf-dist/tex/context/base/node-par.lua index 7be7e7917ca..b0879c7506b 100644 --- a/Master/texmf-dist/tex/context/base/node-par.lua +++ b/Master/texmf-dist/tex/context/base/node-par.lua @@ -6,28 +6,43 @@ if not modules then modules = { } end modules ['node-par'] = { license = "see context related readme files" } -parbuilders = parbuilders or { } +local builders, nodes, node = builders, nodes, node + +builders.paragraphs = builders.paragraphs or { } +local parbuilders = builders.paragraphs + parbuilders.constructors = parbuilders.constructors or { } -parbuilders.names = parbuilders.names or { } -parbuilders.numbers = parbuilders.numbers or { } -parbuilders.attribute = attributes.numbers['parbuilder'] or 999 +local constructors = parbuilders.constructors + +constructors.names = constructors.names or { } +local names = constructors.names + +constructors.numbers = constructors.numbers or { } +local numbers = constructors.numbers + +constructors.methods = constructors.methods or { } +local methods = constructors.methods + +local p_attribute = attributes.numbers['parbuilder'] or 999 +constructors.attribute = p_attribute -storage.register("parbuilders.names", parbuilders.names, "parbuilders.names") -storage.register("parbuilders.numbers", parbuilders.numbers, "parbuilders.numbers") +local has_attribute = node.has_attribute +local starttiming = statistics.starttiming +local stoptiming = statistics.stoptiming -local constructors, names, numbers, p_attribute = parbuilders.constructors, parbuilders.names, parbuilders.numbers, parbuilders.attribute +storage.register("builders/paragraphs/constructors/names", names, "builders.paragraphs.constructors.names") +storage.register("builders/paragraphs/constructors/numbers", numbers, "builders.paragraphs.constructors.numbers") -local has_attribute = node.has_attribute -local starttiming, stoptiming = statistics.starttiming, statistics.stoptiming +local report_parbuilders = logs.reporter("parbuilders") local mainconstructor = nil -- not stored in format -function parbuilders.register(name,number) - parbuilders.names[number] = name - parbuilders.numbers[name] = number +function constructors.register(name,number) + names[number] = name + numbers[name] = number end -function parbuilders.setmain(name) +function constructors.set(name) mainconstructor = numbers[name] end @@ -37,19 +52,19 @@ end -- false : idem but dangerous -- head : list of valid vmode nodes with last being hlist -function parbuilders.constructor(head,followed_by_display) +function constructors.handler(head,followed_by_display) if type(head) == "boolean" then return head else local attribute = has_attribute(head,p_attribute) or mainconstructor if attribute then - local constructor = names[attribute] - if constructor then - local handler = constructor and constructors[constructor] + local method = names[attribute] + if method then + local handler = methods[method] if handler then return handler(head,followed_by_display) else - logs.report("parbuilders","handler '%s' is not defined",tostring(constructor)) + report_parbuilders("contructor method '%s' is not defined",tostring(method)) return true -- let tex break end end @@ -60,28 +75,28 @@ end -- just for testing -function parbuilders.constructors.default(head,followed_by_display) +function constructors.methods.default(head,followed_by_display) return true -- let tex break end -- also for testing (no surrounding spacing done) -function parbuilders.constructors.oneline(head,followed_by_display) +function constructors.methods.oneline(head,followed_by_display) return node.hpack(head) end -- It makes no sense to have a sequence here as we already have -- pre and post hooks and only one parbuilder makes sense, so no: -- --- local actions = tasks.actions("parbuilders",1) +-- local actions = nodes.tasks.actions("parbuilders") -- todo: enable one as main -local actions = parbuilders.constructor +local actions = constructors.handler local enabled = false -function parbuilders.enable () enabled = true end -function parbuilders.disable() enabled = false end +function constructors.enable () enabled = true end +function constructors.disable() enabled = false end local function processor(head,followed_by_display) if enabled then |