From 121940357680091667596eba4099c96c2f5d0fc3 Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Mon, 29 Aug 2022 16:42:07 +0200
Subject: \App needed a function, not a simple pattern

---
 ekdosis.dtx | 37 +++++++++++++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index c8e5080..1838f4e 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -11033,6 +11033,7 @@ local rawcmd = lpeg.Cs(dblbkslash * ascii^1)
 local aftercmd = lpeg.Cs(lpeg.S("*[{,.?;:'`\"") + dblbkslash)
 local cmdargs = lpeg.Cs(spce^-1 * bsqbracketsii * bcbracesii * bsqbrackets^-1)
 local app = lpeg.Cs("app")
+local App = lpeg.Cs("App")
 local lemrdg = lpeg.Cs(lpeg.Cs("lem") + lpeg.Cs("rdg"))
 local note = lpeg.Cs("note")
 local inlem = lpeg.Cs{ "<lem" * ((1 - (lpeg.P"<lem" + lpeg.P"</lem>")) + lpeg.V(1))^0 * "</lem>" }
@@ -11455,8 +11456,6 @@ local texpatttotags = {
    {a="\\ekdpb%s+%*?{(.-)}", b=""},
    {a="\\ekdpb%s+%*\\?", b=""},
    {a="\\mbox%s+(%b{})", b="ekd@ob%1ekd@cb"},
-   {a="\\App%s+(%b[])(%b{})(%b{})", b="\\app[%1]{%2%3}"},
-   {a="\\App%s+(%b{})(%b{})", b="\\app{%1%2}"},
    {a="\\LR%s+(%b{})", b="ekd@ob%1ekd@cb"},
    {a="\\RL%s+(%b{})", b="ekd@ob%1ekd@cb"},
    {a="\\%=%=%=%s?", b="—"},
@@ -11624,6 +11623,39 @@ local function remove_extra_anchors(str)
    return str
 end
 
+local function App_totei(str)
+   str = gsub(str,
+	      dblbkslash *
+		 App *
+		 spcenc^-1 *
+		 bsqbrackets *
+		 bcbraces *
+		 bcbraces *
+		 spcenc^-1,
+		 function(bkslash, cmd, opt, argi, argii)
+		    argi = string.sub(argi, 2, -2)
+		    argii = string.sub(argii, 2, -2)
+		    opt = get_attr_value(opt, "type")
+		    if opt ~= "" then opt = " type=\""..opt.."\"" else end
+		    return App_totei(string.format("<app%s>%s%s</app>",
+						   opt, argi, argii))
+   end)
+   str = gsub(str,
+	      dblbkslash *
+		 App *
+		 spcenc^-1 *
+		 bcbraces *
+		 bcbraces *
+		 spcenc^-1,
+		 function(bkslash, cmd, argi, argii)
+		    argi = string.sub(argi, 2, -2)
+		    argii = string.sub(argii, 2, -2)
+		    return App_totei(string.format("<app>%s%s</app>",
+						   argi, argii))
+   end)
+   return str
+end
+
 local function app_totei(str)
    str = gsub(str,
 	      dblbkslash *
@@ -12464,6 +12496,7 @@ local function textotei(str)
    str = texpatttotei(str)
    str = note_totei(str)
    str = remove_extra_anchors(str)
+   str = App_totei(str)
    str = app_totei(str)
    str = rdgGrp_totei(str)
    str = lem_rdg_totei(str)
-- 
cgit v1.2.3

