From 4c6b2057b47961198ade9efc21dea4402538ac2b Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Tue, 5 May 2020 21:06:11 +0200 Subject: more work on partotei(). checkpars() being discarded --- ekdosis.dtx | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/ekdosis.dtx b/ekdosis.dtx index cbd6637..41025b5 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -1267,6 +1267,9 @@ local endpoem = lpeg.Cs(lnbrk * lpeg.S("*!") * bsqbrackets^-1) local sections = lpeg.Cs(lpeg.P("book") + lpeg.P("part") + lpeg.P("chapter") + lpeg.P("section") + lpeg.P("subsection") + lpeg.P("subsubsection")) +local par = lpeg.P(lpeg.P("\\par") * spce^1) +local parb = lpeg.P(lpeg.Cs("\\p@rb") * spce^1) +local para = lpeg.P(lpeg.Cs("\\p@ra") * spce^1) -- Bind to local variables local next = next @@ -1747,26 +1750,26 @@ local function envtotei(str) then -- 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("}") - * bcbracesii * spcenc^-1, - "\n<"..envtotags[i].b..envtotags[i].c..">") + -- str = gsub(str, lpeg.P("\\par") * spcenc^-1 * lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") + -- * lpeg.Cs(envtotags[i].a) * lpeg.P("}") + -- * 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("}") -- * 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, 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("}") * bcbracesii * spcenc^-1, - "<"..envtotags[i].b..envtotags[i].c..">") + "\\p@rb <"..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

") + "\\p@ra ") else str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") * lpeg.Cs(envtotags[i].a) * lpeg.P("}") @@ -1854,13 +1857,21 @@ end local function partotei(str) str = gsub(str, lpeg.P(lpeg.P("\\par") * spcenc^1)^1, "\\par ") + str = gsub(str, ((para + parb) * par^-1)^2, "\\p@r ") + str = string.gsub(str, "\\p@ra%s?", "

") + str = string.gsub(str, "\\p@rb%s?", "

") + str = string.gsub(str, "\\p@r%s?", "") +-- str = gsub(str, lpeg.P(lpeg.P("\\p@r") * spcenc^1)^1, "\\p@r ") +-- str = gsub(str, lpeg.P(lpeg.P("\\p@r") * spcenc^1 * (lpeg.P("\\par") * spcenc^1)^-1)^1, "\\p@r ") str = string.gsub(str, "%s?\\par%s?", "

", 1) + --str = string.gsub(str, "(\\par)(%s-)(%<%/?div%d?)", "%3") + str = string.gsub(str, "(%)(%s-)(%<%/?div%d?)", "%3") str = string.gsub(str, "%s?\\par%s?", "

") str = string.gsub(str, "

%s?

", "") str = string.gsub(str, "(%)%s?(%)$", "%2") str = string.gsub(str, "(%)%s?$", "") str = string.gsub(str, "(

)%s?()", "%2%1") - str = string.gsub(str, "(%)%s?(.-)", "%2%1") + -- str = string.gsub(str, "(%)%s?(.-)", "%2%1") return str end @@ -1980,7 +1991,7 @@ local function ekddivs_totei(str) if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end if tein ~= "" then tein = " n=\""..tein.."\"" else end if teidepth ~= "" then teidepth = " depth=\""..teidepth.."\"" else end - return string.format("\\par %s", + return string.format("%s", teitype, tein, teidepth, teihead) else return "" @@ -1999,7 +2010,7 @@ local function section_totei(str) else ctr = divdepth[secname] arg = string.sub(arg, 2, -2) - return string.format("\\par %s", + return string.format("\\p@rb %s\\p@ra ", ctr, secname, arg) end end) @@ -2100,7 +2111,7 @@ local function textotei(str) str = cmdtotei(str) str = self_close_tags(str) str = partotei(str) - str = checkpars(str) +-- str = checkpars(str) if ekddivs then else -- cgit v1.2.3