summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/modules/mkiv/m-asymptote.lua
blob: de8d032c8fbdb0bd3400e0a3409dfbe649036728 (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
if not modules then modules = { } end modules ['m-asymptote'] = {
    version   = 1.001,
    comment   = "companion to m-pstricks.mkiv",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

-- See m-asymptote.mkiv for some comment.

local context = context
local replacesuffix = file.replacesuffix

moduledata.asymptote = { }

sandbox.registerrunner {
    name     = "asymptote prc",
    program  = "asy",
    method   = "execute",
    template = '-noV -config="" -tex=context -outformat="prc" "%filename%"',
    checkers = { filename = "readable" },
}

sandbox.registerrunner {
    name     = "asymptote pdf",
    program  = "asy",
    method   = "execute",
    template = '-noV -config="" -tex=context -outformat="pdf" "%filename%"',
    checkers = { filename = "readable" },
}

function moduledata.asympote.process(name,type)
    if type == "prc" then
        local result = buffers.run(name,false,"asymptote prc","prc")
        local jsdata = { js = replacesuffix(result,"js") }
        local parset = parametersets[name]
        if parset then
            -- so we can overload at the tex end
            setmetatableindex(parset,jsdata)
        else
            parametersets[name] = jsdata
        end
        context(result)
    else
        local result = buffers.run(name,false,"asymptote pdf","pdf")
        context(result)
    end
end