lxml-inf.lua /size: 1509 b    last modification: 2020-07-01 14:35
1if not modules then modules = { } end modules ['lxml-inf'] = {
2    version   = 1.001,
3    comment   = "this module is the basis for the lxml-* ones",
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 file will be loaded runtime by x-pending.tex.
10
11local next, tostring, type = next, tostring, type
12local concat = table.concat
13
14local xmlwithelements = xml.withelements
15local getid = lxml.getid
16
17local status, stack
18
19local function get(e,d)
20    local ns   = e.ns
21    local tg   = e.tg
22    local name = tg
23    if ns ~= "" then name = ns .. ":" .. tg end
24    stack[d] = name
25    local ec = e.command
26    if ec == true then
27        ec = "system: text"
28    elseif ec == false then
29        ec = "system: skip"
30    elseif ec == nil then
31        ec = "system: not set"
32    elseif type(ec) == "string" then
33        ec = "setup: " .. ec
34    else -- function
35        ec = tostring(ec)
36    end
37    local tag = concat(stack," => ",1,d)
38    local s = status[tag]
39    if not s then
40        s = { }
41        status[tag] = s
42    end
43    s[ec] = (s[ec] or 0) + 1
44end
45
46local function get_command_status(id)
47    status, stack = {}, {}
48    if id then
49        xmlwithelements(getid(id),get)
50        return status
51    else
52        local t = { }
53        for id, _ in next, loaded do
54            t[id] = get_command_status(id)
55        end
56        return t
57    end
58end
59
60lxml.get_command_status = get_command_status
61