From 3e4e2ad21bc51bf48c71a8a42dc818b0d0cb01c4 Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Sun, 25 Aug 2019 11:10:41 +0200
Subject: rewrote \rdg

---
 ekdosis.dtx | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 61 insertions(+), 4 deletions(-)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index 5a585a0..8a7c4e0 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -494,7 +494,7 @@ idno={}, msName={}, origDate={}][3]{%
     \luadirect{ekdosis.appin(
       \luastring{<\zref@extract{ekd:\theekd@lab}{abspage}>},
       "no")}%
-    \luadirect{ekdosis.appin(\luastringN{#1}, "no")}%
+    \luadirect{ekdosis.appin(\luastringO{#1}, "no")}%
     \luadirect{ekdosis.appin(
       \luastring{</\zref@extract{ekd:\theekd@lab}{abspage}>},
       "yes")}%
@@ -518,6 +518,7 @@ idno={}, msName={}, origDate={}][3]{%
 \define@cmdkey[ekd]{lem}[ekdl@]{sep}{}
 \presetkeys[ekd]{lem}{sep=\ekdsep}{}
 \define@boolkeys[ekd]{lem}[ekdl@]{nolem, nosep}[true]
+\define@boolkeys[ekd]{rdg}[ekdr@]{nordg}[true]
 \NewDocumentCommand{\lem}{O{} m}{%
   #2%
   \bgroup%
@@ -534,7 +535,7 @@ idno={}, msName={}, origDate={}][3]{%
       \else
         \ifdefined\ekdlr@post%
           \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
-        {\textdir TRT#2}%
+        {\textdir TRT\unexpanded{#2}}%
         \ifdefined\ekdlr@pre%
           \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
       \fi
@@ -561,7 +562,7 @@ idno={}, msName={}, origDate={}][3]{%
         \ifdefined\ekdlr@pre%
           \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
           \ltx@ifpackageloaded{babel}%
-            {{\noexpand\selectlanguage{\languagename}#2}}{#2}%
+            {{\noexpand\selectlanguage{\languagename}\unexpanded{#2}}}{#2}%
         \ifdefined\ekdlr@post%
           \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
       \fi
@@ -577,6 +578,62 @@ idno={}, msName={}, origDate={}][3]{%
   \fi%
   \egroup%
 }
+\NewDocumentCommand{\rdg}{O{} m}{%
+  \bgroup%
+  \setkeys[ekd]{lemrdg,rdg}{#1}%
+  \ifekdr@nordg\append@app{}\else%
+  \ifbool{al@rlmode}{%
+    \edef\rdg@app{%
+      \ifdefined\ekdlr@alt
+        \ifdefined\ekdlr@post%
+          \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
+        {\textdir TRT\unexpanded\expandafter{\ekdlr@alt}}
+        \ifdefined\ekdlr@pre%
+          \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
+      \else
+        \ifdefined\ekdlr@post%
+          \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
+        {\textdir TRT\unexpanded{#2}}%
+        \ifdefined\ekdlr@pre%
+          \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
+      \fi
+      \ifdefined\ekdlr@postwit%
+        \space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
+      \ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
+      \ifdefined\ekdlr@prewit%
+        \space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
+    }%
+  }%
+  {%
+    \edef\rdg@app{%
+      \ifdefined\ekdlr@alt
+        \ifdefined\ekdlr@pre%
+          \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
+        \ltx@ifpackageloaded{babel}%
+          {{\noexpand\selectlanguage{\languagename}%
+            \unexpanded\expandafter{\ekdlr@alt}}}%
+          {\unexpanded\expandafter{\ekdlr@alt}}
+        \ifdefined\ekdlr@post%
+          \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
+      \else
+        \ifdefined\ekdlr@pre%
+          \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
+          \ltx@ifpackageloaded{babel}%
+            {{\noexpand\selectlanguage{\languagename}\unexpanded{#2}}}{#2}%
+        \ifdefined\ekdlr@post%
+          \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
+      \fi
+      \ifdefined\ekdlr@prewit%
+        \space\unexpanded\expandafter{\ekdlr@prewit}\space\else\fi
+      \ifdefined\ekdlr@wit\space\getsiglum{\ekdlr@wit}\else\fi
+      \ifdefined\ekdlr@postwit%
+        \space\unexpanded\expandafter{\ekdlr@postwit}\else\fi
+    }%
+  }%
+  \append@app{\rdg@app}%
+  \fi%
+  \egroup%
+}
 \newkeycommand+[\|]{\lemout}[wit, alt, pre, post, prewit, postwit,
 sep={\ekdsep}, choice nosep={false,,true},
 choice nolem={false,,true}][1]{%
@@ -628,7 +685,7 @@ choice nolem={false,,true}][1]{%
       |\fi|%
     }}%
   |\fi|}
-\newkeycommand+[\|]{\rdg}[wit, alt, pre, post, prewit, postwit,
+\newkeycommand+[\|]{\rdgout}[wit, alt, pre, post, prewit, postwit,
 choice nordg={false,,true}][1]{%
   |\ifnum|%
   \commandkey{nordg}>0%
-- 
cgit v1.2.3

