From e7d0200bbbd6f291fc2a4a2e60c148fdbfb4ebf9 Mon Sep 17 00:00:00 2001
From: Robert Alessi <alessi@robertalessi.net>
Date: Thu, 27 Oct 2022 16:41:35 +0200
Subject: included maxlines in ekdverse environment

---
 ekdosis.dtx | 13 +++++++++++++
 1 file changed, 13 insertions(+)

(limited to 'ekdosis.dtx')

diff --git a/ekdosis.dtx b/ekdosis.dtx
index 3212acb..aa85fc2 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -11157,6 +11157,19 @@ Sample text with a \textcolor{red}{word} in red.
 % \env{ekdverse} is defined:---
 %    \begin{macrocode}
 \if@pkg@poetry@verse
+\AddToHook{cmd/@vscentercr/before}{%
+  \ifdefined\maxlines@value
+    \stepcounter{ekd@lnperpage}%
+    \ifnum\value{ekd@locallnperpage} = 1
+      \ifnumcomp{\theekd@lnperpage}{=}{%
+          \luadirect{tex.sprint(ekdosis.getlocalmaxlines())}}{%
+          \setcounter{ekd@locallnperpage}{0}%
+          \setcounter{ekd@lnperpage}{0}\pagebreak}{}%
+      \else
+        \ifnumcomp{\theekd@lnperpage}{=}{\maxlines@value}{%
+            \setcounter{ekd@lnperpage}{0}\pagebreak}{}%
+        \fi
+      \fi}
 \patchcmd{\start@vsline}{%
   \ifaltindent}{%
   \ifekd@pagevlineation\test@vpnum\fi
-- 
cgit v1.2.3

