From 09fae91702814f9a3cc7f80870cf414f3ad9aa59 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Fri, 8 May 2020 17:50:02 +0200 Subject: remove checkpars() and tidy up --- ekdosis.dtx | 140 +----------------------------------------------------------- 1 file changed, 2 insertions(+), 138 deletions(-) diff --git a/ekdosis.dtx b/ekdosis.dtx index 16c332e..22f9c9d 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -561,8 +561,8 @@ Running "make install" installs the files in the local TeX tree. \def\ekd@default@rule{\rule{2truein}{0.5pt}} % \def\ekd@default@rule{\vskip-\baselineskip\mbox{}\newline% % \rule{2truein}{0.5pt}} -% \def\footnoterule{\vskip-\baselineskip} -% \def\pcol@footnoterule{} + % \def\footnoterule{\vskip-\baselineskip} + % \def\pcol@footnoterule{} \newif\iffootnoterule \let\dflt@footnoterule\footnoterule \let\dflt@pcol@footnoterule\pcol@footnoterule @@ -1511,11 +1511,6 @@ local close_p = { function ekdosis.newcmdtotag(cmd, tag, attr) if isintable(cmdtotags, cmd) then - -- tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" - -- ..cmd.. - -- "\" already exists as a known command to be processed to TEI. " - -- .. - -- "Please pick another command.}}") local index = get_a_index(cmd, cmdtotags) table.remove(cmdtotags, index) table.insert(cmdtotags, {a = cmd, b = tag, c = " "..attr}) @@ -1538,24 +1533,13 @@ end function ekdosis.newenvtotag(env, tag, attr, closep) if isintable(envtotags, env) then - -- tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" - -- ..cmd.. - -- "\" already exists as a known environment to be processed to TEI. " - -- .. - -- "Please pick another environment name.}}") local index = get_a_index(env, envtotags) table.remove(envtotags, index) table.insert(envtotags, {a = env, b = tag, c = " "..attr, d = closep}) table.sort(envtotags, function(a ,b) return(#a.a > #b.a) end) - -- if closep == "yes" then - -- table.insert(close_p, tag) - -- else end else table.insert(envtotags, {a = env, b = tag, c = " "..attr, d = closep}) table.sort(envtotags, function(a ,b) return(#a.a > #b.a) end) - -- if closep == "yes" then - -- table.insert(close_p, tag) - -- else end end return true end @@ -1593,32 +1577,8 @@ local function note_totei(str) arg = string.sub(arg, 2, -2) teitype = get_attr_value(opt, "type") if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end - -- teitype = string.match(opt, "%f[%w]type%s?%=%s?%b{}") - -- or string.match(opt, "%f[%w]type%s?%=%s?%w+%f[%W]") - -- or "" - -- teitype = string.gsub(teitype, "type%s?%=%s?(%b{})", function(bbraces) - -- bbraces = string.sub(bbraces, 2, -2) - -- return string.format("%s", bbraces) - -- end) - -- teitype = string.gsub(teitype, "(type%s?%=%s?)(%w+%f[%W])", "%2") right = get_attr_value(opt, "labelb") - -- right = string.match(opt, "%f[%w]labelb%s?%=%s?%b{}") - -- or string.match(opt, "%f[%w]labelb%s?%=%s?%w+%f[%W]") - -- or "" - -- right = string.gsub(right, "labelb%s?%=%s?(%b{})", function(bbraces) - -- bbraces = string.sub(bbraces, 2, -2) - -- return string.format("%s", bbraces) - -- end) - -- right = string.gsub(right, "(labelb%s?%=%s?)(%w+%f[%W])", "%2") left = get_attr_value(opt, "labele") - -- left = string.match(opt, "%f[%w]labele%s?%=%s?%b{}") - -- or string.match(opt, "%f[%w]labele%s?%=%s?%w+%f[%W]") - -- or "" - -- left = string.gsub(left, "labele%s?%=%s?(%b{})", function(bbraces) - -- bbraces = string.sub(bbraces, 2, -2) - -- return string.format("%s", bbraces) - -- end) - -- left = string.gsub(left, "(labele%s?%=%s?)(%w+%f[%W])", "%2") if left ~= "" then return string.format( @@ -1630,26 +1590,6 @@ local function note_totei(str) "<%s%s target=\"#right(%s)\">%s", cmd, teitype, right, arg, cmd, right) end - -- - -- if left ~= "" and teitype ~= "" - -- then - -- return string.format( - -- "<%s type=\"%s\" target=\"#range(right(%s),left(%s))\">%s", - -- cmd, teitype, right, left, arg, cmd, right) - -- elseif left ~= "" and teitype == "" - -- then - -- return string.format( - -- "<%s target=\"#range(right(%s),left(%s))\">%s", - -- cmd, right, left, arg, cmd, right) - -- elseif left == "" and teitype ~= "" - -- then - -- return string.format( - -- "<%s type=\"%s\" target=\"#right(%s)\">%s", - -- cmd, teitype, right, arg, cmd, right) - -- else - -- return string.format("<%s target=\"#right(%s)\">%s", - -- cmd, right, arg, cmd, right) - -- end end) return str end @@ -1667,24 +1607,8 @@ local function app_totei(str) arg = string.sub(arg, 2, -2) opt = get_attr_value(opt, "type") if opt ~= "" then opt = " type=\""..opt.."\"" else end - -- opt = string.match(opt, "%f[%w]type%s?%=%s?%b{}") - -- or string.match(opt, "%f[%w]type%s?%=%s?%w+%f[%W]") - -- or "" - -- opt = string.gsub(opt, "type%s?%=%s?(%b{})", function(bbraces) - -- bbraces = string.sub(bbraces, 2, -2) - -- return string.format("%s", bbraces) - -- end) - -- opt = string.gsub(opt, "(type%s?%=%s?)(%w+%f[%W])", "%2") return app_totei(string.format("<%s%s>%s", cmd, opt, arg, cmd)) - -- if opt == "" - -- then - -- return app_totei(string.format("<%s>%s", - -- cmd, arg, cmd)) - -- else - -- return app_totei(string.format("<%s type=\"%s\">%s", - -- cmd, opt, arg, cmd)) - -- end end) return str end @@ -1701,24 +1625,12 @@ local function lem_rdg_totei(str) function(bkslash, cmd, opt, arg) opt = string.sub(opt, 2, -2) arg = string.sub(arg, 2, -2) - -- opt = string.match(opt, "%f[%w]wit%s?%=%s?%b{}") - -- or string.match(opt, "%f[%w]wit%s?%=%s?%w+%f[%W]") - -- or "" opt = get_attr_value(opt, "wit") if opt == "" then return lem_rdg_totei(string.format("<%s>%s", cmd, arg, cmd)) else - -- opt = string.gsub(opt, "wit%s?%=%s?(%b{})", function(bbraces) - -- bbraces = string.sub(bbraces, 2, -2) - -- bbraces = ekdosis.getsiglum(bbraces, "tei") - -- return string.format("%s", bbraces) - -- end) - -- opt = string.gsub(opt, "(wit%s?%=%s?)(%w+%f[%W])", function(attr, value) - -- value = ekdosis.getsiglum(value, "tei") - -- return string.format("%s", value) - -- end) opt = ekdosis.getsiglum(opt, "tei") return lem_rdg_totei(string.format("<%s wit=\"%s\">%s", cmd, opt, arg, cmd)) @@ -1729,7 +1641,6 @@ local function lem_rdg_totei(str) arg = string.sub(arg, 2, -2) return lem_rdg_totei(string.format("<%s>%s", cmd, arg, cmd)) end) - -- str = string.gsub(str, "(%.-)(%)(.-%<%/lem%>)", "%1%3%2") return str end @@ -1776,21 +1687,6 @@ local function envtotei(str) then if isfound(close_p, envtotags[i].b) or envtotags[i].d == "yes" then - -- 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("}") - -- * 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"), - -- "\n") str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{") * lpeg.Cs(envtotags[i].a) * lpeg.P("}") * bcbracesii * spcenc^-1, @@ -1889,39 +1785,13 @@ local function partotei(str) 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") - 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 @@ -2009,13 +1879,10 @@ local function ekddivs_totei(str) if ekddivs then arg = string.sub(arg, 2, -2) --- arg = arg.."," - -- teitype = get_attr_value(arg, "type") tein = get_attr_value(arg, "n") teihead = get_attr_value(arg, "head") teidepth = get_attr_value(arg, "depth") - -- if teitype ~= "" then teitype = " type=\""..teitype.."\"" else end if tein ~= "" then tein = " n=\""..tein.."\"" else end if teidepth ~= "" @@ -2095,7 +1962,6 @@ local function close_ekddivs_at_end(str) lastdivindex = lastdivindex - 1 end end --- str = string.gsub(str, "()", "%1%3") if isdiv then return str..closedivs.."" @@ -2144,7 +2010,6 @@ local function close_ndivs_at_end(str) lastdivindex = lastdivindex - 1 end end --- str = string.gsub(str, "()", "%1%3") if isdiv then return str..closedivs.."" @@ -2234,7 +2099,6 @@ local function textotei(str) str = cmdtotei(str) str = self_close_tags(str) str = partotei(str) --- str = checkpars(str) if ekddivs then str = close_ekddivs_at_end(str) -- cgit v1.2.3