publ-inc.lua /size: 2078 b    last modification: 2025-02-21 11:03
1if not modules then modules = { } end modules ['publ-inc'] = {
2    version   = 1.001,
3    comment   = "this module part of publication support",
4    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5    copyright = "PRAGMA ADE / ConTeXt Development Team",
6    license   = "see context related readme files"
7}
8
9local fullstrip = string.fullstrip
10local datasets, savers = publications.datasets, publications.savers
11local assignbuffer = buffers.assign
12
13interfaces.implement {
14    name      = "btxentrytobuffer",
15    arguments = "3 strings",
16    actions   = function(dataset,tag,target)
17        local d = datasets[dataset]
18        if d then
19            d = d.luadata[tag]
20        end
21        if d then
22            d = fullstrip(savers.bib(dataset,false,{ [tag] = d }))
23        end
24        assignbuffer(target,d or "")
25    end
26}
27
28do
29
30    local expandmacro = token.expandmacro
31    local nodelisttoutf = nodes.toutf
32    local texgetbox = tex.getbox
33    local settings_to_array = utilities.parsers.settings_to_array
34
35    local meanings        = { }
36    local done            = { }
37    publications.meanings = meanings
38
39    table.setmetatableindex(meanings,function(t,k)
40        expandmacro("publ_cite_set_meaning",true,k)
41        local v = nodelisttoutf(texgetbox("b_btx_cmd").list)
42        t[k] = v
43        return v
44    end)
45
46    interfaces.implement {
47        name      = "btxentrytostring",
48        public    = true,
49        protected = true,
50        arguments = "3 strings",
51        actions   = function(command,again,tag)
52            -- we need to collect multiple
53            local set = settings_to_array(tag)
54            for i=1,#set do
55                tag = set[i]
56                if i > 1 then
57                    context.thinspace()
58                end
59                local meaning = meanings[tag]
60                if done[tag] then
61                    context[again]( { "publ:" .. tag } )
62                else
63                    context[command]( { "publ:" .. tag }, meaning )
64                    done[tag] = true
65                end
66            end
67        end
68    }
69
70end
71