From 66a3577bf279ef34458035d41f8727b6f58cf95d Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Wed, 10 Jun 2020 08:08:58 +0200
Subject: sort texpatttotags table. envtotei(): handle up to two optional
 arguments between square brackets

---
 ekdosis.dtx | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index 3c0de48..6f77144 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -136,6 +136,9 @@ Running "make install" installs the files in the local TeX tree.
 %<*driver>
 \documentclass{ltxdoc}
 \usepackage[letterpaper,margin=25mm,left=50mm,nohead]{geometry}
+\usepackage{dox}
+\doxitem{Option}{option}{options}
+\usepackage{microtype}
 \usepackage{fontspec}
 \usepackage[english]{babel}
 \babelfont{rm}{Old Standard}
@@ -1538,6 +1541,7 @@ function ekdosis.newpatttotag(pat, repl)
    pat = string.gsub(pat, "%#[1-9]", "(.-)")
    repl = string.gsub(repl, "%#([1-9])", "%%%1")
    table.insert(texpatttotags, { a = pat, b = repl })
+   table.sort(texpatttotags, function(a ,b) return(#a.a > #b.a) end)
    return true
 end
 
@@ -1711,7 +1715,7 @@ local function envtotei(str)
 	 then
 	    str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
 			  * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
-			  * bcbracesii * spcenc^-1,
+			  * bsqbracketsii * bcbracesii * spcenc^-1,
 		       "\\p@rb <"..envtotags[i].b..envtotags[i].c..">")
 	    str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
 			  * lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
@@ -1719,7 +1723,7 @@ local function envtotei(str)
 	 else
 	    str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
 			  * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
-			  * bcbracesii * spcenc^-1,
+			  * bsqbracketsii * bcbracesii * spcenc^-1,
 		       "<"..envtotags[i].b..envtotags[i].c..">")
 	    str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
 			  * lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
@@ -1728,7 +1732,7 @@ local function envtotei(str)
       else
 	 str = gsub(str, lpeg.P("\\begin") * spcenc^-1 * lpeg.P("{")
 		       * lpeg.Cs(envtotags[i].a) * lpeg.P("}")
-		       * bcbracesii * spcenc^-1,
+		       * bsqbracketsii * bcbracesii * spcenc^-1,
 		    "")
 	 str = gsub(str, spcenc^-1 * lpeg.P("\\end") * spcenc^-1 * lpeg.P("{")
 		       * lpeg.Cs(envtotags[i].a) * lpeg.P("}"),
-- 
cgit v1.2.3

