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.lua24
1 files changed, 14 insertions, 10 deletions
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
index ac47afc42b3..69ab5cef027 100644
--- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
+++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.lua
@@ -580,22 +580,22 @@ luamplib.verbatiminput = false
local function protect_expansion (str)
if str then
- str = str:gsub("\\","\1Control\1")
- :gsub("%%","\1Comment\1")
- :gsub("#", "\1HashSign\1")
- :gsub("{", "\1LBrace\1")
- :gsub("}", "\1RBrace\1")
+ str = str:gsub("\\","!!!Control!!!")
+ :gsub("%%","!!!Comment!!!")
+ :gsub("#", "!!!HashSign!!!")
+ :gsub("{", "!!!LBrace!!!")
+ :gsub("}", "!!!RBrace!!!")
return format("\\unexpanded{%s}",str)
end
end
local function unprotect_expansion (str)
if str then
- return str:gsub("\1Control\1", "\\")
- :gsub("\1Comment\1", "%%")
- :gsub("\1HashSign\1","#")
- :gsub("\1LBrace\1", "{")
- :gsub("\1RBrace\1", "}")
+ return str:gsub("!!!Control!!!", "\\")
+ :gsub("!!!Comment!!!", "%%")
+ :gsub("!!!HashSign!!!","#")
+ :gsub("!!!LBrace!!!", "{")
+ :gsub("!!!RBrace!!!", "}")
end
end
@@ -622,7 +622,11 @@ local function process_mplibcode (data)
if not luamplib.verbatiminput then
data = data:gsub("\".-\"", protect_expansion)
+
+ data = data:gsub("\\%%", "\0PerCent\0")
data = data:gsub("%%.-\n","")
+ data = data:gsub("%zPerCent%z", "\\%%")
+
run_tex_code(format("\\mplibtmptoks\\expanded{{%s}}",data))
data = texgettoks"mplibtmptoks"
data = data:gsub("##", "#")