From ae1f50d5718a7079efdcf93810416591ddb4aa93 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Sun, 3 May 2020 19:57:48 +0200 Subject: better linestotei() --- ekdosis.dtx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/ekdosis.dtx b/ekdosis.dtx index b3f6d33..cbd6637 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -1708,11 +1708,12 @@ local function relocate_notes(str) end local function linestotei(str) - str = "\n"..str +-- str = "\n"..str + str = string.gsub(str, "^%s?(.-)%s?$", "\n%1\n") -- str = gsub(str, endpoem, "\n") - str = gsub(str, poemline * lpeg.P(">"), "\n") - str = gsub(str, poemline, "\n") - str = str.."\n" + str = gsub(str, poemline * spcenc^-1 * lpeg.P(">"), "\n") + str = gsub(str, poemline * spcenc^-1, "\n") +-- str = str.."\n" return str end @@ -1852,13 +1853,14 @@ local function cmdtotei(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-$", "") - str = string.gsub(str, "(

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

", 1) + 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") return str end -- cgit v1.2.3