From 8976e160e584d67178ab14ee2110429a99623223 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Wed, 22 Apr 2020 14:57:37 +0200 Subject: shorter version of envtotei() --- ekdosis.dtx | 64 ++++++++++++++++++++++++++----------------------------------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/ekdosis.dtx b/ekdosis.dtx index 257af7c..72d9904 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -1630,51 +1630,42 @@ end local function envtotei(str) for i = 1,#envtotags do - if envtotags[i].b ~= "" and isfound(close_p, envtotags[i].b) + if envtotags[i].b ~= "" then - if envtotags[i].b == "p" + if isfound(close_p, envtotags[i].b) then - str = gsub(str, (lpeg.P("\\par") + lpeg.P("

")) * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") + if envtotags[i].b == "p" + then + str = gsub(str, (lpeg.P("\\par") + lpeg.P("

")) * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") + * lpeg.Cs(envtotags[i].a) * lpeg.P("}") + * bsqbracketsii * bcbracesii * spcenc^-1, + "\n<"..envtotags[i].b..envtotags[i].c..">") + else + str = gsub(str, (lpeg.P("\\par") + lpeg.P("

")) * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") + * lpeg.Cs(envtotags[i].a) * lpeg.P("}") + * bsqbracketsii * bcbracesii * spcenc^-1, + "

\n<"..envtotags[i].b..envtotags[i].c..">") + end + str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") + * lpeg.Cs(envtotags[i].a) * lpeg.P("}") * spcenc^-1 * (lpeg.P("\\par") + lpeg.P("

")), + "\n

") + str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") * lpeg.Cs(envtotags[i].a) * lpeg.P("}") * bsqbracketsii * bcbracesii * spcenc^-1, - "\n<"..envtotags[i].b..envtotags[i].c..">") + "<"..envtotags[i].b..envtotags[i].c..">") + str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") + * lpeg.Cs(envtotags[i].a) * lpeg.P("}"), + "\n

") else - str = gsub(str, (lpeg.P("\\par") + lpeg.P("

")) * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") + str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") * lpeg.Cs(envtotags[i].a) * lpeg.P("}") * bsqbracketsii * bcbracesii * spcenc^-1, - "

\n<"..envtotags[i].b..envtotags[i].c..">") + "<"..envtotags[i].b..envtotags[i].c..">") + str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") + * lpeg.Cs(envtotags[i].a) * lpeg.P("}"), + "") end - str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") - * lpeg.Cs(envtotags[i].a) * lpeg.P("}") * spcenc^-1 * (lpeg.P("\\par") + lpeg.P("

")), - "\n

") - str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") - * lpeg.Cs(envtotags[i].a) * lpeg.P("}") - * bsqbracketsii * bcbracesii * spcenc^-1, - "<"..envtotags[i].b..envtotags[i].c..">") - str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") - * lpeg.Cs(envtotags[i].a) * lpeg.P("}"), - "\n

") else - end - end - for i = 1,#envtotags - do - if envtotags[i].b ~= "" and not isfound(close_p, envtotags[i].b) - then - str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") - * lpeg.Cs(envtotags[i].a) * lpeg.P("}") - * bsqbracketsii * bcbracesii * spcenc^-1, - "<"..envtotags[i].b..envtotags[i].c..">") - str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") - * lpeg.Cs(envtotags[i].a) * lpeg.P("}"), - "") - else - end - end - for i = 1,#envtotags - do - if envtotags[i].b == "" - then str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") * lpeg.Cs(envtotags[i].a) * lpeg.P("}") * bsqbracketsii * bcbracesii * spcenc^-1, @@ -1682,7 +1673,6 @@ local function envtotei(str) str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") * lpeg.Cs(envtotags[i].a) * lpeg.P("}"), "") - else end end str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") -- cgit v1.2.3