1if not modules then modules = { } end modules ['m-asymptote'] = {
2 version = 1.001,
3 comment = "companion to m-asymptote.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
9
10
11local context = context
12local replacesuffix = file.replacesuffix
13
14moduledata = moduledata or { }
15moduledata.asymptote = { }
16
17sandbox.registerrunner {
18 name = "asymptote prc",
19 program = "asy",
20 method = "execute",
21 template = [[-noV -config="" -tex=context -outformat="prc" %filename%]],
22 checkers = { filename = "readable" },
23}
24
25sandbox.registerrunner {
26 name = "asymptote pdf",
27 program = "asy",
28 method = "execute",
29 template = [[-noV -config="" -tex=context -outformat="pdf" %filename%]],
30 checkers = { filename = "readable" },
31}
32
33function moduledata.asymptote.process(name,type)
34 if type == "prc" then
35 local result = buffers.run(name,false,"asymptote prc","prc")
36 local jsdata = { js = replacesuffix(result,"js") }
37 local parset = parametersets[name]
38 if parset then
39
40 setmetatableindex(parset,jsdata)
41 else
42 parametersets[name] = jsdata
43 end
44 context(result)
45 else
46 local result = buffers.run(name,false,"asymptote pdf","pdf")
47 context(result)
48 end
49end
50 |