diff options
author | Karl Berry <karl@freefriends.org> | 2018-03-20 22:10:59 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-03-20 22:10:59 +0000 |
commit | 65d009a0596b194597f47531523addd3e64ed005 (patch) | |
tree | e13bd9beecf63e26491a66aa7a8fa702482f0067 /Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua | |
parent | d1a186333ced7b341e26877907343f08211199f7 (diff) |
context [current] (20mar18)
git-svn-id: svn://tug.org/texlive/trunk@47050 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua index 96eb27cbd18..0ff28c1c4e0 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/mlib-ctx.lua @@ -6,12 +6,10 @@ if not modules then modules = { } end modules ['mlib-ctx'] = { license = "see context related readme files", } --- for the moment we have the scanners here but they migh tbe moved to --- the other modules - local type, tostring = type, tostring local format, concat = string.format, table.concat local settings_to_hash = utilities.parsers.settings_to_hash +local formatters = string.formatters local report_metapost = logs.reporter("metapost") @@ -20,9 +18,8 @@ local stoptiming = statistics.stoptiming local mplib = mplib -metapost = metapost or {} +metapost = metapost or { } local metapost = metapost - local context = context local setters = tokens.setters @@ -87,10 +84,6 @@ function metapost.getextensions(instance,state) end end --- function commands.getmpextensions(instance,state) --- context(metapost.getextensions(instance,state)) --- end - implement { name = "setmpextensions", actions = metapost.setextensions, @@ -139,7 +132,7 @@ implement { end } --- metapost.variables = { } -- to be stacked +-- metapost.variables = { } -- to be stacked implement { name = "mprunvar", @@ -202,6 +195,39 @@ function metapost.graphic(specification) metapost.graphic_base_pass(setmpsformat(specification)) end +function metapost.startgraphic(t) + if not t then + t = { } + end + if not t.instance then + t.instance = metapost.defaultinstance + end + if not t.format then + t.format = metapost.defaultformat + end + if not t.method then + t.method = metapost.defaultmethod + end + if not t.definitions then + t.definitions = "" + end + t.data = { } + return t +end + +function metapost.stopgraphic(t) + if t then + t.data = concat(t.data or { },"\n") + metapost.graphic(t) + t.data = "" + end +end + +function metapost.tographic(t,f,s,...) + local d = t.data + d[#d+1] = s and formatters[f](s,...) or f +end + implement { name = "mpgraphic", actions = metapost.graphic, |