aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2019-04-25 20:43:01 +0200
committerRobert Alessi <alessi@robertalessi.net>2019-04-25 20:43:01 +0200
commit36440126b20a87e93336425ee3fbe2efc51dc300 (patch)
treeb2860f5fa7935b98a58130732fa5a5db7a360f43
parenta93925830205df5d06544a059be9c9c79e671ea2 (diff)
downloadekdosis-36440126b20a87e93336425ee3fbe2efc51dc300.tar.gz
added 'nordg' option to \rdg. new function envtotei()
-rw-r--r--ekdosis.dtx50
1 files 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]{%
501\edef\ekdsep{: } 501\edef\ekdsep{: }
502\NewDocumentCommand{\SetSeparator}{m}{\edef\ekdsep{#1}} 502\NewDocumentCommand{\SetSeparator}{m}{\edef\ekdsep{#1}}
503\newkeycommand+[\|]{\lem}[wit, alt, pre, post, prewit, postwit, 503\newkeycommand+[\|]{\lem}[wit, alt, pre, post, prewit, postwit,
504sep={\ekdsep}, 504sep={\ekdsep}, choice nosep={false,,true},
505choice nosep={false,,true}, choice nolem={false,,true}][1]{% 505choice nolem={false,,true}][1]{%
506 #1% 506 #1%
507 |\ifnum|% 507 |\ifnum|%
508 \commandkey{nolem}>0% 508 \commandkey{nolem}>0%
@@ -551,7 +551,11 @@ choice nosep={false,,true}, choice nolem={false,,true}][1]{%
551 |\fi|% 551 |\fi|%
552 }}% 552 }}%
553 |\fi|} 553 |\fi|}
554\newkeycommand+[\|]{\rdg}[wit, alt, pre, post, prewit, postwit][1]{% 554\newkeycommand+[\|]{\rdg}[wit, alt, pre, post, prewit, postwit,
555choice nordg={false,,true}][1]{%
556 |\ifnum|%
557 \commandkey{nordg}>0%
558 |\else|%
555 |\ifbool{al@rlmode}|% 559 |\ifbool{al@rlmode}|%
556 {\append@app{% 560 {\append@app{%
557 \bgroup% 561 \bgroup%
@@ -584,7 +588,7 @@ choice nosep={false,,true}, choice nolem={false,,true}][1]{%
584 \ifcommandkey{wit}{ \getsiglum{\commandkey{wit}}}{}% 588 \ifcommandkey{wit}{ \getsiglum{\commandkey{wit}}}{}%
585 \ifcommandkey{postwit}{ \commandkey{postwit}}{}% 589 \ifcommandkey{postwit}{ \commandkey{postwit}}{}%
586 }}% 590 }}%
587} 591 |\fi|}
588\newkeycommand+[\|]{\ekd@note}[pre, post][1]{% 592\newkeycommand+[\|]{\ekd@note}[pre, post][1]{%
589 \append@app{\ifcommandkey{pre}{\commandkey{pre}}{}% 593 \append@app{\ifcommandkey{pre}{\commandkey{pre}}{}%
590 #1% 594 #1%
@@ -850,6 +854,11 @@ local cmdtotags = {
850 {a="arb", b="s", c=" xml:lang=\"arb-Latn\" type=\"transliterated\" subtype=\"arabtex\""} 854 {a="arb", b="s", c=" xml:lang=\"arb-Latn\" type=\"transliterated\" subtype=\"arabtex\""}
851} 855}
852 856
857local envtotags = {
858 {a="center", b="p", c=" rend=\"centered\""}
859 {a="arab", b="p", c=" xml:lang=\"arb-Latn\" type=\"transliterated\" subtype=\"arabtex\""}
860}
861
853function ekdosis.newcmdtotag(cmd, tag, attr) 862function ekdosis.newcmdtotag(cmd, tag, attr)
854 if isintable(cmdtotags, cmd) 863 if isintable(cmdtotags, cmd)
855 then 864 then
@@ -887,7 +896,29 @@ local function lem_rdg_totei(str)
887 return str 896 return str
888end 897end
889 898
890local function textotei(str) 899local function envtotei(str)
900 for i = 1,#envtotags
901 do
902 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
903 * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
904 * bsqbracketsii * bcbracesii * spcenc^-1,
905 "<"..envtotags[i].b..envtotags[i].c..">")
906 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
907 * lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
908 "</"..envtotags[i].b..">")
909 end
910 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
911 * lpeg.Cs(ascii^1) * lpeg.P("}") * bsqbracketsii
912 * bcbracesii * spcenc^-1,
913 "<%1>")
914 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
915 * lpeg.Cs(ascii^1) * lpeg.P("}") * bsqbracketsii
916 * bcbracesii,
917 "</%1>")
918 return str
919end
920
921local function cmdtotei(str)
891 for i = 1,#cmdtotags 922 for i = 1,#cmdtotags
892 do 923 do
893 str = string.gsub(str, "(\\"..cmdtotags[i].a..")%s?%*?(%b{})", "%1[]%2") 924 str = string.gsub(str, "(\\"..cmdtotags[i].a..")%s?%*?(%b{})", "%1[]%2")
@@ -899,7 +930,7 @@ local function textotei(str)
899 braces = string.sub(braces, 2, -2) 930 braces = string.sub(braces, 2, -2)
900 return string.format("\"%s\"", braces) 931 return string.format("\"%s\"", braces)
901 end) 932 end)
902 body = textotei(body) 933 body = cmdtotei(body)
903 -- return string.format("<"..cmdtotags[i].b..cmdtotags[i].c.." %s>%s</"..cmdtotags[i].b..">", arg, body) 934 -- return string.format("<"..cmdtotags[i].b..cmdtotags[i].c.." %s>%s</"..cmdtotags[i].b..">", arg, body)
904 return string.format("<"..cmdtotags[i].b..cmdtotags[i].c..">%s</"..cmdtotags[i].b..">", body) 935 return string.format("<"..cmdtotags[i].b..cmdtotags[i].c..">%s</"..cmdtotags[i].b..">", body)
905 end) 936 end)
@@ -907,13 +938,13 @@ local function textotei(str)
907 str = string.gsub(str, "\\(%a+)%s?%*?(%b[])(%b{})", 938 str = string.gsub(str, "\\(%a+)%s?%*?(%b[])(%b{})",
908 function(cmd, opt, body) 939 function(cmd, opt, body)
909 body = string.sub(body, 2, -2) 940 body = string.sub(body, 2, -2)
910 body = textotei(body) 941 body = cmdtotei(body)
911 return string.format("<%s>%s</%s>", cmd, body, cmd) 942 return string.format("<%s>%s</%s>", cmd, body, cmd)
912 end) 943 end)
913 str = string.gsub(str, "\\(%a+)%s?%*?(%b{})", 944 str = string.gsub(str, "\\(%a+)%s?%*?(%b{})",
914 function(cmd, body) 945 function(cmd, body)
915 body = string.sub(body, 2, -2) 946 body = string.sub(body, 2, -2)
916 body = textotei(body) 947 body = cmdtotei(body)
917 return string.format("<%s>%s</%s>", cmd, body, cmd) 948 return string.format("<%s>%s</%s>", cmd, body, cmd)
918 end) 949 end)
919 str = string.gsub(str, "(%s)(%>)", "%2") 950 str = string.gsub(str, "(%s)(%>)", "%2")
@@ -924,7 +955,8 @@ function ekdosis.textotei(str)
924 str = xml_entities(str) 955 str = xml_entities(str)
925 str = string.gsub(str, "%s?\\par%s?", "</p>\n<p>") 956 str = string.gsub(str, "%s?\\par%s?", "</p>\n<p>")
926 str = lem_rdg_totei(str) 957 str = lem_rdg_totei(str)
927 str = textotei(str) 958 str = envtotei(str)
959 str = cmdtotei(str)
928 return str 960 return str
929end 961end
930 962