s-structure-sections.mkiv /size: 2006 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [      file=s-structure-sections,
3%D        version=2015.02.02,
4%D          title=\CONTEXT\ Style File,
5%D       subtitle=Show Structure Sections,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\unprotect
15
16\startluacode
17    local context = context
18    local ctx_NC, ctx_NR = context.NC, context.NR
19    local ctx_bold = context.bold
20
21    structures.tracers = structures.tracers or { }
22
23    function structures.tracers.showsections()
24
25        local list = structures.sections.registered
26        local keys = table.keys(list)
27        table.sort(keys,function(a,b)
28            local la, lb = list[a].level, list[b].level
29            if la == lb then
30                return a < b
31            else
32                return la < lb
33            end
34        end)
35        context.start()
36        context.switchtobodyfont { "tt" }
37        context.starttabulate { "||c||||" }
38        context.FL()
39        ctx_NC() ctx_bold("name")
40        ctx_NC() ctx_bold("level")
41        ctx_NC() ctx_bold("parent")
42        ctx_NC() ctx_bold("section")
43        ctx_NC() ctx_bold("coupling")
44        ctx_NC() context.NR()
45        context.ML()
46        for i=1,#keys do
47            local k = keys[i]
48            local v = list[k]
49            ctx_NC() ctx_bold(k)
50            ctx_NC() context(v.level)
51            ctx_NC() context(v.parent)
52            ctx_NC() context(v.section)
53            ctx_NC() context(v.coupling)
54            ctx_NC() context.NR()
55        end
56        context.LL()
57        context.stoptabulate()
58        context.stop()
59
60    end
61\stopluacode
62
63
64\starttexdefinition showstructuresections
65
66    % no settings yet
67
68    \ctxlua{structures.tracers.showsections()}
69
70\stoptexdefinition
71
72\protect
73
74\continueifinputfile{s-structure-sections.mkiv}
75
76\starttext
77
78    \showstructuresections
79
80\stoptext
81