summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/mtx-context-setups.tex
blob: be99211ba1b131a35923ca41ba7314f2f2d16b33 (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
%D \module
%D   [       file=mtx-context-setups,
%D        version=2016.04.05,
%D          title=\CONTEXT\ Command Overvews,
%D       subtitle=Combine Files,
%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.

% begin help
%
% usage: context --extra=setups [options] [categories]
%
% --interface              : user interface (en, nl, etc)
% --overview [--save]      : use collection of files
% --list                   : show know collections
%
% end help

\input mtx-context-common.tex

\starttext

\startluacode
    local report_setups = logs.reporter("setups")

    context.starttext()

    if document.arguments.list then
        local okay = resolvers.findfile("context.mkiv") or "" -- will become an i file
        if okay ~= "" then
            okay = file.collapsepath(okay,true)
            okay = string.gsub(okay,"/base/","/interface/")
            okay = string.gsub(okay,"/sources/","/interface/")
            local path    = file.pathpart(okay)
            local pattern = file.join(path,"i-*.xml")
            local files   = dir.glob(pattern)
            local valid   = { }
            table.sort(files)
            for i=1,#files do
                local name = file.nameonly(files[i])
                local base = string.match(name,"^i%-([a-z]+)$")
                if base then
                    valid[#valid+1] = base
                end
            end
            if #valid > 0 then
                report_setups("% t",valid)
            end
            context.bold("available setup groups: ")
            context("%, t.",valid)
        end
    elseif document.arguments.overview then
        if document.arguments.save then
            context.enablemode { "setups:save" }
        end
        context.input("x-setups-overview.mkiv")
    elseif #document.files > 0 then
        context.usemodule { "x-setups-basics" }
        for i=1,#document.files do
            local filename = "i-" .. document.files[i]
            report_setups("processing %a",filename)
            context.loadsetups { filename }
        end
        context.input("x-setups-proofing.mkiv")
    else
        context("no setups")
    end

    context.stoptext()
\stopluacode

\stoptext