From 0d0a8e1ba25d24da6db332760588a1a922028652 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 14 Nov 2019 21:55:29 +0000 Subject: luamplib (14nov19) git-svn-id: svn://tug.org/texlive/trunk@52795 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/source/luatex/luamplib/luamplib.dtx | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'Master/texmf-dist/source') diff --git a/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx b/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx index 0ca8f9dbc5d..c93ff8c8290 100644 --- a/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx +++ b/Master/texmf-dist/source/luatex/luamplib/luamplib.dtx @@ -1158,22 +1158,22 @@ luamplib.verbatiminput = false % \begin{macrocode} 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 @@ -1210,7 +1210,11 @@ local function process_mplibcode (data) % \begin{macrocode} 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" % \end{macrocode} -- cgit v1.2.3