summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luamplib/luamplib.lua')
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.lua52
1 files changed, 34 insertions, 18 deletions
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
index 8fb71d6fe64..e0db6e0c767 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.2,
- date = "2013/12/29",
+ version = 2.3,
+ date = "2014/01/20",
description = "Lua package to typeset Metapost with LuaTeX's MPLib.",
})
@@ -386,6 +386,38 @@ extra_beginfig := extra_beginfig & " let VerbatimTeX = ignoreVerbatimTeX;" ;
extra_endfig := extra_endfig & " let VerbatimTeX = specialVerbatimTeX;" ;
]]
+local function protecttextext(data)
+ local everymplib = tex.toks['everymplibtoks'] or ''
+ local everyendmplib = tex.toks['everyendmplibtoks'] or ''
+ data = " " .. everymplib .. data .. everyendmplib
+ data = stringgsub(data,
+ "%f[A-Za-z]btex%f[^A-Za-z]%s*(.-)%s*%f[A-Za-z]etex%f[^A-Za-z]",
+ function(str)
+ str = stringgsub(str,'"','"&ditto&"')
+ return format("rawtextext(\\unexpanded{\"%s\"})",str)
+ end)
+ data = stringgsub(data,
+ "%f[A-Za-z]verbatimtex%f[^A-Za-z]%s*(.-)%s*%f[A-Za-z]etex%f[^A-Za-z]",
+ function(str)
+ str = stringgsub(str,'"','"&ditto&"')
+ return format("VerbatimTeX(\\unexpanded{\"%s\"})",str)
+ end)
+ data = stringgsub(data, "\".-\"", -- hack for parentheses inside quotes
+ function(str)
+ str = stringgsub(str,"%(","%%%%LEFTPAREN%%%%")
+ str = stringgsub(str,"%)","%%%%RGHTPAREN%%%%")
+ return str
+ end)
+ data = stringgsub(data, "%f[A-Za-z]TEX%s*%b()", "\\unexpanded{%1}")
+ data = stringgsub(data, "%f[A-Za-z]textext%s*%b()", "\\unexpanded{%1}")
+ data = stringgsub(data, "%f[A-Za-z]textext%.[_a-z]+%s*%b()", "\\unexpanded{%1}")
+ data = stringgsub(data, "%%%%LEFTPAREN%%%%", "(") -- restore
+ data = stringgsub(data, "%%%%RGHTPAREN%%%%", ")") -- restore
+ texsprint(data)
+end
+
+luamplib.protecttextext = protecttextext
+
local factor = 65536*(7227/7200)
local function putTEXboxes (object,prescript)
@@ -436,22 +468,6 @@ local function domakeTEXboxes (data)
end
local function makeTEXboxes (data)
- data = "relax " .. data
- data = stringgsub(data, "([^A-Z_a-z])btex([^A-Z_a-z])",
- function(pre,post)
- post = stringgsub(post,"%s","")
- return pre .. 'rawtextext("' .. post
- end)
- data = stringgsub(data, "([^A-Z_a-z])verbatimtex([^A-Z_a-z])",
- function(pre,post)
- post = stringgsub(post,"%s","")
- return pre .. 'VerbatimTeX("' .. post
- end)
- data = stringgsub(data, "([^A-Z_a-z])etex([^A-Z_a-z])",
- function(pre,post)
- pre = stringgsub(pre,"%s","")
- return pre .. '")' .. post
- end)
local mpx = luamplib.load(currentformat)
if mpx and data then
local result = mpx:execute(mplibcodepreamble .. data)