publ-imp-default.lua /size: 4460 b    last modification: 2020-07-01 14:35
1-- For the moment I put this here as example. When writing the publication modules we
2-- explored several approached: pure tex, pure lua, a mix with xml, etc. In the end
3-- each has advantages and drawbacks so we ended up with readable tex plus helpers in
4-- lua. Anyway here is a lua variant of a setup ... it doesn't look nicer. An alternative
5-- can be to build a table with characters but then we need to pass left, right and
6-- other separators so again no real gain.
7
8-- function publications.maybe.default.journal(currentdataset,currenttag)
9--     if publications.okay(currentdataset,currenttag,"journal") then
10--         context.btxspace()
11--         context.startbtxstyle("italic")
12--             commands.btxflush(currentdataset,currenttag,"expandedjournal -> journal")
13--         context.stopbtxstyle()
14--         if publications.okay(currentdataset,currenttag,"volume") then
15--             context.btxspace()
16--             commands.btxflush(currentdataset,currenttag,"volume")
17--             if publications.okay(currentdataset,currenttag,"number") then
18--                 context.ignorespaces()
19--                 context.btxleftparenthesis()
20--                 commands.btxflush(currentdataset,currenttag,"number")
21--                 context.btxrightparenthesis()
22--             end
23--         elseif publications.okay(currentdataset,currenttag,"number") then
24--             context.btxlabeltext("default:number")
25--             context.btxspace()
26--             commands.btxflush(currentdataset,currenttag,"number")
27--         end
28--         if publications.okay(currentdataset,currenttag,"pages") then
29--             context.btxcomma()
30--             commands.btxflush(currentdataset,currenttag,"pages")
31--         end
32--         context.btxcomma()
33--     end
34-- end
35
36return {
37    --
38    -- metadata
39    --
40    name      = "default",
41    version   = "1.00",
42    comment   = "DEFAULT specification",
43    author    = "Alan Braslau and Hans Hagen",
44    copyright = "ConTeXt development team",
45    --
46    -- derived (combinations of) fields (all share the same default set)
47    --
48    virtual = {
49        "authoryear",
50        "authoryears",
51        "authornum",
52        "num",
53        "suffix",
54    },
55    --
56    -- special datatypes
57    --
58    types = {
59        author   = "author",     -- interpreted as name(s)
60        editor   = "author",     -- interpreted as name(s)
61        page     = "pagenumber", -- number or range: f--t -- maybe just range
62        pages    = "pagenumber", -- number or range: f--t -- maybe just range
63        volume   = "range",      -- number or range: f--t
64        number   = "range",      -- number or range: f--t
65        keywords = "keyword",    -- comma|-|separated list
66    },
67    --
68    -- categories with their specific fields
69    --
70    categories = {
71        --
72        -- the following fields are for documentation and testing purposes
73        --
74        ["demo-a"] = {
75            sets     = {
76                author  = { "author", "institution", "organization" },
77            },
78            required = { "author", "title", "year" },
79            optional = { "subtitle" },
80        },
81        ["demo-b"] = {
82            sets     = {
83                authors = { "author", "institution", "organization" },
84            },
85            required = { "authors", "title", "year" },
86            optional = { "subtitle" },
87        },
88        --
89        -- we only provide article and book (maybe a few more later) and we keep it
90        -- real simple. See the apa and aps definitions for more extensive examples
91        --
92        article = {
93            sets = {
94                author = { "author", "editor" },
95            },
96            required = {
97                "author", -- a set
98                "year",
99            },
100            optional = {
101                "title",
102                "keywords",
103                "journal", "volume", "number", "pages",
104                "note",
105            },
106        },
107        book = {
108            sets = {
109                author     = { "author", "editor", },
110                editionset = { "edition", "volume", "number" },
111            },
112            required = {
113                "title",
114                "year",
115            },
116            optional = {
117                "author", -- a set
118                "subtitle",
119                "keywords",
120                "publisher", "address",
121                "editionset",
122                "note",
123            },
124        },
125    },
126}
127