texlive[70399] branches/branch2023.final/Master/texmf-dist: luamplib

commits+karl at tug.org commits+karl at tug.org
Mon Mar 4 22:13:11 CET 2024


Revision: 70399
          https://tug.org/svn/texlive?view=revision&revision=70399
Author:   karl
Date:     2024-03-04 22:13:11 +0100 (Mon, 04 Mar 2024)
Log Message:
-----------
luamplib (branch) (4mar24)

Modified Paths:
--------------
    branches/branch2023.final/Master/texmf-dist/doc/luatex/luamplib/NEWS
    branches/branch2023.final/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf
    branches/branch2023.final/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex
    branches/branch2023.final/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex
    branches/branch2023.final/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx
    branches/branch2023.final/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
    branches/branch2023.final/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty

Modified: branches/branch2023.final/Master/texmf-dist/doc/luatex/luamplib/NEWS
===================================================================
--- branches/branch2023.final/Master/texmf-dist/doc/luatex/luamplib/NEWS	2024-03-04 21:13:03 UTC (rev 70398)
+++ branches/branch2023.final/Master/texmf-dist/doc/luatex/luamplib/NEWS	2024-03-04 21:13:11 UTC (rev 70399)
@@ -1,5 +1,12 @@
                        History of the luamplib package
 
+2024/03/04 2.26.2
+    * color expressions ('red!50') are supported with xcolor package only
+
+2024/03/04 2.26.1
+    * attempt to support l3color: \mpcolor{color expression}
+    * cope with mp.report warning produced by 'message' under metafun
+
 2024/03/01 2.26.0
     * when \mplibcachedir{<dir>} is not set, default cache directory will
     be in the following order:

Modified: branches/branch2023.final/Master/texmf-dist/doc/luatex/luamplib/luamplib.pdf
===================================================================
(Binary files differ)

Modified: branches/branch2023.final/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex
===================================================================
--- branches/branch2023.final/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex	2024-03-04 21:13:03 UTC (rev 70398)
+++ branches/branch2023.final/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-latex.tex	2024-03-04 21:13:11 UTC (rev 70399)
@@ -81,6 +81,7 @@
 \mplibglobaltextext{disable}\par
 \mplibsetformat{metafun}%
 \begin{mplibcode}
+message "Hello World!";
 verbatimtex \moveright 0.4\hsize etex
 beginfig(0);
 path p; p:= fullcircle scaled 2cm yshifted .5cm;

Modified: branches/branch2023.final/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex
===================================================================
--- branches/branch2023.final/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex	2024-03-04 21:13:03 UTC (rev 70398)
+++ branches/branch2023.final/Master/texmf-dist/doc/luatex/luamplib/test-luamplib-plain.tex	2024-03-04 21:13:11 UTC (rev 70399)
@@ -79,6 +79,7 @@
 \mplibglobaltextext{disable}\par
 \mplibsetformat{metafun}%
 \mplibcode
+message "Hello World!";
 verbatimtex \moveright 0.4\hsize etex
 beginfig(0);
 path p; p:= fullcircle scaled 2cm yshifted .5cm;

Modified: branches/branch2023.final/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx
===================================================================
--- branches/branch2023.final/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx	2024-03-04 21:13:03 UTC (rev 70398)
+++ branches/branch2023.final/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx	2024-03-04 21:13:11 UTC (rev 70399)
@@ -85,7 +85,7 @@
 %<*driver>
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesFile{luamplib.drv}%
-  [2024/03/01 v2.26.0 Interface for using the mplib library]%
+  [2024/03/04 v2.26.2 Interface for using the mplib library]%
 \documentclass{ltxdoc}
 \usepackage{metalogo,multicol,mdwlist,fancyvrb,xspace}
 \usepackage[x11names]{xcolor}
@@ -153,7 +153,7 @@
 % \author{Hans Hagen, Taco Hoekwater, Elie Roux, Philipp Gesang and Kim Dohyun\\
 % Maintainer: LuaLaTeX Maintainers ---
 % Support: \email{lualatex-dev at tug.org}}
-% \date{2024/03/01 v2.26.0}
+% \date{2024/03/04 v2.26.2}
 %
 % \maketitle
 %
@@ -300,10 +300,15 @@
 %   \textsf{color}/\textsf{xcolor} packages can be used inside mplibcode
 %   enviroment (after |withcolor| operator),
 %   though \textsf{luamplib} does not automatically load these
-%   packages. See the example code above. For spot colors, \textsf{(x)spotcolor}
+%   packages. See the example code above. For spot colors,
+%   \textsf{colorspace}, \textsf{spotcolor}
 %   (in PDF mode) and \textsf{xespotcolor} (in DVI mode) packages are supported
 %   as well.
 %
+%   From v2.26.1, \textsf{l3color} is also supported by the command
+%   \cs{mpcolor}, color expressions (|red!50|) being supported with
+%   \textsf{xcolor} package only.
+%
 % \paragraph{\cs{mplibnumbersystem}}
 %   Users can choose |numbersystem| option since v2.4.
 %   The default value |scaled| can be changed to |double| or |decimal|
@@ -451,8 +456,8 @@
 
 luatexbase.provides_module {
   name          = "luamplib",
-  version       = "2.26.0",
-  date          = "2024/03/01",
+  version       = "2.26.2",
+  date          = "2024/03/04",
   description   = "Lua package to typeset Metapost with LuaTeX's MPLib.",
 }
 
@@ -978,10 +983,21 @@
 %    Make |color| or |xcolor|'s color expressions usable,
 %    with \cs{mpcolor} or |mplibcolor|. These commands should be used
 %    with graphical objects.
+%
+%    Attempt to support l3color as well.
 %    \begin{macrocode}
-local mplibcolor_fmt = [[\begingroup\let\XC at mcolor\relax]]..
+local mplibcolorfmt = {
+  xcolor = [[\begingroup\let\XC at mcolor\relax]]..
   [[\def\set at color{\global\mplibtmptoks\expandafter{\current at color}}]]..
-  [[\color %s \endgroup]]
+  [[\color %s\endgroup]],
+  l3color = [[\begingroup\color_if_exist:nTF %s]]..
+  [[{\def\__color_select:N #1{\expandafter\__color_select:nn #1}]]..
+  [[\def\__color_backend_select:nn #1#2{\global\mplibtmptoks{#1~#2}}]]..
+  [[\color_select:n %s}]]..
+  [[{\let\XC at mcolor\relax]]..
+  [[\def\set at color{\global\mplibtmptoks\expandafter{\current at color}}]]..
+  [[\color %s}\endgroup]],
+}
 
 local function process_color (str)
   if str then
@@ -988,7 +1004,12 @@
     if not str:find("{.-}") then
       str = format("{%s}",str)
     end
-    run_tex_code(mplibcolor_fmt:format(str), catat11)
+    local myfmt = luamplib.cctabexplat and mplibcolorfmt.l3color or mplibcolorfmt.xcolor
+    local mod = str:match("(.-){.*}")
+    if mod and mod ~= "" then
+      myfmt = mplibcolorfmt.xcolor
+    end
+    run_tex_code(myfmt:format(str,str,str), luamplib.cctabexplat or catat11)
     return format('1 withprescript "MPlibOverrideColor=%s"', texgettoks"mplibtmptoks")
   end
   return ""
@@ -1069,7 +1090,9 @@
 local mp = mp
 mp.mf_path_reset = mp.mf_path_reset or function() end
 mp.mf_finish_saving_data = mp.mf_finish_saving_data or function() end
+mp.report = mp.report or info
 
+
 %    \end{macrocode}
 %
 %    metafun 2021-03-09 changes crashes luamplib.
@@ -1289,10 +1312,6 @@
   data = format("\n%s\n%s\n%s\n",everymplib, data, everyendmplib)
   data = data:gsub("\r","\n")
 
-  data = data:gsub("\\mpcolor%s+(.-%b{})","mplibcolor(\"%1\")")
-  data = data:gsub("\\mpdim%s+(%b{})", "mplibdimen(\"%1\")")
-  data = data:gsub("\\mpdim%s+(\\%a+)","mplibdimen(\"%1\")")
-
   data = data:gsub(btex_etex, function(str)
     return format("btex %s etex ", -- space
       luamplib.verbatiminput and str or protect_expansion(str))
@@ -2059,7 +2078,7 @@
 \else
   \NeedsTeXFormat{LaTeX2e}
   \ProvidesPackage{luamplib}
-    [2024/03/01 v2.26.0 mplib package for LuaTeX]
+    [2024/03/04 v2.26.2 mplib package for LuaTeX]
   \ifx\newluafunction\@undefined
   \input ltluatex
   \fi
@@ -2252,9 +2271,21 @@
 %    so the following lines are not needed for most cases.
 %    But the macros will be expanded when they are used in another macro.
 %    \begin{macrocode}
-\def\mpdim#1{ mplibdimen("#1") }
+\def\mpdim#1{ runscript("luamplibdimen{#1}") }
+\ifdefined\IfDocumentMetadataTF
+  \IfDocumentMetadataTF{
+    \newcatcodetable\catcodetable at explat
+    \directlua{ luamplib.cctabexplat = \the\allocationnumber }
+    \begingroup
+    \ExplSyntaxOn
+    \catcode`@=11
+    \savecatcodetable\catcodetable at explat
+    \ExplSyntaxOff
+    \endgroup
+  }{}
+\fi
 \def\mpcolor#1#{\domplibcolor{#1}}
-\def\domplibcolor#1#2{ mplibcolor("#1{#2}") }
+\def\domplibcolor#1#2{ runscript("luamplibcolor{#1{#2}}") }
 %    \end{macrocode}
 %
 %    MPLib's number system. Now |binary| has gone away.

Modified: branches/branch2023.final/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
===================================================================
--- branches/branch2023.final/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua	2024-03-04 21:13:03 UTC (rev 70398)
+++ branches/branch2023.final/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua	2024-03-04 21:13:11 UTC (rev 70399)
@@ -11,8 +11,8 @@
 
 luatexbase.provides_module {
   name          = "luamplib",
-  version       = "2.26.0",
-  date          = "2024/03/01",
+  version       = "2.26.2",
+  date          = "2024/03/04",
   description   = "Lua package to typeset Metapost with LuaTeX's MPLib.",
 }
 
@@ -395,9 +395,18 @@
   return ""
 end
 
-local mplibcolor_fmt = [[\begingroup\let\XC at mcolor\relax]]..
+local mplibcolorfmt = {
+  xcolor = [[\begingroup\let\XC at mcolor\relax]]..
   [[\def\set at color{\global\mplibtmptoks\expandafter{\current at color}}]]..
-  [[\color %s \endgroup]]
+  [[\color %s\endgroup]],
+  l3color = [[\begingroup\color_if_exist:nTF %s]]..
+  [[{\def\__color_select:N #1{\expandafter\__color_select:nn #1}]]..
+  [[\def\__color_backend_select:nn #1#2{\global\mplibtmptoks{#1~#2}}]]..
+  [[\color_select:n %s}]]..
+  [[{\let\XC at mcolor\relax]]..
+  [[\def\set at color{\global\mplibtmptoks\expandafter{\current at color}}]]..
+  [[\color %s}\endgroup]],
+}
 
 local function process_color (str)
   if str then
@@ -404,7 +413,12 @@
     if not str:find("{.-}") then
       str = format("{%s}",str)
     end
-    run_tex_code(mplibcolor_fmt:format(str), catat11)
+    local myfmt = luamplib.cctabexplat and mplibcolorfmt.l3color or mplibcolorfmt.xcolor
+    local mod = str:match("(.-){.*}")
+    if mod and mod ~= "" then
+      myfmt = mplibcolorfmt.xcolor
+    end
+    run_tex_code(myfmt:format(str,str,str), luamplib.cctabexplat or catat11)
     return format('1 withprescript "MPlibOverrideColor=%s"', texgettoks"mplibtmptoks")
   end
   return ""
@@ -462,6 +476,7 @@
 local mp = mp
 mp.mf_path_reset = mp.mf_path_reset or function() end
 mp.mf_finish_saving_data = mp.mf_finish_saving_data or function() end
+mp.report = mp.report or info
 
 catcodes = catcodes or {}
 local catcodes = catcodes
@@ -653,10 +668,6 @@
   data = format("\n%s\n%s\n%s\n",everymplib, data, everyendmplib)
   data = data:gsub("\r","\n")
 
-  data = data:gsub("\\mpcolor%s+(.-%b{})","mplibcolor(\"%1\")")
-  data = data:gsub("\\mpdim%s+(%b{})", "mplibdimen(\"%1\")")
-  data = data:gsub("\\mpdim%s+(\\%a+)","mplibdimen(\"%1\")")
-
   data = data:gsub(btex_etex, function(str)
     return format("btex %s etex ", -- space
       luamplib.verbatiminput and str or protect_expansion(str))

Modified: branches/branch2023.final/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
===================================================================
--- branches/branch2023.final/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty	2024-03-04 21:13:03 UTC (rev 70398)
+++ branches/branch2023.final/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty	2024-03-04 21:13:11 UTC (rev 70399)
@@ -14,7 +14,7 @@
 \else
   \NeedsTeXFormat{LaTeX2e}
   \ProvidesPackage{luamplib}
-    [2024/03/01 v2.26.0 mplib package for LuaTeX]
+    [2024/03/04 v2.26.2 mplib package for LuaTeX]
   \ifx\newluafunction\@undefined
   \input ltluatex
   \fi
@@ -147,9 +147,21 @@
     }%
   }
 \fi
-\def\mpdim#1{ mplibdimen("#1") }
+\def\mpdim#1{ runscript("luamplibdimen{#1}") }
+\ifdefined\IfDocumentMetadataTF
+  \IfDocumentMetadataTF{
+    \newcatcodetable\catcodetable at explat
+    \directlua{ luamplib.cctabexplat = \the\allocationnumber }
+    \begingroup
+    \ExplSyntaxOn
+    \catcode`@=11
+    \savecatcodetable\catcodetable at explat
+    \ExplSyntaxOff
+    \endgroup
+  }{}
+\fi
 \def\mpcolor#1#{\domplibcolor{#1}}
-\def\domplibcolor#1#2{ mplibcolor("#1{#2}") }
+\def\domplibcolor#1#2{ runscript("luamplibcolor{#1{#2}}") }
 \def\mplibnumbersystem#1{\directlua{
   local t = "#1"
   if t == "binary" then t = "decimal" end



More information about the tex-live-commits mailing list.