diff options
author | Marius <mariausol@gmail.com> | 2013-10-07 13:20:14 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2013-10-07 13:20:14 +0300 |
commit | 44c1fc0eda825190cd117b7b16b60398d96a4cb7 (patch) | |
tree | 44544f401027add2f8f46c5c6e3e750e17971835 /tex/context/base/mlib-run.lua | |
parent | 498eb3a0485c5510695edfd678d587f07afe19c8 (diff) | |
download | context-44c1fc0eda825190cd117b7b16b60398d96a4cb7.tar.gz |
beta 2013.10.07 12:02
Diffstat (limited to 'tex/context/base/mlib-run.lua')
-rw-r--r-- | tex/context/base/mlib-run.lua | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tex/context/base/mlib-run.lua b/tex/context/base/mlib-run.lua index 1fc36dd80..e2585998e 100644 --- a/tex/context/base/mlib-run.lua +++ b/tex/context/base/mlib-run.lua @@ -589,3 +589,37 @@ function metapost.directrun(formatname,filename,outputformat,astable,mpdata) end end end + +-- goodie + +function metapost.quickanddirty(mpxformat,data) + if not data then + mpxformat = "metafun" + data = mpxformat + end + local code, bbox + local flusher = { + startfigure = function(n,llx,lly,urx,ury) + code = { } + bbox = { llx, lly, urx, ury } + end, + flushfigure = function(t) + for i=1,#t do + code[#code+1] = t[i] + end + end, + stopfigure = function() + end + } + local data = format("; beginfig(1) ;\n %s\n ; endfig ;",data) + metapost.process(mpxformat, { data }, false, flusher, false, false, "all") + if code then + return { + bbox = bbox or { 0, 0, 0, 0 }, + code = code, + data = data, + } + else + report_metapost("invalid quick and dirty run") + end +end |