summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkxl/m-json.mkxl
blob: b08286b08bb798e874585b845ab6bf15e4f2678e (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
%D \module
%D   [       file=m-json,
%D        version=2022.04.11, % 2012.08.03,
%D          title=\CONTEXT\ Modules,
%D       subtitle=Json,
%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.

\startmodule [json]

\registerctxluafile{util-jsn}{}
\registerctxluafile{util-tbs}{}

% \def\u#1#2#3#4{\cldcontext{utf.char(0x#1#2#3#4)}}

\startluacode

    local tablestore = utilities.tablestore

    interfaces.implement {
        name      = "loadtable",
        actions   = tablestore.load,
        arguments = { "optional", "optional" },
        public    = true,
        protected = true,
    }

    interfaces.implement {
        name      = "tablefield",
        actions   = { tablestore.field, context },
        arguments = "2 arguments",
        public    = true,
    }

    interfaces.implement {
        name      = "tablefielddefault",
        actions   = { tablestore.field, context },
        arguments = "3 arguments",
        public    = true,
    }

    utilities.json.field  = tablestore.field
    utilities.json.loaded = tablestore.loaded

\stopluacode

\let\loadjsonfile     \loadtable
\let\jsonfield        \tablefield
\let\jsonfielddefault \tablefielddefault

\stopmodule