summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-03-20 21:30:20 +0000
committerKarl Berry <karl@freefriends.org>2015-03-20 21:30:20 +0000
commitae842bc213f34ca95dc9c206d56e00258098f479 (patch)
treec9b55ce72cd2ee315524de99762b628e5423130b /Master/texmf-dist/tex/luatex
parentb9277f42feaf18549d8112685f45894a5789bbbd (diff)
luamplib (20mar15)
git-svn-id: svn://tug.org/texlive/trunk@36575 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex')
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.lua110
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.sty24
2 files changed, 72 insertions, 62 deletions
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
index 6a8301b06a1..9a8e1aad02f 100644
--- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
+++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
@@ -18,8 +18,8 @@ luamplib.lastlog = ""
local err, warn, info, log = luatexbase.provides_module({
name = "luamplib",
- version = "2.9.1",
- date = "2015/01/26",
+ version = "2.10.0",
+ date = "2015/03/20",
description = "Lua package to typeset Metapost with LuaTeX's MPLib.",
})
@@ -142,6 +142,7 @@ local noneedtoreplace = {
["mp-abck.mpiv"] = true,
["mp-apos.mpiv"] = true,
["mp-asnc.mpiv"] = true,
+ ["mp-bare.mpiv"] = true,
["mp-base.mpiv"] = true,
["mp-butt.mpiv"] = true,
["mp-char.mpiv"] = true,
@@ -155,13 +156,13 @@ local noneedtoreplace = {
["mp-grid.mpiv"] = true,
["mp-grph.mpiv"] = true,
["mp-idea.mpiv"] = true,
+ ["mp-luas.mpiv"] = true,
["mp-mlib.mpiv"] = true,
["mp-page.mpiv"] = true,
["mp-shap.mpiv"] = true,
["mp-step.mpiv"] = true,
["mp-text.mpiv"] = true,
["mp-tool.mpiv"] = true,
- ["mp-luas.mpiv"] = true,
}
luamplib.noneedtoreplace = noneedtoreplace
@@ -183,6 +184,23 @@ local function replaceformatmp(file,newfile,ofmodify)
return newfile
end
+local esctex = "!!!T!!!E!!!X!!!"
+local esclbr = "!!!!!LEFTBRCE!!!!!"
+local escrbr = "!!!!!RGHTBRCE!!!!!"
+local escshar = "!!!!!SHARPE!!!!!"
+local escpcnt = "!!!!!PERCENT!!!!!"
+local begname = "%f[A-Z_a-z]"
+local endname = "%f[^A-Z_a-z]"
+
+local function protecttexcontents(str)
+ str = stringgsub(str,"\\%%","\\"..escpcnt)
+ str = stringgsub(str,"%%.-\n", "")
+ str = stringgsub(str,"%%.-$", "")
+ str = stringgsub(str,'"','"&ditto&"')
+ str = stringgsub(str,"\n%s*"," ")
+ return str
+end
+
local function replaceinputmpfile (name,file)
local ofmodify = lfsattributes(file,"modification")
if not ofmodify then return file end
@@ -202,24 +220,20 @@ local function replaceinputmpfile (name,file)
local data = fh:read("*all"); fh:close()
data = stringgsub(data, "\"[^\n]-\"",
function(str)
- str = stringgsub(str,"([bem])tex%f[^A-Z_a-z]","%1!!!T!!!E!!!X!!!")
+ str = stringgsub(str,"([bem])tex"..endname,"%1"..esctex)
return str
end)
local count,cnt = 0,0
data,cnt = stringgsub(data,
- "%f[A-Z_a-z]btex%f[^A-Z_a-z]%s*(.-)%s*%f[A-Z_a-z]etex%f[^A-Z_a-z]",
+ begname.."btex"..endname.."%s*(.-)%s*"..begname.."etex"..endname,
function(str)
- str = stringgsub(str,"\\%%","\\!!!!!PERCENT!!!!!")
- str = stringgsub(str,"%%.-\n", "")
- str = stringgsub(str,"%%.-$", "")
- str = stringgsub(str,"\\!!!!!PERCENT!!!!!","\\%%")
- str = stringgsub(str,"[\n\r]%s*"," ")
- str = stringgsub(str,'"','"&ditto&"')
+ str = protecttexcontents(str)
+ str = stringgsub(str,"\\"..escpcnt,"\\%%")
return format("rawtextext(\"%s\")",str)
end)
count = count + cnt
data,cnt = stringgsub(data,
- "%f[A-Z_a-z]verbatimtex%f[^A-Z_a-z]%s*.-%s*%f[A-Z_a-z]etex%f[^A-Z_a-z]",
+ begname.."verbatimtex"..endname.."%s*.-%s*"..begname.."etex"..endname,
"")
count = count + cnt
if count == 0 then
@@ -231,7 +245,7 @@ local function replaceinputmpfile (name,file)
end
return file
end
- data = stringgsub(data,"([bem])!!!T!!!E!!!X!!!","%1tex")
+ data = stringgsub(data,"([bem])"..esctex,"%1tex")
fh = ioopen(newfile,"w")
if not fh then return file end
fh:write(data); fh:close()
@@ -595,9 +609,9 @@ enddef;
def TEX = textext enddef;
def fontmapfile primary filename = enddef;
def specialVerbatimTeX (text t) = special "MPlibVerbTeX="&t; enddef;
-def ignoreVerbatimTeX (text t) = enddef;
+def normalVerbatimTeX (text t) = special "PostMPlibVerbTeX="&t; enddef;
let VerbatimTeX = specialVerbatimTeX;
-extra_beginfig := extra_beginfig & " let VerbatimTeX = ignoreVerbatimTeX;" ;
+extra_beginfig := extra_beginfig & " let VerbatimTeX = normalVerbatimTeX;" ;
extra_endfig := extra_endfig & " let VerbatimTeX = specialVerbatimTeX;" ;
]]
luamplib.mplibcodepreamble = mplibcodepreamble
@@ -622,45 +636,38 @@ local function protecttextext(data)
data = stringgsub(data,"\r","\n")
data = stringgsub(data, "\"[^\n]-\"",
function(str)
- str = stringgsub(str,"%%","!!!!!PERCENT!!!!!")
- str = stringgsub(str,"([bem])tex%f[^A-Z_a-z]","%1!!!T!!!E!!!X!!!")
+ str = stringgsub(str,"%%",escpcnt)
+ str = stringgsub(str,"([bem])tex"..endname,"%1"..esctex)
return str
end)
data = stringgsub(data,
- "%f[A-Z_a-z]btex%f[^A-Z_a-z]%s*(.-)%s*%f[A-Z_a-z]etex%f[^A-Z_a-z]",
+ begname.."btex"..endname.."%s*(.-)%s*"..begname.."etex"..endname,
function(str)
- str = stringgsub(str,"\\%%","\\!!!!!PERCENT!!!!!")
- str = stringgsub(str,"%%.-\n", "")
- str = stringgsub(str,"%%.-$", "")
- str = stringgsub(str,'"','"&ditto&"')
- str = stringgsub(str,"\n%s*"," ")
+ str = protecttexcontents(str)
return format("rawtextext(\"%s\")",str)
end)
data = stringgsub(data,
- "%f[A-Z_a-z]verbatimtex%f[^A-Z_a-z]%s*(.-)%s*%f[A-Z_a-z]etex%f[^A-Z_a-z]",
+ begname.."verbatimtex"..endname.."%s*(.-)%s*"..begname.."etex"..endname,
function(str)
- str = stringgsub(str,"\\%%","\\!!!!!PERCENT!!!!!")
- str = stringgsub(str,"%%.-\n", "")
- str = stringgsub(str,"%%.-$", "")
- str = stringgsub(str,'"','"&ditto&"')
- str = stringgsub(str,"\n%s*"," ")
+ str = protecttexcontents(str)
return format("VerbatimTeX(\"%s\")",str)
end)
data = stringgsub(data, "\"[^\n]-\"",
function(str)
- str = stringgsub(str,"([bem])!!!T!!!E!!!X!!!","%1tex")
- str = stringgsub(str,"{", "!!!!!LEFTBRCE!!!!!")
- str = stringgsub(str,"}", "!!!!!RGHTBRCE!!!!!")
- str = stringgsub(str,"#", "!!!!!SHARPE!!!!!")
+ str = stringgsub(str,"([bem])"..esctex,"%1tex")
+ str = stringgsub(str,"{", esclbr)
+ str = stringgsub(str,"}", escrbr)
+ str = stringgsub(str,"#", escshar)
return format("\\detokenize{%s}",str)
end)
data = stringgsub(data,"%%.-\n", "")
luamplib.mpxcolors = {}
- data = stringgsub(data, "\\mpcolor%s*{(.-)}",
- function(str)
+ data = stringgsub(data, "\\mpcolor"..endname.."(.-){(.-)}",
+ function(opt,str)
local cnt = #luamplib.mpxcolors + 1
luamplib.mpxcolors[cnt] = format(
- "\\expandafter\\mplibcolor\\csname mpxcolor%i\\endcsname{%s}",cnt,str)
+ "\\expandafter\\mplibcolor\\csname mpxcolor%i\\endcsname%s{%s}",
+ cnt,opt,str)
return format("\\csname mpxcolor%i\\endcsname",cnt)
end)
texsprint(data)
@@ -700,10 +707,10 @@ end
local function makeTEXboxes (data)
data = stringgsub(data, "##", "#") -- restore # doubled in input string
- data = stringgsub(data, "!!!!!PERCENT!!!!!", "%%")
- data = stringgsub(data, "!!!!!LEFTBRCE!!!!!","{")
- data = stringgsub(data, "!!!!!RGHTBRCE!!!!!","}")
- data = stringgsub(data, "!!!!!SHARPE!!!!!", "#" )
+ data = stringgsub(data, escpcnt, "%%")
+ data = stringgsub(data, esclbr,"{")
+ data = stringgsub(data, escrbr,"}")
+ data = stringgsub(data, escshar, "#" )
local _,result = process(data, false)
domakeTEXboxes(result)
return data
@@ -751,15 +758,22 @@ end
local function putTEXboxes (object,prescript)
local box = prescript.MPlibTEXboxID
- local n,tw,th = box[1],box[2],box[3]
+ local n,tw,th = box[1],tonumber(box[2]),tonumber(box[3])
if n and tw and th then
local op = object.path
local first, second, fourth = op[1], op[2], op[4]
local tx, ty = first.x_coord, first.y_coord
- local sx, sy = (second.x_coord - tx)/tw, (fourth.y_coord - ty)/th
- local rx, ry = (second.y_coord - ty)/tw, (fourth.x_coord - tx)/th
- if sx == 0 then sx = 0.00001 end
- if sy == 0 then sy = 0.00001 end
+ local sx, rx, ry, sy = 1, 0, 0, 1
+ if tw ~= 0 then
+ sx = (second.x_coord - tx)/tw
+ rx = (second.y_coord - ty)/tw
+ if sx == 0 then sx = 0.00001 end
+ end
+ if th ~= 0 then
+ sy = (fourth.y_coord - ty)/th
+ ry = (fourth.x_coord - tx)/th
+ if sy == 0 then sy = 0.00001 end
+ end
start_pdf_code()
pdf_literalcode("%f %f %f %f %f %f cm",sx,rx,ry,sy,tx,ty)
texsprint(format("\\mplibputtextbox{%i}",n))
@@ -1008,6 +1022,7 @@ local function flush(result,flusher)
if TeX_code_t[f] then
texsprint(TeX_code_t[f])
end
+ local TeX_code_bot = {} -- PostVerbatimTeX
pdf_startfigure(fignum,llx,lly,urx,ury)
start_pdf_code()
if objects then
@@ -1019,6 +1034,8 @@ local function flush(result,flusher)
local tr_opaq,cr_over,shade_no = do_preobj_color(object,prescript)
if prescript and prescript.MPlibTEXboxID then
putTEXboxes(object,prescript)
+ elseif prescript and prescript.PostMPlibVerbTeX then
+ TeX_code_bot[#TeX_code_bot+1] = prescript.PostMPlibVerbTeX
elseif objecttype == "start_bounds" or objecttype == "stop_bounds" then
-- skip
elseif objecttype == "start_clip" then
@@ -1133,6 +1150,9 @@ local function flush(result,flusher)
end
stop_pdf_code()
pdf_stopfigure()
+ if #TeX_code_bot > 0 then
+ texsprint(TeX_code_bot)
+ end
end
end
end
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
index b826fc117af..1fdda30df69 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}
- [2015/01/26 v2.9.1 mplib package for LuaTeX]
+ [2015/03/20 v2.10.0 mplib package for LuaTeX]
\RequirePackage{luatexbase-modutils}
\fi
\RequireLuaModule{luamplib}
@@ -61,7 +61,7 @@
\long\def\mplibdocode#1\endmplibcode{%
\endgroup
\edef\mplibtemp{\directlua{luamplib.protecttextext([===[\unexpanded{#1}]===])}}%
- \directlua{ tex.sprint(table.concat(luamplib.mpxcolors)) }%
+ \directlua{ tex.sprint(luamplib.mpxcolors) }%
\directlua{luamplib.tempdata = luamplib.makeTEXboxes([===[\mplibtemp]===])}%
\directlua{luamplib.processwithTEXboxes(luamplib.tempdata)}%
\endgroup
@@ -83,7 +83,7 @@
\toks@\expandafter{\the\toks@#1}%
\def\mplibtemp@a{#2}\ifx\mplib@mplibcode\mplibtemp@a
\edef\mplibtemp{\directlua{luamplib.protecttextext([===[\the\toks@]===])}}%
- \directlua{ tex.sprint(table.concat(luamplib.mpxcolors)) }%
+ \directlua{ tex.sprint(luamplib.mpxcolors) }%
\directlua{luamplib.tempdata=luamplib.makeTEXboxes([===[\mplibtemp]===])}%
\directlua{luamplib.processwithTEXboxes(luamplib.tempdata)}%
\end{mplibcode}%
@@ -95,20 +95,6 @@
\fi
}
\fi
-\def\mplibcolor#1#2{%
- \ifcsname\string\color @#2\endcsname
- \edef#1{1 withprescript
- "MPlibOverrideColor=\csname\string\color @#2\endcsname"}%
- \else
- \ifdefined\extractcolorspecs
- \extractcolorspecs{#2}\mplibtemp@a\mplibtemp@b
- \convertcolorspec\mplibtemp@a\mplibtemp@b{cmyk}\mplibtemp@c
- \edef#1{(\mplibtemp@c)}%
- \else
- \errmessage{Undefined color `#2'}%
- \fi
- \fi
-}
\newtoks\everymplibtoks
\newtoks\everyendmplibtoks
\protected\def\everymplib{%
@@ -134,6 +120,10 @@
\ifnum\mplibstartlineno<\inputlineno\expandafter\mplibreplacenewlinebr\fi
}
\def\mpdim#1{ begingroup \the\dimexpr #1\relax\space endgroup } % gmp.sty
+\def\mplibcolor#1{%
+ \def\set@color{\edef#1{1 withprescript "MPlibOverrideColor=\current@color"}}%
+ \color
+}
\def\mplibnumbersystem#1{\directlua{luamplib.numbersystem = "#1"}}
\def\mplibmakenocache#1{\mplibdomakenocache #1,*,}
\def\mplibdomakenocache#1,{%