From 0d6bc09305d8139778e9bbf95910e614ee66bb99 Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Fri, 25 Oct 2019 08:50:17 +0200
Subject: first implementation of ekdverse environment

---
 ekdosis.dtx | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index 5ee1169..fd99891 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -1018,6 +1018,21 @@ idno={}, msName={}, origDate={}][3]{%
   \end{linenumbers}%
   \iftei@export\luadirect{ekdosis.exporttei(\luastringN{#1})}\else\fi}
 %    \end{macrocode}
+% Very basic implementation of poetry lines:---
+%    \begin{macrocode}
+\newlength{\ekdverseindentlength}
+\setlength{\ekdverseindentlength}{\parindent}
+\newenvironment*{ekdverse}[1][\ekdverseindentlength]{
+  \begin{list}{}{%
+      \setlength{\leftmargin}{#1}
+      \setlength{\itemsep}{0pt}
+      \setlength{\topsep}{0pt}
+      \setlength{\partopsep}{0pt}
+    }
+  \item[]
+  }{\end{list}}
+%    \end{macrocode}
+% 
 % \iffalse
 %</package>
 % \fi
@@ -1267,6 +1282,7 @@ local cmdtotags = {
 }
 
 local envtotags = {
+   {a="ekdverse", b="lg", c=""},
    {a="txarabtr", b="p", c=" xml:lang=\"arb-Latn\" type=\"transliterated\""},
    {a="txarab", b="p", c=" xml:lang=\"arb\""},
    {a="center", b="p", c=" rend=\"centered\""},
@@ -1441,14 +1457,23 @@ end
 
 local function linestotei(str)
    str = "\n<l>"..str
-   str = gsub(str, endpoem, "</l>\n")
+--   str = gsub(str, endpoem, "</l>\n")
    str = gsub(str, poemline * lpeg.P("&gt;"), "\n<lb/>")
    str = gsub(str, poemline, "</l>\n<l>")
+   str = str.."</l>\n"
    return str
 end
 
 -- better use lpeg: look into this later
 local function versetotei(str)
+   str = string.gsub(str, "(\\begin%s?%{ekdverse%})(%b[])(.-)(\\end%s?%{ekdverse%})", function(benv, opt, arg, eenv)
+			arg = linestotei(arg)
+			return string.format("%s%s%s%s", benv, opt, arg, eenv)
+   end)
+   str = string.gsub(str, "(\\begin%s?%{ekdverse%})(.-)(\\end%s?%{ekdverse%})", function(benv, arg, eenv)
+			arg = linestotei(arg)
+			return string.format("%s%s%s", benv, arg, eenv)
+   end)
    str = string.gsub(str, "(\\begin%s?%{verse%})(%b[])(.-)(\\end%s?%{verse%})", function(benv, opt, arg, eenv)
 			arg = linestotei(arg)
 			return string.format("%s%s%s%s", benv, opt, arg, eenv)
-- 
cgit v1.2.3

