aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ekdosis.dtx26
1 files changed, 18 insertions, 8 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index deb5a4b..37fab9d 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -774,6 +774,12 @@ function ekdosis.newcmdtotag(cmd, tag, attr)
774 return true 774 return true
775end 775end
776 776
777local function xml_entities(str)
778 str = string.gsub(str, "%<", "&lt;")
779 str = string.gsub(str, "%>", "&gt;")
780 return str
781end
782
777local function lem_rdg_totei(str) 783local function lem_rdg_totei(str)
778 str = gsub(str, dblbkslash * lemrdg * spcenc^-1 * bsqbrackets * bcbraces * spcenc^-1, 784 str = gsub(str, dblbkslash * lemrdg * spcenc^-1 * bsqbrackets * bcbraces * spcenc^-1,
779 function(bkslash, cmd, opt, arg) 785 function(bkslash, cmd, opt, arg)
@@ -790,11 +796,7 @@ local function lem_rdg_totei(str)
790 return str 796 return str
791end 797end
792 798
793function ekdosis.textotei(str) 799local function textotei(str)
794 str = string.gsub(str, "%s?\\par%s?", "</p>\n<p>")
795 str = string.gsub(str, "%<", "&lt;")
796 str = string.gsub(str, "%>", "&gt;")
797 str = lem_rdg_totei(str)
798 for i = 1,#cmdtotags 800 for i = 1,#cmdtotags
799 do 801 do
800 str = string.gsub(str, "(\\"..cmdtotags[i].a..")%s?%*?(%b{})", "%1[]%2") 802 str = string.gsub(str, "(\\"..cmdtotags[i].a..")%s?%*?(%b{})", "%1[]%2")
@@ -806,7 +808,7 @@ function ekdosis.textotei(str)
806 braces = string.sub(braces, 2, -2) 808 braces = string.sub(braces, 2, -2)
807 return string.format("\"%s\"", braces) 809 return string.format("\"%s\"", braces)
808 end) 810 end)
809 body = ekdosis.textotei(body) 811 body = textotei(body)
810 -- return string.format("<"..cmdtotags[i].b..cmdtotags[i].c.." %s>%s</"..cmdtotags[i].b..">", arg, body) 812 -- return string.format("<"..cmdtotags[i].b..cmdtotags[i].c.." %s>%s</"..cmdtotags[i].b..">", arg, body)
811 return string.format("<"..cmdtotags[i].b..cmdtotags[i].c..">%s</"..cmdtotags[i].b..">", body) 813 return string.format("<"..cmdtotags[i].b..cmdtotags[i].c..">%s</"..cmdtotags[i].b..">", body)
812 end) 814 end)
@@ -814,19 +816,27 @@ function ekdosis.textotei(str)
814 str = string.gsub(str, "\\(%a+)%s?%*?(%b[])(%b{})", 816 str = string.gsub(str, "\\(%a+)%s?%*?(%b[])(%b{})",
815 function(cmd, opt, body) 817 function(cmd, opt, body)
816 body = string.sub(body, 2, -2) 818 body = string.sub(body, 2, -2)
817 body = ekdosis.textotei(body) 819 body = textotei(body)
818 return string.format("<%s>%s</%s>", cmd, body, cmd) 820 return string.format("<%s>%s</%s>", cmd, body, cmd)
819 end) 821 end)
820 str = string.gsub(str, "\\(%a+)%s?%*?(%b{})", 822 str = string.gsub(str, "\\(%a+)%s?%*?(%b{})",
821 function(cmd, body) 823 function(cmd, body)
822 body = string.sub(body, 2, -2) 824 body = string.sub(body, 2, -2)
823 body = ekdosis.textotei(body) 825 body = textotei(body)
824 return string.format("<%s>%s</%s>", cmd, body, cmd) 826 return string.format("<%s>%s</%s>", cmd, body, cmd)
825 end) 827 end)
826 str = string.gsub(str, "(%s)(%>)", "%2") 828 str = string.gsub(str, "(%s)(%>)", "%2")
827 return str 829 return str
828end 830end
829 831
832function ekdosis.textotei(str)
833 str = xml_entities(str)
834 str = string.gsub(str, "%s?\\par%s?", "</p>\n<p>")
835 str = lem_rdg_totei(str)
836 str = textotei(str)
837 return str
838end
839
830local teifilename = tex.jobname.."-tei" 840local teifilename = tex.jobname.."-tei"
831 841
832function ekdosis.setteifilename(str) 842function ekdosis.setteifilename(str)