grph-epd.lmt /size: 1989 b    last modification: 2023-12-21 09:44
1if not modules then modules = { } end modules ['grph-epd'] = {
2    version   = 1.001,
3    comment   = "companion to grph-epd.mkiv",
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 variables        = interfaces.variables
10local settings_to_hash = utilities.parsers.settings_to_hash
11local codeinjections   = backends.registered.pdf.codeinjections
12
13local trace  = false  trackers.register("figures.merging", function(v) trace = v end)
14
15local report = logs.reporter("backend","merging")
16
17local function mergegoodies(optionlist)
18    local options  = settings_to_hash(optionlist)
19    local yes      = options[variables.yes]
20    local all      = options[variables.all]
21    if next(options) then
22        report("% t",table.sortedkeys(options))
23    end
24    if all or yes or options[variables.reference] then
25        codeinjections.mergereferences(nil,options) -- first can be specification
26    end
27    if all or options[variables.comment] then
28        codeinjections.mergecomments()
29    end
30    if all or yes or options[variables.bookmark] then
31        codeinjections.mergebookmarks()
32    end
33    if all or options[variables.field] or options[variables.data] then
34        codeinjections.mergefields(nil,options[variables.data])
35    end
36    if all or options[variables.layer] then
37        codeinjections.mergeviewerlayers()
38    end
39    if all or options[variables.media] then
40        codeinjections.mergerenditions()
41    end
42    codeinjections.flushmergelayer()
43end
44
45function figures.mergegoodies(optionlist)
46    -- todo: we can use runlocal instead
47    context.stepwise(function()
48        -- we use stepwise because we might need to define symbols
49        -- for stamps that have no default appearance
50        mergegoodies(optionlist)
51    end)
52end
53
54interfaces.implement {
55    name      = "figure_mergegoodies",
56    actions   = figures.mergegoodies,
57    arguments = "string"
58}
59