From 36440126b20a87e93336425ee3fbe2efc51dc300 Mon Sep 17 00:00:00 2001
From: Robert Alessi
Date: Thu, 25 Apr 2019 20:43:01 +0200
Subject: added 'nordg' option to \rdg. new function envtotei()
---
ekdosis.dtx | 50 +++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 41 insertions(+), 9 deletions(-)
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 1490d4d..6ad89ae 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -501,8 +501,8 @@ idno={}, msName={}, origDate={}][3]{%
\edef\ekdsep{: }
\NewDocumentCommand{\SetSeparator}{m}{\edef\ekdsep{#1}}
\newkeycommand+[\|]{\lem}[wit, alt, pre, post, prewit, postwit,
-sep={\ekdsep},
-choice nosep={false,,true}, choice nolem={false,,true}][1]{%
+sep={\ekdsep}, choice nosep={false,,true},
+choice nolem={false,,true}][1]{%
#1%
|\ifnum|%
\commandkey{nolem}>0%
@@ -551,7 +551,11 @@ choice nosep={false,,true}, choice nolem={false,,true}][1]{%
|\fi|%
}}%
|\fi|}
-\newkeycommand+[\|]{\rdg}[wit, alt, pre, post, prewit, postwit][1]{%
+\newkeycommand+[\|]{\rdg}[wit, alt, pre, post, prewit, postwit,
+choice nordg={false,,true}][1]{%
+ |\ifnum|%
+ \commandkey{nordg}>0%
+ |\else|%
|\ifbool{al@rlmode}|%
{\append@app{%
\bgroup%
@@ -584,7 +588,7 @@ choice nosep={false,,true}, choice nolem={false,,true}][1]{%
\ifcommandkey{wit}{ \getsiglum{\commandkey{wit}}}{}%
\ifcommandkey{postwit}{ \commandkey{postwit}}{}%
}}%
-}
+ |\fi|}
\newkeycommand+[\|]{\ekd@note}[pre, post][1]{%
\append@app{\ifcommandkey{pre}{\commandkey{pre}}{}%
#1%
@@ -850,6 +854,11 @@ local cmdtotags = {
{a="arb", b="s", c=" xml:lang=\"arb-Latn\" type=\"transliterated\" subtype=\"arabtex\""}
}
+local envtotags = {
+ {a="center", b="p", c=" rend=\"centered\""}
+ {a="arab", b="p", c=" xml:lang=\"arb-Latn\" type=\"transliterated\" subtype=\"arabtex\""}
+}
+
function ekdosis.newcmdtotag(cmd, tag, attr)
if isintable(cmdtotags, cmd)
then
@@ -887,7 +896,29 @@ local function lem_rdg_totei(str)
return str
end
-local function textotei(str)
+local function envtotei(str)
+ for i = 1,#envtotags
+ do
+ 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("}"),
+ ""..envtotags[i].b..">")
+ end
+ str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
+ * lpeg.Cs(ascii^1) * lpeg.P("}") * bsqbracketsii
+ * bcbracesii * spcenc^-1,
+ "<%1>")
+ str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
+ * lpeg.Cs(ascii^1) * lpeg.P("}") * bsqbracketsii
+ * bcbracesii,
+ "%1>")
+ return str
+end
+
+local function cmdtotei(str)
for i = 1,#cmdtotags
do
str = string.gsub(str, "(\\"..cmdtotags[i].a..")%s?%*?(%b{})", "%1[]%2")
@@ -899,7 +930,7 @@ local function textotei(str)
braces = string.sub(braces, 2, -2)
return string.format("\"%s\"", braces)
end)
- body = textotei(body)
+ body = cmdtotei(body)
-- return string.format("<"..cmdtotags[i].b..cmdtotags[i].c.." %s>%s"..cmdtotags[i].b..">", arg, body)
return string.format("<"..cmdtotags[i].b..cmdtotags[i].c..">%s"..cmdtotags[i].b..">", body)
end)
@@ -907,13 +938,13 @@ local function textotei(str)
str = string.gsub(str, "\\(%a+)%s?%*?(%b[])(%b{})",
function(cmd, opt, body)
body = string.sub(body, 2, -2)
- body = textotei(body)
+ body = cmdtotei(body)
return string.format("<%s>%s%s>", cmd, body, cmd)
end)
str = string.gsub(str, "\\(%a+)%s?%*?(%b{})",
function(cmd, body)
body = string.sub(body, 2, -2)
- body = textotei(body)
+ body = cmdtotei(body)
return string.format("<%s>%s%s>", cmd, body, cmd)
end)
str = string.gsub(str, "(%s)(%>)", "%2")
@@ -924,7 +955,8 @@ function ekdosis.textotei(str)
str = xml_entities(str)
str = string.gsub(str, "%s?\\par%s?", "
\n")
str = lem_rdg_totei(str)
- str = textotei(str)
+ str = envtotei(str)
+ str = cmdtotei(str)
return str
end
--
cgit v1.2.3