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