summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/node-par.lua
blob: 56741e76511ed5b87b1ff22428f25034652893f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
if not modules then modules = { } end modules ['node-par'] = {
    version   = 1.001,
    comment   = "companion to node-ini.mkiv",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

local starttiming = statistics.starttiming
local stoptiming  = statistics.stoptiming

local sequencers  = utilities.sequencers

-- This are called a lot!

if LUATEXFUNCTIONALITY > 6857 then

    local actions = nodes.tasks.actions("everypar")

    local function everypar(head)
        starttiming(builders)
        head = actions(head)
        stoptiming(builders)
        return head
    end

    callbacks.register("insert_local_par",everypar,"after paragraph start")

end

if LUATEXFUNCTIONALITY > 6870 then

    local actions = sequencers.new {
        name         = "newgraf",
        arguments    = "mode,indented",
        returnvalues = "indented",
        results      = "indented",
    }

    sequencers.appendgroup(actions,"before") -- user
    sequencers.appendgroup(actions,"system") -- private
    sequencers.appendgroup(actions,"after" ) -- user

    local function newgraf(mode,indented)
        local runner = actions.runner
        if runner then
            starttiming(builders)
            indent = runner(mode,indented)
            stoptiming(builders)
        end
        return indented
    end

    callbacks.register("new_graf",newgraf,"before paragraph start")

end