From 7d3ff2b76d62d69d36a90bba0d306d920ae5b415 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Wed, 22 Apr 2020 13:08:46 +0200 Subject: insert in
tags attributes collected by mkenvdata() --- ekdosis.dtx | 78 ++++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/ekdosis.dtx b/ekdosis.dtx index 64122d3..257af7c 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -1630,34 +1630,51 @@ end local function envtotei(str) for i = 1,#envtotags do - if envtotags[i].b ~= "" + if envtotags[i].b ~= "" and isfound(close_p, envtotags[i].b) then - if isfound(close_p, envtotags[i].b) + if envtotags[i].b == "p" then - str = gsub(str, lpeg.P("\\par") * 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..">") - str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") - * lpeg.Cs(envtotags[i].a) * lpeg.P("}") * spcenc^-1 * lpeg.P("\\par"), - "\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

") + 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("\\begin") * spcenc^-1 * lpeg.P("{") + 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, - "<"..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<"..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, + "<"..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, @@ -1665,6 +1682,7 @@ 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("{") @@ -2144,6 +2162,24 @@ function ekdosis.mkenv() ..", \\luastringN{\\par#1\\par})}\\fi" .."}") end + if aligned_texts[i].attribute ~= "" + then + table.insert(environments, "\\EnvtoTEI{" + .. aligned_texts[i].text + .."}{div}" + .."[xml:id=\"div-" + .. aligned_texts[i].text + .. "\" " + .. aligned_texts[i].attribute + .. "]") + else + table.insert(environments, "\\EnvtoTEI{" + .. aligned_texts[i].text + .."}{div}" + .."[xml:id=\"div-" + .. aligned_texts[i].text + .. "\"]") + end end str = table.concat(environments) return str -- cgit v1.2.3