From 81b17c3a69bb1b2f93e5ca4b114be5098da9b6d8 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 12 Jan 2022 21:19:46 +0000 Subject: luamplib (12jan22) git-svn-id: svn://tug.org/texlive/trunk@61587 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/luatex/luamplib/NEWS | 6 ++ Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf | Bin 153133 -> 153902 bytes .../doc/luatex/luamplib/test-luamplib-latex.tex | 7 +- .../texmf-dist/source/luatex/luamplib/luamplib.dtx | 77 +++++++++++++++------ Master/texmf-dist/tex/luatex/luamplib/luamplib.lua | 13 ++-- Master/texmf-dist/tex/luatex/luamplib/luamplib.sty | 41 +++++++---- 6 files changed, 102 insertions(+), 42 deletions(-) (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/luatex/luamplib/NEWS b/Master/texmf-dist/doc/luatex/luamplib/NEWS index 8f258c41f6b..0a4d0ea0680 100644 --- a/Master/texmf-dist/doc/luatex/luamplib/NEWS +++ b/Master/texmf-dist/doc/luatex/luamplib/NEWS @@ -1,5 +1,11 @@ History of the luamplib package +2022/01/12 2.23.0 + In parellel with the functionality introduced at previous version, + \everymplib (\everyendmplib as well, of course) supports + optional argument of named MetaPost instance, affecting only those + mplibcode environments of the same name. + 2022/01/09 2.22.0 * Sergey Slyusarev (@jemmybutton) has suggested and contributed a new feature for LaTeX mplibcode environment, which now supports diff --git a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf index aeefe5ca287..58ee697d5f0 100644 Binary files a/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf and b/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf differ 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 632dae44e67..e3b04413361 100644 --- a/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex +++ b/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex @@ -169,12 +169,13 @@ diameter:\Dia bp.% \vskip 2\baselineskip \mplibcodeinherit{disable}% +\everymplib[instanceOne]{beginfig(1);} +\everyendmplib[instanceOne]{endfig;} + \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 @@ -213,10 +214,8 @@ endfig; 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 diff --git a/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx b/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx index ae2f5d3a98b..4e9eb71356d 100644 --- a/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx +++ b/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx @@ -85,7 +85,7 @@ See source file '\inFileName' for licencing and contact information. %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{luamplib.drv}% - [2022/01/09 v2.22.0 Interface for using the mplib library]% + [2022/01/12 v2.23.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{2022/01/09 v2.22.0} +% \date{2022/01/12 v2.23.0} % % \maketitle % @@ -269,9 +269,9 @@ See source file '\inFileName' for licencing and contact information. % % \paragraph{\cs{everymplib}, \cs{everyendmplib}} % Since v2.3, new macros \cs{everymplib} and \cs{everyendmplib} redefine -% token lists \cs{everymplibtoks} and \cs{everyendmplibtoks} respectively, +% the lua table containing MetaPost code % which will -% be automatically inserted at the beginning and ending of each mplib code. +% be automatically inserted at the beginning and ending of each |mplibcode|. % \begin{verbatim} % \everymplib{ beginfig(0); } % \everyendmplib{ endfig; } @@ -374,6 +374,17 @@ See source file '\inFileName' for licencing and contact information. % \item When an instance names is set, % respective |\currentmpinstancename| is set. % \end{itemize} +% In parellel with this functionality, v2.23 and after supports +% optional argument of instance name for \cs{everymplib} and +% \cs{everyendmplib}, affecting only those |mplibcode| environments +% of the same name. +% Unnamed \cs{everymplib} affects not only those instances with no name, +% but also those with name but with no corresponding \cs{everymplib}. +% Syntax is: +% \begin{verbatim} +% \everymplib[instanceName]{...} +% \everyendmplib[instanceName]{...} +% \end{verbatim} % % \paragraph{\cs{mplibglobaltextext}} % To inherit |btex ... etex| labels as well as metapost variables, @@ -435,8 +446,8 @@ See source file '\inFileName' for licencing and contact information. luatexbase.provides_module { name = "luamplib", - version = "2.22.0", - date = "2022/01/09", + version = "2.23.0", + date = "2022/01/12", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", } @@ -1258,6 +1269,9 @@ local function unprotect_expansion (str) end end +luamplib.everymplib = { [""] = "" } +luamplib.everyendmplib = { [""] = "" } + local function process_mplibcode (data, instancename) % \end{macrocode} % @@ -1265,8 +1279,10 @@ local function process_mplibcode (data, instancename) % \begin{macrocode} legacy_mplibcode_reset() - local everymplib = texgettoks'everymplibtoks' or '' - local everyendmplib = texgettoks'everyendmplibtoks' or '' + local everymplib = luamplib.everymplib[instancename] or + luamplib.everymplib[""] + local everyendmplib = luamplib.everyendmplib[instancename] or + luamplib.everyendmplib[""] data = format("\n%s\n%s\n%s\n",everymplib, data, everyendmplib) data = data:gsub("\r","\n") @@ -2040,7 +2056,7 @@ luamplib.colorconverter = colorconverter \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luamplib} - [2022/01/09 v2.22.0 mplib package for LuaTeX] + [2022/01/12 v2.23.0 mplib package for LuaTeX] \ifx\newluafunction\@undefined \input ltluatex \fi @@ -2124,7 +2140,7 @@ luamplib.colorconverter = colorconverter } \long\def\mplibdocode#1\endmplibcode{% \endgroup - \directlua{luamplib.process_mplibcode([===[\unexpanded{#1}]===])}% + \directlua{luamplib.process_mplibcode([===[\unexpanded{#1}]===],"")}% \endgroup } \else @@ -2186,30 +2202,47 @@ luamplib.colorconverter = colorconverter \newtoks\mplibtmptoks % \end{macrocode} % -% \cs{everymplib} \& \cs{everyendmplib}: macros redefining -% \cs{everymplibtoks} \& \cs{everyendmplibtoks} respectively +% \cs{everymplib} \& \cs{everyendmplib}: macros resetting +% |luamplib.every(end)mplib| tables % % \begin{macrocode} -\newtoks\everymplibtoks -\newtoks\everyendmplibtoks \protected\def\everymplib{% \begingroup \mplibsetupcatcodes \mplibdoeverymplib } -\long\def\mplibdoeverymplib#1{% - \endgroup - \everymplibtoks{#1}% -} \protected\def\everyendmplib{% \begingroup \mplibsetupcatcodes \mplibdoeveryendmplib } -\long\def\mplibdoeveryendmplib#1{% - \endgroup - \everyendmplibtoks{#1}% -} +\ifcsname ver@luamplib.sty\endcsname + \newcommand\mplibdoeverymplib[2][]{% + \endgroup + \directlua{ + luamplib.everymplib["#1"] = [===[\unexpanded{#2}]===] + }% + } + \newcommand\mplibdoeveryendmplib[2][]{% + \endgroup + \directlua{ + luamplib.everyendmplib["#1"] = [===[\unexpanded{#2}]===] + }% + } +\else + \long\def\mplibdoeverymplib#1{% + \endgroup + \directlua{ + luamplib.everymplib[""] = [===[\unexpanded{#1}]===] + }% + } + \long\def\mplibdoeveryendmplib#1{% + \endgroup + \directlua{ + luamplib.everyendmplib[""] = [===[\unexpanded{#1}]===] + }% + } +\fi % \end{macrocode} % % Allow \TeX\ dimen/color macros. Now |runscript| does the job, diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua index a0bdce00e70..35b7e435c1c 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.22.0", - date = "2022/01/09", + version = "2.23.0", + date = "2022/01/12", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", } @@ -642,11 +642,16 @@ local function unprotect_expansion (str) end end +luamplib.everymplib = { [""] = "" } +luamplib.everyendmplib = { [""] = "" } + local function process_mplibcode (data, instancename) legacy_mplibcode_reset() - local everymplib = texgettoks'everymplibtoks' or '' - local everyendmplib = texgettoks'everyendmplibtoks' or '' + local everymplib = luamplib.everymplib[instancename] or + luamplib.everymplib[""] + local everyendmplib = luamplib.everyendmplib[instancename] or + luamplib.everyendmplib[""] data = format("\n%s\n%s\n%s\n",everymplib, data, everyendmplib) data = data:gsub("\r","\n") diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty index 5de8c9c6b36..97ebcc2789d 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} - [2022/01/09 v2.22.0 mplib package for LuaTeX] + [2022/01/12 v2.23.0 mplib package for LuaTeX] \ifx\newluafunction\@undefined \input ltluatex \fi @@ -58,7 +58,7 @@ } \long\def\mplibdocode#1\endmplibcode{% \endgroup - \directlua{luamplib.process_mplibcode([===[\unexpanded{#1}]===])}% + \directlua{luamplib.process_mplibcode([===[\unexpanded{#1}]===],"")}% \endgroup } \else @@ -110,26 +110,43 @@ end }} \newtoks\mplibtmptoks -\newtoks\everymplibtoks -\newtoks\everyendmplibtoks \protected\def\everymplib{% \begingroup \mplibsetupcatcodes \mplibdoeverymplib } -\long\def\mplibdoeverymplib#1{% - \endgroup - \everymplibtoks{#1}% -} \protected\def\everyendmplib{% \begingroup \mplibsetupcatcodes \mplibdoeveryendmplib } -\long\def\mplibdoeveryendmplib#1{% - \endgroup - \everyendmplibtoks{#1}% -} +\ifcsname ver@luamplib.sty\endcsname + \newcommand\mplibdoeverymplib[2][]{% + \endgroup + \directlua{ + luamplib.everymplib["#1"] = [===[\unexpanded{#2}]===] + }% + } + \newcommand\mplibdoeveryendmplib[2][]{% + \endgroup + \directlua{ + luamplib.everyendmplib["#1"] = [===[\unexpanded{#2}]===] + }% + } +\else + \long\def\mplibdoeverymplib#1{% + \endgroup + \directlua{ + luamplib.everymplib[""] = [===[\unexpanded{#1}]===] + }% + } + \long\def\mplibdoeveryendmplib#1{% + \endgroup + \directlua{ + luamplib.everyendmplib[""] = [===[\unexpanded{#1}]===] + }% + } +\fi \def\mpdim#1{ mplibdimen("#1") } \def\mpcolor#1#{\domplibcolor{#1}} \def\domplibcolor#1#2{ mplibcolor("#1{#2}") } -- cgit v1.2.3