summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkiv/s-structure-sections.mkiv
blob: daaab5abcd078a6b64229a14107cf10b15d42559 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
%D \module
%D   [      file=s-structure-sections,
%D        version=2015.02.02,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Show Structure Sections,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\unprotect

\startluacode
    local context = context
    local ctx_NC, ctx_NR = context.NC, context.NR
    local ctx_bold = context.bold

    structures.tracers = structures.tracers or { }

    function structures.tracers.showsections()

        local list = structures.sections.registered
        local keys = table.keys(list)
        table.sort(keys,function(a,b)
            local la, lb = list[a].level, list[b].level
            if la == lb then
                return a < b
            else
                return la < lb
            end
        end)
        context.start()
        context.switchtobodyfont { "tt" }
        context.starttabulate { "||c||||" }
        context.FL()
        ctx_NC() ctx_bold("name")
        ctx_NC() ctx_bold("level")
        ctx_NC() ctx_bold("parent")
        ctx_NC() ctx_bold("section")
        ctx_NC() ctx_bold("coupling")
        ctx_NC() context.NR()
        context.ML()
        for i=1,#keys do
            local k = keys[i]
            local v = list[k]
            ctx_NC() ctx_bold(k)
            ctx_NC() context(v.level)
            ctx_NC() context(v.parent)
            ctx_NC() context(v.section)
            ctx_NC() context(v.coupling)
            ctx_NC() context.NR()
        end
        context.LL()
        context.stoptabulate()
        context.stop()

    end
\stopluacode


\starttexdefinition showstructuresections

    % no settings yet

    \ctxlua{structures.tracers.showsections()}

\stoptexdefinition

\protect

\continueifinputfile{s-structure-sections.mkiv}

\starttext

    \showstructuresections

\stoptext