aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2020-04-28 10:48:14 +0200
committerRobert Alessi <alessi@robertalessi.net>2020-04-28 10:48:14 +0200
commitd60e584fd104a46dcc8b59f4d18dd50548526310 (patch)
tree7f809de782146da312b1ef934cca83a16e5e1b89
parentb3d7ebd008cea5f2c9fc532316ac9051650e67d8 (diff)
downloadekdosis-d60e584fd104a46dcc8b59f4d18dd50548526310.tar.gz
close_divs_in_between() obviously needed a for loop, not a recursion
-rw-r--r--ekdosis.dtx23
1 files changed, 18 insertions, 5 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 5c142e2..5ec9df1 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -1874,12 +1874,25 @@ local function close_divs_at_end(str)
1874end 1874end
1875 1875
1876local function close_divs_in_between(str) 1876local function close_divs_in_between(str)
1877 for i = 0, 9 1877 for ndivi = 0, 9
1878 do 1878 do
1879 str = string.gsub(str, "(<div"..i..".->)(.-)(<div"..i..".->)", function(divi, between, divii) 1879 str = string.gsub(str, "(<div)("..ndivi..")(.->)(.-)(<div)(%d)(.->)",
1880 between = close_divs_in_between(between) 1880 function(bdivi, ndivi, edivi, between, bdivii, ndivii, edivii)
1881 return string.format("%s%s</div%s>%s", divi, between, i, divii) 1881 firstdiv = tonumber(ndivi)
1882 end) 1882 lastdiv = tonumber(ndivii)
1883 local closedivs = ""
1884 if firstdiv >= lastdiv
1885 then
1886 while firstdiv >= lastdiv
1887 do
1888 closedivs = closedivs.."</div"..firstdiv..">"
1889 firstdiv = firstdiv - 1
1890 end
1891 end
1892 return string.format("%s%s%s%s%s%s%s%s",
1893 bdivi, ndivi, edivi, between, closedivs, bdivii, ndivii, edivii)
1894
1895 end)
1883 end 1896 end
1884 return str 1897 return str
1885end 1898end