summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-01-06 23:23:06 +0000
committerKarl Berry <karl@freefriends.org>2015-01-06 23:23:06 +0000
commit74e692423a7de7dd8025088ba676249e85443d9e (patch)
tree5c8d663c16667e533edbd602cf6096505ebb5c82
parentd9c7d6c59e9daf56e5fda7f969e0d6e90146d8d3 (diff)
luamplib (6jan15)
git-svn-id: svn://tug.org/texlive/trunk@35974 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/luatex/luamplib/NEWS7
-rw-r--r--Master/texmf-dist/doc/luatex/luamplib/luamplib.pdfbin135869 -> 137590 bytes
-rw-r--r--Master/texmf-dist/source/luatex/luamplib/luamplib.dtx85
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.lua38
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.sty12
5 files changed, 105 insertions, 37 deletions
diff --git a/Master/texmf-dist/doc/luatex/luamplib/NEWS b/Master/texmf-dist/doc/luatex/luamplib/NEWS
index 8f26a19aba9..fb6b3a71d09 100644
--- a/Master/texmf-dist/doc/luatex/luamplib/NEWS
+++ b/Master/texmf-dist/doc/luatex/luamplib/NEWS
@@ -1,5 +1,12 @@
History of the luamplib package
+2015/01/05 2.9.0
+ * after declaring `\mplibcodeinherit{enable}', each mplib code chunks
+ will inherit variables/constants/macros defined by previous chunks.
+ On the contrary, the default value `\mplibcodeinherit{disable}' will
+ treat each code chunks as an independent instance, never being affected
+ by other code chunks.
+
2014/07/04 2.8.1
* support color package on plain tex.
* fix a failure at `btex \% etex'.
diff --git a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf
index e99e6833521..cf176ee9f78 100644
--- a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf
+++ b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx b/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx
index 84de6b6ba18..c5374632c75 100644
--- a/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx
+++ b/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment -- by the way, this file contains UTF-8
%
-% Copyright (C) 2008-2014 by Hans Hagen, Taco Hoekwater, Elie Roux,
+% Copyright (C) 2008-2015 by Hans Hagen, Taco Hoekwater, Elie Roux,
% Manuel Pégourié-Gonnard, Philipp Gesang and Kim Dohyun.
% Currently maintained by the LuaLaTeX development team.
% Support: <lualatex-dev@tug.org>
@@ -85,7 +85,7 @@ See source file '\inFileName' for licencing and contact information.
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{luamplib.drv}%
- [2014/07/04 v2.8.1 Interface for using the mplib library]%
+ [2015/01/05 v2.9.0 Interface for using the mplib library]%
\documentclass{ltxdoc}
\usepackage{metalogo,multicol,mdwlist,fancyvrb,xspace}
\usepackage[x11names]{xcolor}
@@ -154,7 +154,7 @@ See source file '\inFileName' for licencing and contact information.
% \author{Hans Hagen, Taco Hoekwater, Elie Roux, Philipp Gesang and Kim Dohyun\\
% Maintainer: LuaLaTeX Maintainers ---
% Support: \email{lualatex-dev@tug.org}}
-% \date{2014/07/04 v2.8.1}
+% \date{2015/01/05 v2.9.0}
%
% \maketitle
%
@@ -290,6 +290,29 @@ See source file '\inFileName' for licencing and contact information.
% therefore will be typeset with current \TeX\ font.
% Also take care of |char| operator in the left side argument,
% as this might bring unpermitted characters into \TeX.
+% \item Starting with v2.9, |\mplibcodeinherit{enable}| enables the inheritance
+% of variables, constants, and macros defined by previous |mplibcode| chunks.
+% On the contrary, the default value |\mplibcodeinherit{disable}| will make
+% each code chunks being treated as an independent instance, and never
+% affected by previous code chunks.
+%
+% \textsc{n.b.} It does not work to pass across code chunks those variables
+% containing |btex ... etex| pictures, as these are not METAPOST, but \TeX\
+% elements from the standpoint of \textsf{luamplib}. Likewise, |graph.mp|
+% does not work properly with the inheritance functionality.
+% \begin{verbatim}
+% \mplibcodeinherit{enable}
+% \everymplib{ beginfig(0);} \everyendmplib{ endfig;}
+% A circle
+% \mplibcode
+% u := 10;
+% draw fullcircle scaled u;
+% \endmplibcode
+% and twice the size
+% \mplibcode
+% draw fullcircle scaled 2u;
+% \endmplibcode
+% \end{verbatim}
% \item At the end of package loading, \textsf{luamplib} searches
% |luamplib.cfg| and, if found, reads the file in automatically.
% Frequently used settings such as \cs{everymplib} or \cs{mplibcachedir}
@@ -327,8 +350,8 @@ luamplib.lastlog = ""
local err, warn, info, log = luatexbase.provides_module({
name = "luamplib",
- version = "2.8.1",
- date = "2014/07/04",
+ version = "2.9.0",
+ date = "2015/01/05",
description = "Lua package to typeset Metapost with LuaTeX's MPLib.",
})
@@ -675,6 +698,13 @@ else
math_mode = luamplib.numbersystem,
random_seed = randomseed,
}
+% \end{macrocode}
+% Append our own preamble to the preamble above.
+% \begin{macrocode}
+ local preamble = preamble .. luamplib.mplibcodepreamble
+ if luamplib.textextlabel then
+ preamble = preamble .. luamplib.textextlabelpreamble
+ end
local result
if not mpx then
result = { status = 99, error = "out of memory"}
@@ -714,7 +744,6 @@ end
local function process_indeed (mpx, data, indeed)
local converted, result = false, {}
- local mpx = luamplib.load(mpx)
if mpx and data then
result = mpx:execute(data)
local log = luamplib.reporterror(result)
@@ -741,11 +770,23 @@ local function process_indeed (mpx, data, indeed)
end
return converted, result
end
+
+% \end{macrocode}
+% v2.9 has introduced the concept of `code inherit'
+% \begin{macrocode}
+luamplib.codeinherit = false
+local mplibinstances = {}
local process = function (data,indeed)
- if not indeed then
- randomseed = math.random(65535)
+ local standalone, firstpass = not luamplib.codeinherit, not indeed
+ local currfmt = currentformat .. luamplib.numbersystem
+ currfmt = firstpass and currfmt or (currfmt.."2")
+ local mpx = mplibinstances[currfmt]
+ if standalone or not mpx then
+ randomseed = firstpass and math.random(65535) or randomseed
+ mpx = luamplib.load(currentformat)
+ mplibinstances[currfmt] = mpx
end
- return process_indeed(currentformat, data, indeed)
+ return process_indeed(mpx, data, indeed)
end
luamplib.process = process
@@ -965,6 +1006,7 @@ let VerbatimTeX = specialVerbatimTeX;
extra_beginfig := extra_beginfig & " let VerbatimTeX = ignoreVerbatimTeX;" ;
extra_endfig := extra_endfig & " let VerbatimTeX = specialVerbatimTeX;" ;
]]
+luamplib.mplibcodepreamble = mplibcodepreamble
local textextlabelpreamble = [[
primarydef s infont f = rawtextext(s) enddef;
@@ -977,6 +1019,7 @@ def fontsize expr f =
endgroup
enddef;
]]
+luamplib.textextlabelpreamble = textextlabelpreamble
local function protecttextext(data)
local everymplib = tex.toks['everymplibtoks'] or ''
@@ -1071,11 +1114,7 @@ local function makeTEXboxes (data)
data = stringgsub(data, "!!!!!LEFTBRCE!!!!!","{")
data = stringgsub(data, "!!!!!RGHTBRCE!!!!!","}")
data = stringgsub(data, "!!!!!SHARPE!!!!!", "#" )
- local preamble = mplibcodepreamble
- if luamplib.textextlabel then
- preamble = preamble .. textextlabelpreamble
- end
- local _,result = process(preamble .. data, false)
+ local _,result = process(data, false)
domakeTEXboxes(result)
return data
end
@@ -1099,11 +1138,7 @@ local function processwithTEXboxes (data)
num, box.height/factor,
num, box.depth /factor)
end
- local preamble = prepreamble .. mplibcodepreamble
- if luamplib.textextlabel then
- preamble = preamble .. textextlabelpreamble
- end
- process(preamble .. data, true)
+ process(prepreamble .. data, true)
end
luamplib.processwithTEXboxes = processwithTEXboxes
@@ -1578,7 +1613,7 @@ luamplib.colorconverter = colorconverter
\else
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{luamplib}
- [2014/07/04 v2.8.1 mplib package for LuaTeX]
+ [2015/01/05 v2.9.0 mplib package for LuaTeX]
\RequirePackage{luatexbase-modutils}
\fi
% \end{macrocode}
@@ -1775,6 +1810,16 @@ luamplib.colorconverter = colorconverter
\fi
\endgroup
}
+\def\mplibcodeinherit#1{%
+ \begingroup
+ \def\tempa{enable}\def\tempb{#1}%
+ \ifx\tempa\tempb
+ \directlua{luamplib.codeinherit = true}%
+ \else
+ \directlua{luamplib.codeinherit = false}%
+ \fi
+ \endgroup
+}
% \end{macrocode}
%
% We use a dedicated scratchbox.
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
index df329392c0b..3f9a7e7a904 100644
--- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
+++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
@@ -18,8 +18,8 @@ luamplib.lastlog = ""
local err, warn, info, log = luatexbase.provides_module({
name = "luamplib",
- version = "2.8.1",
- date = "2014/07/04",
+ version = "2.9.0",
+ date = "2015/01/05",
description = "Lua package to typeset Metapost with LuaTeX's MPLib.",
})
@@ -323,6 +323,10 @@ else
math_mode = luamplib.numbersystem,
random_seed = randomseed,
}
+ local preamble = preamble .. luamplib.mplibcodepreamble
+ if luamplib.textextlabel then
+ preamble = preamble .. luamplib.textextlabelpreamble
+ end
local result
if not mpx then
result = { status = 99, error = "out of memory"}
@@ -361,7 +365,6 @@ end
local function process_indeed (mpx, data, indeed)
local converted, result = false, {}
- local mpx = luamplib.load(mpx)
if mpx and data then
result = mpx:execute(data)
local log = luamplib.reporterror(result)
@@ -382,11 +385,20 @@ local function process_indeed (mpx, data, indeed)
end
return converted, result
end
+
+luamplib.codeinherit = false
+local mplibinstances = {}
local process = function (data,indeed)
- if not indeed then
- randomseed = math.random(65535)
+ local standalone, firstpass = not luamplib.codeinherit, not indeed
+ local currfmt = currentformat .. luamplib.numbersystem
+ currfmt = firstpass and currfmt or (currfmt.."2")
+ local mpx = mplibinstances[currfmt]
+ if standalone or not mpx then
+ randomseed = firstpass and math.random(65535) or randomseed
+ mpx = luamplib.load(currentformat)
+ mplibinstances[currfmt] = mpx
end
- return process_indeed(currentformat, data, indeed)
+ return process_indeed(mpx, data, indeed)
end
luamplib.process = process
@@ -588,6 +600,7 @@ let VerbatimTeX = specialVerbatimTeX;
extra_beginfig := extra_beginfig & " let VerbatimTeX = ignoreVerbatimTeX;" ;
extra_endfig := extra_endfig & " let VerbatimTeX = specialVerbatimTeX;" ;
]]
+luamplib.mplibcodepreamble = mplibcodepreamble
local textextlabelpreamble = [[
primarydef s infont f = rawtextext(s) enddef;
@@ -600,6 +613,7 @@ def fontsize expr f =
endgroup
enddef;
]]
+luamplib.textextlabelpreamble = textextlabelpreamble
local function protecttextext(data)
local everymplib = tex.toks['everymplibtoks'] or ''
@@ -690,11 +704,7 @@ local function makeTEXboxes (data)
data = stringgsub(data, "!!!!!LEFTBRCE!!!!!","{")
data = stringgsub(data, "!!!!!RGHTBRCE!!!!!","}")
data = stringgsub(data, "!!!!!SHARPE!!!!!", "#" )
- local preamble = mplibcodepreamble
- if luamplib.textextlabel then
- preamble = preamble .. textextlabelpreamble
- end
- local _,result = process(preamble .. data, false)
+ local _,result = process(data, false)
domakeTEXboxes(result)
return data
end
@@ -718,11 +728,7 @@ local function processwithTEXboxes (data)
num, box.height/factor,
num, box.depth /factor)
end
- local preamble = prepreamble .. mplibcodepreamble
- if luamplib.textextlabel then
- preamble = preamble .. textextlabelpreamble
- end
- process(preamble .. data, true)
+ process(prepreamble .. data, true)
end
luamplib.processwithTEXboxes = processwithTEXboxes
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
index ffee72280ff..60744698c6a 100644
--- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
+++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
@@ -14,7 +14,7 @@
\else
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{luamplib}
- [2014/07/04 v2.8.1 mplib package for LuaTeX]
+ [2015/01/05 v2.9.0 mplib package for LuaTeX]
\RequirePackage{luatexbase-modutils}
\fi
\RequireLuaModule{luamplib}
@@ -168,6 +168,16 @@
\fi
\endgroup
}
+\def\mplibcodeinherit#1{%
+ \begingroup
+ \def\tempa{enable}\def\tempb{#1}%
+ \ifx\tempa\tempb
+ \directlua{luamplib.codeinherit = true}%
+ \else
+ \directlua{luamplib.codeinherit = false}%
+ \fi
+ \endgroup
+}
\ifx\mplibscratchbox\undefined \newbox\mplibscratchbox \fi
\def\mplibstarttoPDF#1#2#3#4{%
\hbox\bgroup