texlive[70310] Master/texmf-dist: minim-mp (1mar24)

commits+karl at tug.org commits+karl at tug.org
Fri Mar 1 22:45:34 CET 2024


Revision: 70310
          https://tug.org/svn/texlive?view=revision&revision=70310
Author:   karl
Date:     2024-03-01 22:45:34 +0100 (Fri, 01 Mar 2024)
Log Message:
-----------
minim-mp (1mar24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/luatex/minim-mp/README
    trunk/Master/texmf-dist/doc/luatex/minim-mp/minim-mp.doc
    trunk/Master/texmf-dist/doc/luatex/minim-mp/minim-mp.pdf
    trunk/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.lua
    trunk/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.sty
    trunk/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.tex

Modified: trunk/Master/texmf-dist/doc/luatex/minim-mp/README
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/minim-mp/README	2024-03-01 21:45:25 UTC (rev 70309)
+++ trunk/Master/texmf-dist/doc/luatex/minim-mp/README	2024-03-01 21:45:34 UTC (rev 70310)
@@ -1,4 +1,4 @@
-Version: 2024/1.4
+Version: 2024/1.5
 
 SUMMARY
 
@@ -19,6 +19,18 @@
 
 HISTORY
 
+2025/1.5 (in development)
+
+  New features:
+
+    * Add a luamplib compatibility mode to the latex package.
+    * Make default format and math mode configurable.
+
+  Bug fixes:
+
+    * Make metafun not crash immediately.
+    * Comments (% characters) are now handled by metapost, not tex.
+
 2024/1.4 (5/1/2024)
 
     * Support the extended graphics state (extgstate)

Modified: trunk/Master/texmf-dist/doc/luatex/minim-mp/minim-mp.doc
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/minim-mp/minim-mp.doc	2024-03-01 21:45:25 UTC (rev 70309)
+++ trunk/Master/texmf-dist/doc/luatex/minim-mp/minim-mp.doc	2024-03-01 21:45:34 UTC (rev 70310)
@@ -8,8 +8,8 @@
 \else \startmetadata
     author   {Esger Renkema}
     title    {minim-mp}
-    date     {2024-01-05}
-    version  {2024/1.4}
+    date     {2024-02-25}
+    version  {2024/1.5}
     keywords {LuaTeX; Plain TeX; MetaPost; mplib}
     stopmetadata
 \maketitle \fi
@@ -29,8 +29,8 @@
 extraction. See below under „Metapost instances”. The ⟦options⟧ will also be 
 explained there (for simple cases, you will not need them).
 
-The logging of the metapost run will be included in the regular log file. If an 
-error occurs, the logging will also be shown on the terminal.
+The logs of the metapost run will be included in the regular log file. If an 
+error occurs, the log of the last snippet will also be shown on the terminal.
 
 \section As a stand-alone Metapost compiler %
1
 
@@ -49,18 +49,28 @@
 
 \section LaTeX compatibility %
1
 
-An experimental latex package is included in ⟦minim-mp.sty⟧. It accepts no 
-options, as it really is a rather thin wrapper around the plain tex package.
-It does, however, provide a proper ⟦*metapost⟧ latex environment as an 
+An experimental latex package is included in ⟦minim-mp.sty⟧. It really is 
+a rather thin wrapper around the plain tex package,
+but does provide a proper ⟦*metapost⟧ latex environment as an 
 alternative to ⟦\directmetapost⟧.
-
-The ⟦metapost⟧ environment has no persistent backing instance.
-You can create a similar environment ⟦envname⟧ that does with
+The ⟦metapost⟧ environment has no persistent backing instance,
+but you can create a similar environment ⟦envname⟧ that does with
 ⟦*\newmetapostenvironment [options] {envname}⟧.
 If your demands are even more complex, you should fall back to the plain tex 
-commands described below.
+commands described in the next section.
 
+As in luamplib, you can use ⟦*\mpcolor {name}⟧ to insert the proper colour 
+values; this macro is only available inside the above environments.
 
+When the package is loaded with the option ⟦luamplib⟧, minim-mp will try and 
+act as a drop-in replacement for luamplib. The effort made is not very great 
+though, but it will define an ⟦mplibcode⟧ environment, as well as the
+⟦\mplibcodeinherit⟧, ⟦\mplibshowlog⟧, ⟦\mplibsetformat⟧ and 
+⟦\mplibnumbersystem⟧ switches.
+Please do note that this is not the recommended way of using minim-mp, which 
+remains the interface documented in the next section.
+
+
 \section Metapost instances %
1
 
 For more complicated uses, you can define your own instances by saying
@@ -73,7 +83,7 @@
 Option&Default&Description\cr
 ⟦jobname⟧&⟦':metapost:'⟧&Used in error messages.\cr
 ⟦format⟧&⟦'plain.mp'⟧&Format to initialise the instance with.\cr
-⟦math⟧&⟦'scaled'⟧&One of ⟦scaled⟧, ⟦decimal⟧ or ⟦double⟧.\cr
+⟦mathmode⟧&⟦'scaled'⟧&One of ⟦scaled⟧, ⟦decimal⟧ or ⟦double⟧.\cr
 ⟦seed⟧&⟦nil⟧&Random seed for this instance.\cr
 ⟦catcodes⟧&⟦0⟧&Catcode table for ⟦btex ... etex⟧.\cr
 ⟦env⟧&copy of ⟦_G⟧&Lua environment; see below.\cr
@@ -103,7 +113,7 @@
 Say ⟦*\remainingmpimages \id⟧ for the number of images not yet retrieved.
 
 Finally, as a shorthand, ⟦*\runmetapostimage \id { code }⟧ will add
-⟦beginfig ... endfig⟧ to your ⟦code⟧ and write the resulting image immediately 
+⟦beginfig ... endfig;⟧ to your ⟦code⟧ and write the resulting image immediately 
 to the current list.
 
 
@@ -364,7 +374,7 @@
 withing metapost: ⟦<id> =⟧ ⟦*saveboxresource (<attributes>) <picture>⟧ returns 
 a number identifying the resource and can be fed attributes in the same way as 
 ⟦setgstate⟧. XForms defined through metapost are available to other metapost 
-instances, but not to tex, though the macro painting them, ⟦*boxresource <id>⟧, 
+instances but not to tex, though the macro painting them, ⟦*boxresource <id>⟧, 
 also accepts identifiers of tex-defined box resources. There remains a subtle 
 difference, however: metapost-defined box resources are placed at their 
 original origin.
@@ -429,7 +439,12 @@
 ⟦catcodes⟧&Number of the catcode table used with ⟦btex ... etex⟧.\cr
 ⟦env⟧&The lua environment for ⟦runscript⟧.\cr}
 
+Default values for the format and number system are available in the
+⟦M.default_format⟧ and ⟦M.default_mathmode⟧ variables,
+while ⟦M.on_line⟧ controls whether the logs are always printed to the 
+terminal.
 
+
 \section Debugging %
1
 
 You can enable (global) debugging by saying ⟦*debug_pdf⟧ to metapost or 

Modified: trunk/Master/texmf-dist/doc/luatex/minim-mp/minim-mp.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.lua	2024-03-01 21:45:25 UTC (rev 70309)
+++ trunk/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.lua	2024-03-01 21:45:34 UTC (rev 70310)
@@ -228,7 +228,7 @@
 local function parse_lua_table(name, str)
     local f, msg = load('return '..str, name, 't')
     if msg then return alloc.err(msg) end
-    t = f()
+    local t = f()
     if not t or type(t) ~= 'table' then
         return alloc.err('%s attributes must be given as lua table', name)
     end
@@ -772,9 +772,9 @@
     end
 end
 
-E.set_boxresource_dimensions = set_boxresource_dimensions 
-E.get_boxresource_dimensions = get_boxresource_dimensions 
-E.get_boxresource_center = get_boxresource_center 
+E.set_boxresource_dimensions = set_boxresource_dimensions
+E.get_boxresource_dimensions = get_boxresource_dimensions
+E.get_boxresource_center = get_boxresource_center
 
 local function save_as_boxresource(pic)
     -- attributes
@@ -1248,6 +1248,21 @@
     return E.quote(mkluastring(s))
 end
 
+-- These are here so that luametafun does not bug out immediately. Please note 
+-- that using metafun is not otherwise supported or recommended.
+local cct_maketext = alloc.registernumber('minim:mp:catcodes:maketext')
+E.catcodes = { numbers =
+    { inicatcodes = cct_maketext , texcatcodes = cct_maketext
+    , luacatcodes = cct_maketext , notcatcodes = cct_maketext
+    , vrbcatcodes = cct_maketext , prtcatcodes = cct_maketext
+    , ctxcatcodes = cct_maketext , txtcatcodes = cct_maketext
+}   }
+E.mp = mp or { } -- all seem nonessential
+E.mp.mf_path_reset = E.mp.mf_path_reset or function() end
+E.mp.mf_finish_saving_data = E.mp.mf_finish_saving_data or function() end
+E.mp.report = E.mp.report or function() end
+
+
 --
2 typesetting with tex
 
 -- The result of the maketext function is fed back into metapost; on that side, 
@@ -1330,7 +1345,6 @@
         alloc.err('Font not found: %s (id %s)', fnt, fontid)
         return { }, 10
     end
-    local fontname = thefont.psname
     local gid = luaotfload.aux.gid_of_name(fontid, glyphname)
     if not gid then
         alloc.err('Font %s has no glyph named %s', thefont.psname, glyphname)
@@ -1393,6 +1407,9 @@
 
 --
2 opening, running and and closing instances
 
+M.default_format = 'plain.mp'
+M.default_mathmode = 'scaled'
+
 local function apply_default_instance_opts(t)
     return
         { ini_version  = true
@@ -1401,7 +1418,7 @@
         , find_file    = new_file_finder()
         --, script_error = ...
         , job_name     = t.jobname
-        , math_mode    = t.math or 'scaled'
+        , math_mode    = t.mathmode or t.math or M.default_mathmode
         , random_seed  = t.seed or nil
         -- , file_line_error_style
         , make_text    = maketext
@@ -1440,7 +1457,11 @@
     save_image_list(self, picts)
 end
 
-M.init_code = { 'let dump=endinput;', 'input INIT;', 'input minim-mp.mp;', 'input minim.mp;' }
+M.init_code = { 'let dump=endinput;'
+              , 'boolean mplib; mplib:=true;'
+              , 'input INIT;'
+              , 'input minim-mp.mp;'
+              , 'input minim.mp;' }
 local maketext_catcodes = alloc.registernumber('minim:mp:catcodes:maketext')
 
 function M.open (t)
@@ -1447,7 +1468,7 @@
     local nr = #instances + 1
     t.jobname = t.jobname or ':metapost:'
     -- creating instance options
-    local init = string.gsub(table.concat(M.init_code, ''), 'INIT', t.format or 'plain.mp')
+    local init = string.gsub(table.concat(M.init_code, ''), 'INIT', t.format or M.default_format)
     local opts = apply_default_instance_opts(t)
     local instance = mplib.new(opts)
     -- adding the instance

Modified: trunk/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.sty
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.sty	2024-03-01 21:45:25 UTC (rev 70309)
+++ trunk/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.sty	2024-03-01 21:45:34 UTC (rev 70310)
@@ -29,7 +29,7 @@
     \newmetapostinstance[#1]\mnm at tmp
     \expandafter\let\csname #2 at instance\endcsname\mnm at tmp
     \newenvironment{#2}{%
-         \begingroup \catcode`\#=12
+         \begingroup \catcode`\#=12 \catcode`\%=12
          \let\mpcolor = \minimpcolor
          \csname:#2:\endcsname}
         {\csname end:#2:\endcsname \endgroup}%
@@ -50,3 +50,33 @@
 \newtoks\mpcolorspectoks \newtoks\mpcolorruntoks \newtoks\mpcolorvaltoks
 \mpcolorruntoks{\expandafter\extractcolorspec\the\mpcolorspectoks\mptmpcolor
     \expandafter\mpcolorvaltoks\expandafter\@gobble\mptmpcolor}
+
+% as a rather fragile drop-in replacement for luamplib
+\DeclareOption{luamplib}{%
+    \def\mplibtextextlabel#1{} % always enabled
+    \def\mplibshowlog#1{\directlua{
+        require 'minim-mp'.on_line = %
+            \ifcsname minimp at switch@#1\endcsname
+                true \else false \fi }}
+    \newmetapostenvironment[jobname='\jobname']{@mplibcode}
+    \def\mplibcodeinherit#1{%
+        \ifcsname minimp at switch@#1\endcsname
+            \let\mplibcode=\@mplibcode
+            \let\endmplibcode=\@mplibcode
+        \else
+            \let\mplibcode=\metapost
+            \let\endmplibcode=\endmetapost
+        \fi}
+    \mplibcodeinherit{disable}
+    \def\mplibsetformat#1{\directlua{
+        require 'minim-mp'.default_format = '#1.mp' }}
+    \def\mplibnumbersystem#1{\directlua{
+        require 'minim-mp'.default_math = '#1' }}
+} \ProcessOptions*
+
+\let\minimp at switch@@enable=\relax
+\let\minimp at switch@@enabled=\relax
+\let\minimp at switch@@true=\relax
+\let\minimp at switch@@yes=\relax
+
+

Modified: trunk/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.tex
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.tex	2024-03-01 21:45:25 UTC (rev 70309)
+++ trunk/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.tex	2024-03-01 21:45:34 UTC (rev 70310)
@@ -16,6 +16,7 @@
 \newcatcodetable \minim:mp:catcodes:mpcode
 {\catcodetable\minim:initcatcodes
     \catcode`\{=1 \catcode`\}=2 \catcode9=10
+    \catcode`\#=12 \catcode`\%=12 \catcode`\~=12
     \savecatcodetable\csname minim:mp:catcodes:mpcode\endcsname}
 
 \directlua { require('minim-mp') }



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