From 28beeb84d780edd5fe55b49eeeb14a502f0721e1 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Mon, 12 Oct 2020 12:34:36 +0200 Subject: new global option 'verse' --- ekdosis.dtx | 81 ++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 20 deletions(-) diff --git a/ekdosis.dtx b/ekdosis.dtx index d3e2bd5..811b4f2 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -360,7 +360,7 @@ along with this program. If not, see \def\sg#1{\textancientgreek{#1}} \usepackage[Old Standard]{mathfont} \usepackage{arabluatex} -\usepackage[parnotes=roman,teiexport=tidy]{ekdosis} +\usepackage[parnotes=roman,teiexport=tidy,verse]{ekdosis} \input{ekdosis-cfg} \AddxmlBibResource{bibdata.xml} \usepackage{booktabs} @@ -5022,7 +5022,7 @@ Sample text with a \textcolor{red}{word} in red. \lem[source=Drak, type=emendation]{ne morem} \rdg[wit={L, F}]{me morem} \rdg[wit={O, V}]{memorem} - } et pugnae signum exspectate petendae: + } et pugnae signum exspectate petendae:\\ \end{ekdverse} \end{ekdosis} \end{minted} @@ -5035,8 +5035,8 @@ Sample text with a \textcolor{red}{word} in red. % % \needspace{7\baselineskip} % \begin{alignment}[flush,tcols=1,texts=specimen,apparatus=specimen] -% \resetlinenumber[30]\rightlinenumbers -% \setlength{\linenumbersep}{-1.5in} +% \setverselinenums{30}{0} +% \setlength{\vrightskip}{-1.5in} % \begin{specimen} % \begin{ekdverse} % Sed uos, quorum oculos atque ora humentia uidi,\\ @@ -5045,7 +5045,7 @@ Sample text with a \textcolor{red}{word} in red. % \lem[source=sDrak, type=emendation]{ne morem} % \rdg[wit={sL, sF}]{me morem} % \rdg[wit={sO, sV}]{memorem} -% } et pugnae signum exspectate petendae: +% } et pugnae signum exspectate petendae:\\ % \end{ekdverse} % \end{specimen} % \end{alignment} @@ -5956,7 +5956,8 @@ Sample text with a \textcolor{red}{word} in red. \AtBeginDocument{\luadirect{ekdosis.setekddivsfalse()}}}}, initial divs = ekdosis, unknown-choice divs = \PackageError{ekdosis}{unknown divs=#1}{`divs' - must be either `ekdosis' or `latex'.}, + must be either `ekdosis' or `latex'.}, + bool verse = \if@pkg@verse, choice parnotes = {false = {}, true = {\@pkg@parnotestrue}, roman = {\@pkg@parnotestrue\@parnotesromantrue}}, @@ -5996,6 +5997,9 @@ Sample text with a \textcolor{red}{word} in red. \RequirePackage{ltxcmds} \RequirePackage{pdftexcmds} \RequirePackage{ifoddpage} +\if@pkg@verse + \RequirePackage{verse} +\fi \if@pkg@parnotes \RequirePackage{parnotes} \fi @@ -6669,6 +6673,9 @@ Sample text with a \textcolor{red}{word} in red. lineation=#1}{`lineation' must be either `page' or `document'.}, code modulonum = \chardef\c@linenumbermodulo#1\relax, noval modulo = \modulolinenumbers, + code vmodulonum = \if@pkg@verse\poemlines{#1}\fi, + initial vmodulonum = 1, + noval vmodulo = \if@pkg@verse\poemlines{5}\fi, choice numbers = {elided = \ekd@elidednumberstrue, full = \ekd@elidednumbersfalse}, unknown-choice numbers = \PackageError{ekdosis}{unknown @@ -7636,21 +7643,51 @@ Sample text with a \textcolor{red}{word} in red. } % \end{macrocode} % \end{macro} -% A very basic and provisional implementation of poetry lines -% follows:--- +% If \pkg{ekdosis} be loaded with the |verse| global option, the +% \env{verse} environment needs to be redefined so that lines of +% poetry are numbered continuously. Additionally, +% \cs{verselinenumfont} is initially set to +% \cs{normalfont}\cs{footnotesize}. % \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}} +\if@pkg@verse +\verselinenumfont{\normalfont\footnotesize} +\setcounter{poemline}{1} +\renewenvironment{verse}[1][\linewidth]{% + \stepcounter{verse@envctr}% + \setcounter{vslineno}{1}% + \let\\=\@vscentercr + \list{}{\itemsep \z@ + \itemindent -\vindent% + \listparindent\itemindent + \parsep \stanzaskip + \ifdim #1 < \linewidth + \rightmargin \z@ + \setlength{\leftmargin}{\linewidth}% + \addtolength{\leftmargin}{-#1}% + \addtolength{\leftmargin}{-0.5\leftmargin}% + \else + \rightmargin \leftmargin + \fi + \addtolength{\leftmargin}{\vindent}}% +\item[]% +}{\endlist} +\fi % \end{macrocode} +% \begin{environment}{ekdverse} +% \env{ekdverse} provides an implementation of poetry lines. It is +% set to use either the \pkg{lineno} or the \pkg{verse} package +% depending on the value that is passed to the global option +% |verse|:--- +% \begin{macrocode} +\NewDocumentEnvironment{ekdverse}{}{% + \if@pkg@verse + \nolinenumbers + \let\linelabel\label + \fi + \begin{verse}} + {\end{verse}} +% \end{macrocode} +% \end{environment} % \begin{environment}{ekdpar} % When |autopar| is set to |false| by means of \cs{SetTEIxmlExport}, % \env{ekdpar}\---or any other environment set to be inserted within @@ -8049,6 +8086,10 @@ local cmdtotags = { local texpatttotags = { {a="\\addentries%s+%[(.-)%]{(.-)}", b=""}, {a="\\addentries%s+{(.-)}", b=""}, + {a="\\setverselinenums%s+{(.-)}{(.-)}", b=""}, + {a="\\resetlinenumber%s+%[(.-)%]", b=""}, + {a="\\resetlinenumber%s+", b=""}, + {a="\\poemlines%s+{(.-)}", b=""}, {a="\\pagebreak%s+%[[1-4]%]", b=""}, {a="\\pagebreak%s+", b=""}, {a="\\altrfont%s+", b=""}, @@ -8278,7 +8319,7 @@ end local function linestotei(str) -- str = "\n"..str - str = string.gsub(str, "^%s?(.-)%s?$", "\n%1\n") + str = string.gsub(str, "^%s?(.-)\\\\%!?%s?$", "\n%1\n") -- str = gsub(str, endpoem, "\n") str = gsub(str, poemline * spcenc^-1 * lpeg.P(">"), "\n") str = gsub(str, poemline * spcenc^-1, "\n") -- cgit v1.2.3