summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-03-01 21:45:34 +0000
committerKarl Berry <karl@freefriends.org>2024-03-01 21:45:34 +0000
commit78106bb24e28f74747fe222a8ecfe7e77dd0d1f0 (patch)
tree36f6625a4f4e674c6741349db1f59b2af221eb62 /Master
parent0eaa5c8aa577036e91ec287c5797a3e96bcffb8c (diff)
minim-mp (1mar24)
git-svn-id: svn://tug.org/texlive/trunk@70310 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/luatex/minim-mp/README14
-rw-r--r--Master/texmf-dist/doc/luatex/minim-mp/minim-mp.doc43
-rw-r--r--Master/texmf-dist/doc/luatex/minim-mp/minim-mp.pdfbin120017 -> 120799 bytes
-rw-r--r--Master/texmf-dist/tex/luatex/minim-mp/minim-mp.lua37
-rw-r--r--Master/texmf-dist/tex/luatex/minim-mp/minim-mp.sty32
-rw-r--r--Master/texmf-dist/tex/luatex/minim-mp/minim-mp.tex1
6 files changed, 103 insertions, 24 deletions
diff --git a/Master/texmf-dist/doc/luatex/minim-mp/README b/Master/texmf-dist/doc/luatex/minim-mp/README
index 6c10eeabb2c..372e9626e1a 100644
--- a/Master/texmf-dist/doc/luatex/minim-mp/README
+++ b/Master/texmf-dist/doc/luatex/minim-mp/README
@@ -1,4 +1,4 @@
-Version: 2024/1.4
+Version: 2024/1.5
SUMMARY
@@ -19,6 +19,18 @@ In order to obtain the typeset manual of this package, simply say:
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)
diff --git a/Master/texmf-dist/doc/luatex/minim-mp/minim-mp.doc b/Master/texmf-dist/doc/luatex/minim-mp/minim-mp.doc
index 9429544d8ef..0cd4ff574e0 100644
--- a/Master/texmf-dist/doc/luatex/minim-mp/minim-mp.doc
+++ b/Master/texmf-dist/doc/luatex/minim-mp/minim-mp.doc
@@ -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 @@ a persistent metapost instance. This will also give you more control over image
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,16 +49,26 @@ and ⟦\end{document}⟧ will be inserted automatically if omitted.
\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
@@ -73,7 +83,7 @@ These are the options you can use:
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 @@ tex can parse as a number.
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 @@ A transparency group is a special kind of XForm, and these can be created from
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,6 +439,11 @@ Each metapost instance is a table containing the following entries:
⟦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
diff --git a/Master/texmf-dist/doc/luatex/minim-mp/minim-mp.pdf b/Master/texmf-dist/doc/luatex/minim-mp/minim-mp.pdf
index 9ea6a516125..eae0cd360e4 100644
--- a/Master/texmf-dist/doc/luatex/minim-mp/minim-mp.pdf
+++ b/Master/texmf-dist/doc/luatex/minim-mp/minim-mp.pdf
Binary files differ
diff --git a/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.lua b/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.lua
index 9069ab7147e..fba65732396 100644
--- a/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.lua
+++ b/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.lua
@@ -228,7 +228,7 @@ end
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 @@ local function get_boxresource_center (id)
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 @@ function E.quote_for_lua(s)
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 @@ function M.make_glyph(glyphname, fnt)
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 @@ M.get_contours = E.get_contours
-- 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 @@ local function apply_default_instance_opts(t)
, 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,14 +1457,18 @@ function M.run (nr, code)
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)
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
diff --git a/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.sty b/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.sty
index 250e86668e0..6240c80b9a4 100644
--- a/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.sty
+++ b/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.sty
@@ -29,7 +29,7 @@
\newmetapostinstance[#1]\mnm@tmp
\expandafter\let\csname #2@instance\endcsname\mnm@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@switch@#1\endcsname
+ true \else false \fi }}
+ \newmetapostenvironment[jobname='\jobname']{@mplibcode}
+ \def\mplibcodeinherit#1{%
+ \ifcsname minimp@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@switch@@enable=\relax
+\let\minimp@switch@@enabled=\relax
+\let\minimp@switch@@true=\relax
+\let\minimp@switch@@yes=\relax
+
+
diff --git a/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.tex b/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.tex
index 6d953346776..7b8cef6c6b5 100644
--- a/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.tex
+++ b/Master/texmf-dist/tex/luatex/minim-mp/minim-mp.tex
@@ -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') }