aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2021-02-02 08:33:43 +0100
committerRobert Alessi <alessi@robertalessi.net>2021-02-02 08:33:43 +0100
commit6f3b36f0d1f8fa8f476a72c34d80166fd95ed39e (patch)
treef02c20f26daf8df6085b3901c592b1d0bf985cde
parentc0d0bfdb0af577c342508a42cc488430eee6e46f (diff)
downloadekdosis-6f3b36f0d1f8fa8f476a72c34d80166fd95ed39e.tar.gz
bugfix: divs needed to be processed twice and in 'overlapping' mode for the TEI output to validate
-rw-r--r--ekdosis.dtx28
1 files changed, 22 insertions, 6 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 5f5eab3..53eda98 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -8898,7 +8898,7 @@ local function close_ekddivs_in_between(str)
8898 end 8898 end
8899 for ndivi = 1, maxdepth 8899 for ndivi = 1, maxdepth
8900 do 8900 do
8901 str = string.gsub(str, "(<div .-depth%=\")("..ndivi..")(\".->)(.-)(<div .-depth%=\")(%d)(\".->)", 8901 str = string.gsub(str, "(<div [^%>]-[Dd]epth%=\")("..ndivi..")(\".->)(.-)(<div [^%>]-depth%=\")(%d)(\".->)",
8902 function(bdivi, ndivi, edivi, between, bdivii, ndivii, edivii) 8902 function(bdivi, ndivi, edivi, between, bdivii, ndivii, edivii)
8903 local firstdiv = ndivi 8903 local firstdiv = ndivi
8904 local lastdiv = ndivii 8904 local lastdiv = ndivii
@@ -8915,11 +8915,17 @@ local function close_ekddivs_in_between(str)
8915 firstdivindex = firstdivindex - 1 8915 firstdivindex = firstdivindex - 1
8916 end 8916 end
8917 end 8917 end
8918 bdivii = string.gsub(bdivii, "depth", "Depth")
8918 return string.format("%s%s%s%s%s%s%s%s", 8919 return string.format("%s%s%s%s%s%s%s%s",
8919 bdivi, ndivi, edivi, between, closedivs, bdivii, ndivii, edivii) 8920 bdivi, ndivi, edivi, between,
8921 closedivs, bdivii, ndivii, edivii)
8920 end) 8922 end)
8921 end 8923 end
8922 str = string.gsub(str, "(<div.-)(%sdepth%=\"%d\")(.->)", "%1%3") 8924 return str
8925end
8926
8927local function clean_ekddivs(str)
8928 str = string.gsub(str, "(<div.-)(%s[Dd]epth%=\"%d\")(.->)", "%1%3")
8923 used_ndivs = {} 8929 used_ndivs = {}
8924 return str 8930 return str
8925end 8931end
@@ -8927,7 +8933,7 @@ end
8927local function close_ndivs_in_between(str) 8933local function close_ndivs_in_between(str)
8928 for ndivi = 1, 6 8934 for ndivi = 1, 6
8929 do 8935 do
8930 str = string.gsub(str, "(<div)("..ndivi..")(.->)(.-)(<div)([1-6])(.->)", 8936 str = string.gsub(str, "(<[Dd]iv)("..ndivi..")(.->)(.-)(<div)([1-6])(.->)",
8931 function(bdivi, ndivi, edivi, between, bdivii, ndivii, edivii) 8937 function(bdivi, ndivi, edivi, between, bdivii, ndivii, edivii)
8932 local firstdiv = ndivi 8938 local firstdiv = ndivi
8933 local lastdiv = ndivii 8939 local lastdiv = ndivii
@@ -8944,11 +8950,17 @@ local function close_ndivs_in_between(str)
8944 firstdivindex = firstdivindex - 1 8950 firstdivindex = firstdivindex - 1
8945 end 8951 end
8946 end 8952 end
8953 bdivii = string.gsub(bdivii, "div", "Div")
8947 return string.format("%s%s%s%s%s%s%s%s", 8954 return string.format("%s%s%s%s%s%s%s%s",
8948 bdivi, ndivi, edivi, between, closedivs, bdivii, ndivii, edivii) 8955 bdivi, ndivi, edivi, between,
8949 8956 closedivs, bdivii, ndivii, edivii)
8950 end) 8957 end)
8951 end 8958 end
8959 return str
8960end
8961
8962local function clean_latexdivs(str)
8963 str = string.gsub(str, "(<Div)([1-6])(.->)", "<div%2%3")
8952 used_ndivs = {} 8964 used_ndivs = {}
8953 return str 8965 return str
8954end 8966end
@@ -8973,9 +8985,13 @@ local function textotei(str)
8973 then 8985 then
8974 str = close_ekddivs_at_end(str) 8986 str = close_ekddivs_at_end(str)
8975 str = close_ekddivs_in_between(str) 8987 str = close_ekddivs_in_between(str)
8988 str = close_ekddivs_in_between(str)
8989 str = clean_ekddivs(str)
8976 else 8990 else
8977 str = close_ndivs_at_end(str) 8991 str = close_ndivs_at_end(str)
8978 str = close_ndivs_in_between(str) 8992 str = close_ndivs_in_between(str)
8993 str = close_ndivs_in_between(str)
8994 str = clean_latexdivs(str)
8979 end 8995 end
8980 return str 8996 return str
8981end 8997end