diff options
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/luatex/luamplib/luamplib-createmem.lua | 55 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/luamplib/luamplib.lua | 167 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/luamplib/luamplib.sty | 54 |
3 files changed, 52 insertions, 224 deletions
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib-createmem.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib-createmem.lua deleted file mode 100644 index 4066758e9bd..00000000000 --- a/Master/texmf-dist/tex/luatex/luamplib/luamplib-createmem.lua +++ /dev/null @@ -1,55 +0,0 @@ --- --- This is file `luamplib-createmem.lua', --- generated with the docstrip utility. --- --- The original source files were: --- --- luamplib.dtx (with options: `gen-lua') --- This is a generated file. --- --- Copyright (C) 2008-2009 by Hans Hagen, Taco Hoekwater and Elie Roux --- <elie.roux@telecom-bretagne.eu>. (Support: <lualatex-dev@tug.org>.) --- --- This work is under the CC0 license. --- --- This Current Maintainer of this work is Elie Roux. --- --- This work consists of the main source file luamplib.dtx --- and the derived files --- luamplib.sty, luamplib.lua, luamplib-createmem.lua and luamplib.pdf. --- - -kpse.set_program_name("kpsewhich") - -function finder (name, mode, ftype) - if mode == "w" then - return name - else - local result = kpse.find_file(name,ftype) - return result - end -end - -local preamble = [[ -input %s ; dump ; -]] - - -makeformat = function (name, mem_name) - local mpx = mplib.new { - ini_version = true, - find_file = finder, - job_name = mem_name, - } - if mpx then - local result - result = mpx:execute(string.format(preamble,name)) - print(string.format("dumping format %s in %s", name, mem_name)) - mpx:finish() - end -end - -makeformat("plain", "mplib-luatex.mem") - --- --- End of File `luamplib-createmem.lua'. diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua index 2ff14676ff2..f5c7ef12141 100644 --- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua +++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua @@ -5,158 +5,84 @@ -- The original source files were: -- -- luamplib.dtx (with options: `lua') --- This is a generated file. -- --- Copyright (C) 2008-2009 by Hans Hagen, Taco Hoekwater and Elie Roux --- <elie.roux@telecom-bretagne.eu>. (Support: <lualatex-dev@tug.org>.) +-- See source file 'luamplib.dtx' for licencing and contact information. -- --- This work is under the CC0 license. --- --- This Current Maintainer of this work is Elie Roux. --- --- This work consists of the main source file luamplib.dtx --- and the derived files --- luamplib.sty, luamplib.lua, luamplib-createmem.lua and luamplib.pdf. --- - module('luamplib', package.seeall) - -luamplib.module = { +local err, warn, info, log = luatexbase.provides_module({ name = "luamplib", - version = 1.06, - date = "2010/10/17", + version = 1.07, + date = "2010/12/28", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", - author = "Hans Hagen, Taco Hoekwater & Elie Roux", - copyright = "ConTeXt Development Team & Elie Roux", - license = "CC0", -} - -luatexbase.provides_module(luamplib.module) +}) +local function term(...) + texio.write_nl('term', 'luamplib: ' .. string.format(...)) +end local format, concat, abs = string.format, table.concat, math.abs +local data = "" -luamplib.currentformat = "plain" -luamplib.currentmem = "mplib-luatex" - -local currentformat = luamplib.currentformat -local currentmem = luamplib.currentmem - -function luamplib.setformat (name) - luamplib.currentformat = name +local function resetdata() + data = "" end - -function luamplib.setmemfile(name) - luamplib.currentmem = name +function addline(line) + data = data .. '\n' .. line +end +function processlines() + process(data) + resetdata() end +local mpkpse = kpse.new("luatex", "mpost") -local mpkpse = kpse.new("luatex","mpost") - -function luamplib.finder(name, mode, ftype) +local function finder(name, mode, ftype) if mode == "w" then return name else - local result = mpkpse:find_file(name,ftype) - if not result and ftype == "mem" then - result = mpkpse:find_file("metapost/"..name,ftype) - end - return result + return mpkpse:find_file(name,ftype) end end -function luamplib.info (...) - luatexbase.module_info('luamplib', format(...)) -end - -function luamplib.log (...) - luatexbase.module_log('luamplib', format(...)) -end - -function luamplib.term (...) - luatexbase.module_term('luamplib', format(...)) -end +local currentformat = "plain" -function luamplib.warning (...) - luatexbase.module_warning('luamplib', format(...)) +function setformat (name) + currentformat = name end -function luamplib.error (...) - luatexbase.module_error('luamplib', format(...)) -end - - -luamplib.data = "" - -function luamplib.resetdata() - luamplib.data = "" -end - -function luamplib.addline(line) - luamplib.data = luamplib.data .. '\n' .. line -end - -function luamplib.processlines() - luamplib.process(luamplib.data) - luamplib.resetdata() -end - - -function luamplib.input_mp(name) +function load() local mpx = mplib.new { + find_file = finder, ini_version = true, - find_file = luamplib.finder, - job_name = name, - } - mpx:execute(format("input %s ;",name)) - return mpx -end - - -function luamplib.load() - local mpx = mplib.new { - ini_version = false, - mem_name = currentmem, - find_file = luamplib.finder } - if mpx then - luamplib.log("using mem file %s", luamplib.finder(currentmem, 'r', 'mem')) - else - mpx = luamplib.input_mp(currentformat) - if mpx then - luamplib.log("using mp file %s", luamplib.finder(currentformat, 'r', 'mp')) - else - luamplib.error("unable to load the metapost format.") - end - end + mpx:execute(format("input %s ;", currentformat)) return mpx end - -function luamplib.report(result) +function report(result) if not result then - luamplib.error("no result object") + err("no result object") elseif result.status > 0 then local t, e, l, f = result.term, result.error, result.log if l then - luamplib.log(l) + log(l) end if t then - luamplib.term(t) + term(t) end if e then if result.status == 1 then - luamplib.warning(e) + warn(e) else - luamplib.error(e) + err(e) end end if not t and not e and not l then if result.status == 1 then - luamplib.warning("unknown error, no error, terminal or log messages, maybe missing beginfig/endfig") + warn("unknown error, no error, terminal or log messages, maybe missing beginfig/endfig") else - luamplib.error("unknown error, no error, terminal or log messages, maybe missing beginfig/endfig") + err("unknown error, no error, terminal or log messages, maybe missing beginfig/endfig") end end else @@ -165,20 +91,20 @@ function luamplib.report(result) return false end -function luamplib.process(data) +function process(data) local converted, result = false, {} - local mpx = luamplib.load() + local mpx = load() if mpx and data then local result = mpx:execute(data) - if luamplib.report(result) then + if report(result) then if result.fig then - converted = luamplib.convert(result) + converted = convert(result) else - luamplib.warning("no figure output") + warn("no figure output") end end else - luamplib.error("Mem file unloadable. Maybe generated with a different version of mplib?") + err("Mem file unloadable. Maybe generated with a different version of mplib?") end return converted, result end @@ -187,8 +113,8 @@ local function getobjects(result,figure,f) return figure:objects() end -function luamplib.convert(result, flusher) - luamplib.flush(result, flusher) +function convert(result, flusher) + flush(result, flusher) return true -- done end @@ -301,13 +227,12 @@ local function flushconcatpath(path,open) return t end - -function luamplib.flush(result,flusher) +function flush(result,flusher) if result then local figures = result.fig if figures then for f=1, #figures do - luamplib.log("flushing figure %s",f) + log("flushing figure %s",f) local figure = figures[f] local objects = getobjects(result,figure,f) local fignum = tonumber((figure:filename()):match("([%d]+)$") or figure:charcode() or 0) @@ -344,7 +269,7 @@ function luamplib.flush(result,flusher) else local cs = object.color if cs and #cs > 0 then - pdf_literalcode(luamplib.colorconverter(cs)) + pdf_literalcode(colorconverter(cs)) end local ml = object.miterlimit if ml and ml ~= miterlimit then @@ -442,7 +367,7 @@ function luamplib.flush(result,flusher) end end -function luamplib.colorconverter(cr) +function colorconverter(cr) local n = #cr if n == 4 then local c, m, y, k = cr[1], cr[2], cr[3], cr[4] diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty index acdf367c53f..6f6d90e0e9d 100644 --- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty +++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty @@ -5,40 +5,22 @@ %% The original source files were: %% %% luamplib.dtx (with options: `package') -%% This is a generated file. %% -%% Copyright (C) 2008-2009 by Hans Hagen, Taco Hoekwater and Elie Roux -%% <elie.roux@telecom-bretagne.eu>. (Support: <lualatex-dev@tug.org>.) +%% See source file 'luamplib.dtx' for licencing and contact information. %% -%% This work is under the CC0 license. -%% -%% This Current Maintainer of this work is Elie Roux. -%% -%% This work consists of the main source file luamplib.dtx -%% and the derived files -%% luamplib.sty, luamplib.lua, luamplib-createmem.lua and luamplib.pdf. -%% - \bgroup\expandafter\expandafter\expandafter\egroup \expandafter\ifx\csname ProvidesPackage\endcsname\relax \input luatexbase-modutils.sty \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luamplib} - [2010/10/17 v1.06 mplib package for LuaTeX] + [2010/12/28 v1.07 mplib package for LuaTeX] \RequirePackage{luatexbase-modutils} \RequirePackage{fancyvrb} \fi - - \RequireLuaModule{luamplib} - - -\def\mplibsetformat#1{\directlua{luamplib.setformat([[#1]])}} - -\def\mplibsetmemfile#1{\directlua{luamplib.setmemfile([[#1]])}} - - +\def\mplibsetformat#1{% + \directlua{luamplib.setformat("\luatexluaescapestring{#1}")}} \ifnum\pdfoutput>0 \let\mplibtoPDF\pdfliteral \else @@ -52,35 +34,25 @@ \PackageWarning{mplib}{MPLib only works in PDF mode, no figure will be output.} \fi \fi - - \bgroup\expandafter\expandafter\expandafter\egroup \expandafter\ifx\csname ProvidesPackage\endcsname\relax - \def\mplibsetupcatcodes{ \catcode`\{=12 \catcode`\}=12 \catcode`\#=12 \catcode`\^=12 \catcode`\~=12 \catcode`\_=12 \catcode`\%=12 \catcode`\&=12 \catcode`\$=12 } - \def\mplibcode{% \bgroup % \mplibsetupcatcodes % \mplibdocode % } - \long\def\mplibdocode#1\endmplibcode{% \egroup % \mplibprocess{#1}% } - \long\def\mplibprocess#1{% - \directlua{luamplib.process([[#1]])}% + \directlua{luamplib.process("\luatexluaescapestring{#1}")}% } - \else - - -\makeatletter \begingroup \catcode`\,=13 \catcode`\-=13 @@ -89,21 +61,15 @@ \def-{\string-}% } \endgroup - - \newcommand\mplibaddlines[1]{% \begingroup % \FV@hack % \def\FV@ProcessLine##1{% - \directlua{luamplib.addline([[##1]])}% + \directlua{luamplib.addline("\luatexluaescapestring{##1}")}% }% \csname FV@SV@#1\endcsname % \endgroup % } - -\makeatother - - \newenvironment{mplibcode}{% \VerbatimEnvironment % \begin{SaveVerbatim}{memoire}% @@ -114,11 +80,7 @@ } \fi - - \ifx\mplibscratchbox\undefined \newbox\mplibscratchbox \fi - - \def\mplibstarttoPDF#1#2#3#4{ \hbox\bgroup \xdef\MPllx{#1}\xdef\MPlly{#2}% @@ -132,7 +94,6 @@ \setbox\mplibscratchbox\vbox\bgroup \noindent } - \def\mplibstoptoPDF{% \egroup % \setbox\mplibscratchbox\hbox % @@ -151,8 +112,6 @@ \box\mplibscratchbox \egroup } - - \def\mplibtextext#1#2#3#4#5{% \begingroup \setbox\mplibscratchbox\hbox @@ -169,7 +128,6 @@ \box\mplibscratchbox \endgroup } - \endinput %% %% End of file `luamplib.sty'. |