From 5a2b496bee2c50ba6f8a6cc83cc78de4ea6d44b1 Mon Sep 17 00:00:00 2001
From: Robert Alessi
") 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("}" * spcenc^-1 * lpeg.P("\\par")), - ""..envtotags[i].b..">\n
") str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{") * lpeg.Cs(envtotags[i].a) * lpeg.P("}"), - ""..envtotags[i].b..">") + ""..envtotags[i].b..">\n
") else str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") * lpeg.Cs(envtotags[i].a) * lpeg.P("}") @@ -1741,6 +1741,28 @@ local function partotei(str) return str end +local function checkpars(str) + for i = 1,#envtotags + do + if isfound(close_p, envtotags[i].b) + then + str = string.gsub(str, "(%
%s])(.-<"..envtotags[i].b.."[%>%s])", function(par, substr_tag) + substr_tag = checkpars(substr_tag) + substr = string.gsub(substr_tag, "(.-)(<"..envtotags[i].b.."[%>%s])", "%1") + tag = string.gsub(substr_tag, "(.-)(<"..envtotags[i].b.."[%>%s])", "%2") + if string.find(substr, "<%/p[%>%s]") + then + return string.format("%s%s%s", par, substr, tag) + else + return string.format("%s%s
%s", par, substr, tag) + end + end) + else + end + end + return str +end + local function textotei(str) str = xml_entities(str) str = texpatttotei(str) @@ -1758,6 +1780,7 @@ local function textotei(str) str = envtotei(str) str = cmdtotei(str) str = partotei(str) + str = checkpars(str) return str end @@ -1856,8 +1879,9 @@ local tidy = nil local function cleanup_tei() local f = assert(io.open(teifilename.."_tmp.xml", "r")) t = f:read("*a") - t = string.gsub(t, "%%
\n", "") + t = string.gsub(t, "%%s?%
", "") t = string.gsub(t, "^\n", "") + f:close() local fw = assert(io.open(teifilename.."_tmp.xml", "w")) fw:write(t) fw:close() @@ -2061,7 +2085,7 @@ function ekdosis.mkenv() .."\\end{nthcolumn}" .."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata(" .. aligned_texts[i].column - ..", \\luastringN{#1})}\\fi" + ..", \\luastringN{\\par#1\\par})}\\fi" .."}") table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."*}{+b}" .."{\\begin{nthcolumn*}{".. aligned_texts[i].column.."}[]" @@ -2073,7 +2097,7 @@ function ekdosis.mkenv() .."\\end{nthcolumn*}" .."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata(" .. aligned_texts[i].column - ..", \\luastringN{#1})}\\fi" + ..", \\luastringN{\\par#1\\par})}\\fi" .."}") else table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."}{+b}" @@ -2083,7 +2107,7 @@ function ekdosis.mkenv() .."}{\\end{nthcolumn}" .."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata(" .. aligned_texts[i].column - ..", \\luastringN{#1})}\\fi" + ..", \\luastringN{\\par#1\\par})}\\fi" .."}") table.insert(environments, "\\NewDocumentEnvironment{".. aligned_texts[i].text.."*}{+b}" .."{\\begin{nthcolumn*}{"..aligned_texts[i].column.."}[]" @@ -2093,7 +2117,7 @@ function ekdosis.mkenv() .."\\end{nthcolumn*}" .."\\csname iftei@export\\endcsname\\luadirect{ekdosis.storecoldata(" .. aligned_texts[i].column - ..", \\luastringN{#1})}\\fi" + ..", \\luastringN{\\par#1\\par})}\\fi" .."}") end end -- cgit v1.2.3