From 8564f1723d5e0700930f6c3c33426fc83d5f405f Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Mon, 30 Sep 2019 14:43:47 +0200
Subject: make \note compatible with arabluatex

---
 ekdosis.dtx | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index 7d757b7..ab3afbb 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -654,8 +654,8 @@ idno={}, msName={}, origDate={}][3]{%
         \ifdefined\ekdlr@pre%
           \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
         \ltx@ifpackageloaded{babel}%
-          {{\noexpand\selectlanguage{\languagename}%
-            \unexpanded\expandafter{\ekdlr@alt}}}%
+          {\noexpand\selectlanguage{\languagename}%
+            \unexpanded\expandafter{\ekdlr@alt}}%
           {\unexpanded\expandafter{\ekdlr@alt}}
         \ifdefined\ekdlr@post%
           \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
@@ -663,7 +663,7 @@ idno={}, msName={}, origDate={}][3]{%
         \ifdefined\ekdlr@pre%
           \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
           \ltx@ifpackageloaded{babel}%
-          {{\noexpand\selectlanguage{\languagename}\unexpanded{#2}}}{%
+          {\noexpand\selectlanguage{\languagename}\unexpanded{#2}}{%
             \unexpanded{#2}}%
         \ifdefined\ekdlr@post%
           \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
@@ -727,8 +727,8 @@ idno={}, msName={}, origDate={}][3]{%
         \ifdefined\ekdlr@pre%
           \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
         \ltx@ifpackageloaded{babel}%
-          {{\noexpand\selectlanguage{\languagename}%
-            \unexpanded\expandafter{\ekdlr@alt}}}%
+          {\noexpand\selectlanguage{\languagename}%
+            \unexpanded\expandafter{\ekdlr@alt}}%
           {\unexpanded\expandafter{\ekdlr@alt}}
         \ifdefined\ekdlr@post%
           \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
@@ -736,7 +736,7 @@ idno={}, msName={}, origDate={}][3]{%
         \ifdefined\ekdlr@pre%
           \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
           \ltx@ifpackageloaded{babel}%
-          {{\noexpand\selectlanguage{\languagename}\unexpanded{#2}}}{%
+          {\noexpand\selectlanguage{\languagename}\unexpanded{#2}}{%
             \unexpanded{#2}}%
         \ifdefined\ekdlr@post%
           \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
@@ -782,20 +782,30 @@ idno={}, msName={}, origDate={}][3]{%
   \ifdefined\ekdn@labelb%
     \luadirect{tex.sprint(ekdosis.setnotelab(\luastringO{\ekdn@labelb}))}%
     \ifdefined\ekdn@labele\else\def\ekdn@labele{\ekdn@labelb}\fi%
-  \else\PackageError{ekdosis}{missing labelb}{`labelb' must be set.}\fi%
-  \edef\note@contents{%
+  \else\PackageError{ekdosis}{missing labelb}{`labelb' must be
+    set.}\fi%
+  \ifbool{al@rlmode}%
+  {\edef\note@contents{%
+    \hskip .75em\ifsubsq@unit%
+    \unexpanded\expandafter{\ekd@unit@delim}\else\fi%
+    \current@ref@arg{\ekdn@labelb}{\ekdn@labele}\hskip .25em%
+      \ifdefined\ekdn@lem%
+          {\textdir TRT\unexpanded\expandafter{\ekdn@lem}}%
+          \unexpanded\expandafter{\ekdn@sep}\else\fi%
+            {\textdir TRT\unexpanded{#2}}}}%
+  {\edef\note@contents{%
     \hskip .75em\ifsubsq@unit%
     \unexpanded\expandafter{\ekd@unit@delim}\else\fi%
     \current@ref@arg{\ekdn@labelb}{\ekdn@labele}\hskip .25em%
       \ifdefined\ekdn@lem
         \ltx@ifpackageloaded{babel}%
-          {{\noexpand\selectlanguage{\languagename}%
-            \unexpanded\expandafter{\ekdn@lem}}}%
+          {\noexpand\selectlanguage{\languagename}%
+            \unexpanded\expandafter{\ekdn@lem}}%
           {\unexpanded\expandafter{\ekdn@lem}}%
           \unexpanded\expandafter{\ekdn@sep}\else\fi%
           \ltx@ifpackageloaded{babel}%
-          {{\noexpand\selectlanguage{\languagename}\unexpanded{#2}}}{%
-            \unexpanded{#2}}}%
+          {\noexpand\selectlanguage{\languagename}\unexpanded{#2}}{%
+            \unexpanded{#2}}}}%
   \ifekd@mapps%
   \unconditional@appin[\ekdan@type]{\note@contents}%
   \else%
-- 
cgit v1.2.3

