diff options
author | Karl Berry <karl@freefriends.org> | 2022-01-09 21:20:32 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-01-09 21:20:32 +0000 |
commit | e2eade5f75ce75881f3148efa4b24392428f4832 (patch) | |
tree | 003129dbf2fd737f25d5d0e0f931ba196e66407a /Master/texmf-dist/source/luatex | |
parent | 26ab7cdf587597f705bc839bb829b07d1969f125 (diff) |
luamplib (9jan22)
git-svn-id: svn://tug.org/texlive/trunk@61554 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/luatex')
-rw-r--r-- | Master/texmf-dist/source/luatex/luamplib/luamplib.dtx | 56 |
1 files changed, 43 insertions, 13 deletions
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}}% |