From 7122c0117c670647f6dceb7d0ae8a0c47f4bfc26 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Fri, 8 May 2020 14:54:38 +0200 Subject: added fourth element in envtotags to store user-defined closep. collect used depths in ekddivs and use max value in the following for-loop --- ekdosis.dtx | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/ekdosis.dtx b/ekdosis.dtx index 9978cd0..16c332e 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -1545,17 +1545,17 @@ function ekdosis.newenvtotag(env, tag, attr, closep) -- "Please pick another environment name.}}") local index = get_a_index(env, envtotags) table.remove(envtotags, index) - table.insert(envtotags, {a = env, b = tag, c = " "..attr}) + table.insert(envtotags, {a = env, b = tag, c = " "..attr, d = closep}) table.sort(envtotags, function(a ,b) return(#a.a > #b.a) end) - if closep == "yes" then - table.insert(close_p, tag) - else end + -- if closep == "yes" then + -- table.insert(close_p, tag) + -- else end else - table.insert(envtotags, {a = env, b = tag, c = " "..attr}) + table.insert(envtotags, {a = env, b = tag, c = " "..attr, d = closep}) table.sort(envtotags, function(a ,b) return(#a.a > #b.a) end) - if closep == "yes" then - table.insert(close_p, tag) - else end + -- if closep == "yes" then + -- table.insert(close_p, tag) + -- else end end return true end @@ -1774,7 +1774,7 @@ local function envtotei(str) do if envtotags[i].b ~= "" then - if isfound(close_p, envtotags[i].b) + if isfound(close_p, envtotags[i].b) or envtotags[i].d == "yes" then -- if envtotags[i].b == "p" -- then @@ -2154,7 +2154,16 @@ local function close_ndivs_at_end(str) end local function close_ekddivs_in_between(str) - for ndivi = 1, 7 + local maxdepth = 1 + for i in string.gmatch(str, "", "%1") + do + if tonumber(i) > tonumber(maxdepth) + then + maxdepth = i + else + end + end + for ndivi = 1, maxdepth do str = string.gsub(str, "(
)(.-)(
)", function(bdivi, ndivi, edivi, between, bdivii, ndivii, edivii) @@ -2183,7 +2192,7 @@ local function close_ekddivs_in_between(str) end local function close_ndivs_in_between(str) - for ndivi = 0, 6 + for ndivi = 1, 6 do str = string.gsub(str, "()(.-)()", function(bdivi, ndivi, edivi, between, bdivii, ndivii, edivii) -- cgit v1.2.3