diff options
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/luatex/luamplib/NEWS | 8 | ||||
-rw-r--r-- | Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf | bin | 151338 -> 153133 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex | 56 | ||||
-rw-r--r-- | Master/texmf-dist/source/luatex/luamplib/luamplib.dtx | 56 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/luamplib/luamplib.lua | 21 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/luamplib/luamplib.sty | 7 |
6 files changed, 124 insertions, 24 deletions
diff --git a/Master/texmf-dist/doc/luatex/luamplib/NEWS b/Master/texmf-dist/doc/luatex/luamplib/NEWS index 1fd97ca4f23..8f258c41f6b 100644 --- a/Master/texmf-dist/doc/luatex/luamplib/NEWS +++ b/Master/texmf-dist/doc/luatex/luamplib/NEWS @@ -1,5 +1,13 @@ History of the luamplib package +2022/01/09 2.22.0 + * Sergey Slyusarev (@jemmybutton) has suggested and contributed + a new feature for LaTeX mplibcode environment, which now supports + separately named MetaPost instances. Using this feature, + all the variables and functions are shared only among + all the environments belonging to the same instance. + (#99 and #100) + 2021/11/23 2.21.1 * address #97 (typesetting fails with "--lua" option) diff --git a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf Binary files differindex a2685b2b09e..aeefe5ca287 100644 --- a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf +++ b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf diff --git a/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex b/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex index dc06a9bd8fb..632dae44e67 100644 --- a/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex +++ b/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex @@ -164,6 +164,60 @@ diameter:\Dia bp.% rotatedlabel.top(textext("Rotated!"), origin, 45); endfig; \end{mplibcode}% - \tracingcommands0 + +\vskip 2\baselineskip +\mplibcodeinherit{disable}% + +\begin{mplibcode}[instanceOne] +beginfig(1); +a := 1cm; +draw fullcircle scaled a; +draw btex a circle with $d=a$ etex shifted (a,0); +endfig; +\end{mplibcode}% +Current instance name is: \currentmpinstancename \vskip 2\baselineskip + +\begin{mplibcode}[instanceTwo] +beginfig(1); +if not known a: + draw btex code is not inherited from an instance with a different name etex; +else: + errmessage("Variable was inherited from a different instance"); +fi; +endfig; +\end{mplibcode}% +Current instance name is: \currentmpinstancename \vskip 2\baselineskip + +\begin{mplibcode} +beginfig(1); +if not known a: + draw btex code is not inherited if instance name is not listed etex; +else: + errmessage("Variable was inherited from a different instance"); +fi; +a := 1cm; +endfig; +\end{mplibcode}% +Current instance name is: \currentmpinstancename (should be empty) \vskip 2\baselineskip + +\begin{mplibcode} +beginfig(1); +if not known a: + draw btex code is not inherited if mplibcodeinherit is disabled and instance name is not explicitly set etex; +else: + errmessage("Variable was inherited when code inheritance is turned off and instance name is not set"); +fi; +endfig; +\end{mplibcode}% +Current instance name is: \currentmpinstancename (should be empty) \vskip 2\baselineskip + +\begin{mplibcode}[instanceOne] +beginfig(1); +draw unitsquare scaled a; +draw btex a square with side $=a$, inherited from the same instance etex shifted (3/2a, 1/2a); +endfig; +\end{mplibcode}% +Current instance name is: \currentmpinstancename \vskip 2\baselineskip + \end{document} diff --git a/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx b/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx index 0966f32b98d..ae2f5d3a98b 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-2021 by Hans Hagen, Taco Hoekwater, Elie Roux, +% Copyright (C) 2008-2022 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}% - [2021/11/23 v2.21.1 Interface for using the mplib library]% + [2022/01/09 v2.22.0 Interface for using the mplib library]% \documentclass{ltxdoc} \usepackage{metalogo,multicol,mdwlist,fancyvrb,xspace} \usepackage[x11names]{xcolor} @@ -153,7 +153,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{2021/11/23 v2.21.1} +% \date{2022/01/09 v2.22.0} % % \maketitle % @@ -353,6 +353,28 @@ See source file '\inFileName' for licencing and contact information. % each code chunks being treated as an independent instance, and never % affected by previous code chunks. % +% \paragraph{Separate instances for \LaTeX{} environment} +% v2.22 has added the support for several named MetaPost instances +% in \LaTeX{} |mplibcode| environment. +% Syntax is like so: +% \begin{verbatim} +% \begin{mplibcode}[instanceName] +% % some mp code +% \end{mplibcode} +% \end{verbatim} +% Behaviour is as follows. +% \begin{itemize} +% \item All the variables and functions are shared +% only among all the environments belonging to the same instance. +% \item |\mplibcodeinherit| only affects environments +% with no instance name set (since if a name is set, +% the code is intended to be reused at some point). +% \item |btex ... etex| labels still exist separately and +% require |\mplibglobaltextext|. +% \item When an instance names is set, +% respective |\currentmpinstancename| is set. +% \end{itemize} +% % \paragraph{\cs{mplibglobaltextext}} % To inherit |btex ... etex| labels as well as metapost variables, % it is necessary to declare \cs{mplibglobaltextext\{enable\}} in advance. @@ -413,8 +435,8 @@ See source file '\inFileName' for licencing and contact information. luatexbase.provides_module { name = "luamplib", - version = "2.21.1", - date = "2021/11/23", + version = "2.22.0", + date = "2022/01/09", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", } @@ -846,7 +868,7 @@ end luamplib.codeinherit = false local mplibinstances = {} -local function process (data) +local function process (data, instancename) % \end{macrocode} % % The workaround of issue \#70 seems to be unnecessary, as we use @@ -857,10 +879,17 @@ local function process (data) % end % \end{verbatim} % \begin{macrocode} - local standalone = not luamplib.codeinherit - local currfmt = currentformat .. (luamplib.numbersystem or "scaled") + local defaultinstancename = currentformat .. (luamplib.numbersystem or "scaled") .. tostring(luamplib.textextlabel) .. tostring(luamplib.legacy_verbatimtex) + local currfmt = instancename or defaultinstancename + if #currfmt == 0 then + currfmt = defaultinstancename + end local mpx = mplibinstances[currfmt] + local standalone = false + if currfmt == defaultinstancename then + standalone = not luamplib.codeinherit + end if mpx and standalone then mpx:finish() end @@ -1229,7 +1258,7 @@ local function unprotect_expansion (str) end end -local function process_mplibcode (data) +local function process_mplibcode (data, instancename) % \end{macrocode} % % This is needed for legacy behavior regarding |verbatimtex| @@ -1283,7 +1312,7 @@ local function process_mplibcode (data) end) end - process(data) + process(data, instancename) end luamplib.process_mplibcode = process_mplibcode @@ -2011,7 +2040,7 @@ luamplib.colorconverter = colorconverter \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luamplib} - [2021/11/23 v2.21.1 mplib package for LuaTeX] + [2022/01/09 v2.22.0 mplib package for LuaTeX] \ifx\newluafunction\@undefined \input ltluatex \fi @@ -2103,7 +2132,8 @@ luamplib.colorconverter = colorconverter % % The \LaTeX-specific part: a new environment. % \begin{macrocode} -\newenvironment{mplibcode}{% +\newenvironment{mplibcode}[1][]{% + \global\def\currentmpinstancename{#1}% \mplibtmptoks{}\ltxdomplibcode }{} \def\ltxdomplibcode{% @@ -2117,7 +2147,7 @@ luamplib.colorconverter = colorconverter \mplibtmptoks\expandafter{\the\mplibtmptoks#1}% \def\mplibtemp@a{#2}% \ifx\mplib@mplibcode\mplibtemp@a - \directlua{luamplib.process_mplibcode([===[\the\mplibtmptoks]===])}% + \directlua{luamplib.process_mplibcode([===[\the\mplibtmptoks]===],"\currentmpinstancename")}% \end{mplibcode}% \else \mplibtmptoks\expandafter{\the\mplibtmptoks\end{#2}}% diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua index 430d2991efa..a0bdce00e70 100644 --- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua +++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua @@ -11,8 +11,8 @@ luatexbase.provides_module { name = "luamplib", - version = "2.21.1", - date = "2021/11/23", + version = "2.22.0", + date = "2022/01/09", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", } @@ -346,11 +346,18 @@ end luamplib.codeinherit = false local mplibinstances = {} -local function process (data) - local standalone = not luamplib.codeinherit - local currfmt = currentformat .. (luamplib.numbersystem or "scaled") +local function process (data, instancename) + local defaultinstancename = currentformat .. (luamplib.numbersystem or "scaled") .. tostring(luamplib.textextlabel) .. tostring(luamplib.legacy_verbatimtex) + local currfmt = instancename or defaultinstancename + if #currfmt == 0 then + currfmt = defaultinstancename + end local mpx = mplibinstances[currfmt] + local standalone = false + if currfmt == defaultinstancename then + standalone = not luamplib.codeinherit + end if mpx and standalone then mpx:finish() end @@ -635,7 +642,7 @@ local function unprotect_expansion (str) end end -local function process_mplibcode (data) +local function process_mplibcode (data, instancename) legacy_mplibcode_reset() local everymplib = texgettoks'everymplibtoks' or '' @@ -675,7 +682,7 @@ local function process_mplibcode (data) end) end - process(data) + process(data, instancename) end luamplib.process_mplibcode = process_mplibcode diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty index 8d91224481f..5de8c9c6b36 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} - [2021/11/23 v2.21.1 mplib package for LuaTeX] + [2022/01/09 v2.22.0 mplib package for LuaTeX] \ifx\newluafunction\@undefined \input ltluatex \fi @@ -62,7 +62,8 @@ \endgroup } \else -\newenvironment{mplibcode}{% +\newenvironment{mplibcode}[1][]{% + \global\def\currentmpinstancename{#1}% \mplibtmptoks{}\ltxdomplibcode }{} \def\ltxdomplibcode{% @@ -76,7 +77,7 @@ \mplibtmptoks\expandafter{\the\mplibtmptoks#1}% \def\mplibtemp@a{#2}% \ifx\mplib@mplibcode\mplibtemp@a - \directlua{luamplib.process_mplibcode([===[\the\mplibtmptoks]===])}% + \directlua{luamplib.process_mplibcode([===[\the\mplibtmptoks]===],"\currentmpinstancename")}% \end{mplibcode}% \else \mplibtmptoks\expandafter{\the\mplibtmptoks\end{#2}}% |