From 69e14a448f99226dd21485bdc61108ab97126323 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Fri, 10 Apr 2020 15:56:18 +0200 Subject: new function partotei(). put on hold tei_p_open boolean --- ekdosis.dtx | 63 ++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/ekdosis.dtx b/ekdosis.dtx index d6a328e..9bc6304 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -1401,6 +1401,7 @@ local cmdtotags = { } local texpatttotags = { + {a="\\icite%s?%[(.-)%]%[(.-)%]{(.-)}", b="%1 %2"}, {a="\\icite%s?%[(.-)%]{(.-)}", b="%1"}, {a="\\icite%s?{(.-)}", b=""} } @@ -1628,16 +1629,24 @@ local function envtotei(str) do if envtotags[i].b ~= "" then - -- if tei_p_open and envtotags[i].b == "p" or envtotags[i].b == "lg" - if tei_p_open and isfound(close_p, envtotags[i].b) + -- -- if tei_p_open and envtotags[i].b == "p" or envtotags[i].b == "lg" + -- if tei_p_open and isfound(close_p, envtotags[i].b) + if isfound(close_p, envtotags[i].b) 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, 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..">") + * 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

") + * lpeg.Cs(envtotags[i].a) * lpeg.P("}" * spcenc^-1 * lpeg.P("\\par")), + "\n

") + str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") + * lpeg.Cs(envtotags[i].a) * lpeg.P("}"), + "") else str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") * lpeg.Cs(envtotags[i].a) * lpeg.P("}") @@ -1723,22 +1732,32 @@ local function cmdtotei(str) return str end +local function partotei(str) + str = string.gsub(str, "\\par%s-", "

", 1) + str = string.gsub(str, "\\par%s-", "

") + str = string.gsub(str, "

%s-

", "") + str = string.gsub(str, "(%)%s-(%)$", "%2") + str = string.gsub(str, "(%)%s-$", "") + return str +end + local function textotei(str) str = xml_entities(str) str = texpatttotei(str) - if tei_p_open - then - str = string.gsub(str, "%s?\\par%s?", "

\n

") - else - str = string.gsub(str, "%s?\\par%s?", "\n

") - tei_p_open = true - end + -- if tei_p_open + -- then + -- str = string.gsub(str, "%s?\\par%s?", "

\n

") + -- else + -- str = string.gsub(str, "%s?\\par%s?", "\n

") + -- tei_p_open = true + -- end str = note_totei(str) str = app_totei(str) str = lem_rdg_totei(str) str = versetotei(str) str = envtotei(str) str = cmdtotei(str) + str = partotei(str) return str end @@ -1879,16 +1898,16 @@ end function ekdosis.exporttei(str) local f = io.open(teifilename.."_tmp.xml", "a+") - f:write("\n

") - tei_p_open = true + -- f:write("\n

") + -- tei_p_open = true str = textotei(str) f:write(str) - if tei_p_open - then - f:write("

") - tei_p_open = false - else - end + -- if tei_p_open + -- then + -- f:write("

") + -- tei_p_open = false + -- else + -- end f:close() return true end -- cgit v1.2.3