aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2025-04-02 15:43:06 +0200
committerRobert Alessi <alessi@robertalessi.net>2025-04-02 15:43:06 +0200
commitc31e7ec1496d22362c3da0d6fc8ef45622cf3cbc (patch)
treeb7e9fea1ebe4dc2864851f60d73e90a977cc4075
parente63c189f9c482ab0683b73d56bbea8bdc0e8d52d (diff)
downloadekdosis-c31e7ec1496d22362c3da0d6fc8ef45622cf3cbc.tar.gz
robustify for now close_ekd|ndivs_in_between()HEADmaster
-rw-r--r--ekdosis.dtx130
1 files changed, 104 insertions, 26 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index bc7eadf..730de36 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -59,7 +59,7 @@ Alessi <alessi@robertalessi.net>
59%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] 59%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
60%<package>\ProvidesPackage{ekdosis} 60%<package>\ProvidesPackage{ekdosis}
61%<*package> 61%<*package>
62 [2025/03/09 v1.5-dev Typesetting TEI xml-compliant critical editions] 62 [2025/04/02 v1.5-dev Typesetting TEI xml-compliant critical editions]
63%</package> 63%</package>
64%<*driver> 64%<*driver>
65\begin{filecontents}[noheader,overwrite]{bibdata.xml} 65\begin{filecontents}[noheader,overwrite]{bibdata.xml}
@@ -8520,7 +8520,7 @@ Sample text with a \textcolor{red}{word} in red.
8520% \end{macrocode} 8520% \end{macrocode}
8521% \paragraph{\textsf{ekdosis} Symbol} 8521% \paragraph{\textsf{ekdosis} Symbol}
8522% \begin{macro}{\eKd} 8522% \begin{macro}{\eKd}
8523% \changes{v1.5}{2025/03/09}{Prints \textsf{ekdosis} indentifying 8523% \changes{v1.5}{2025/04/02}{Prints \textsf{ekdosis} indentifying
8524% symbol} As of v1.5, \pkg{ekdosis} has its own identifying 8524% symbol} As of v1.5, \pkg{ekdosis} has its own identifying
8525% symbol. It is produced by \cs{eKd} and best printed with the Old 8525% symbol. It is produced by \cs{eKd} and best printed with the Old
8526% Standard Greek font. 8526% Standard Greek font.
@@ -8783,7 +8783,7 @@ Sample text with a \textcolor{red}{word} in red.
8783% \begin{macro}{\teidirectE} 8783% \begin{macro}{\teidirectE}
8784% \changes{v1.3}{2021/08/18}{direct insertion of elements in the 8784% \changes{v1.3}{2021/08/18}{direct insertion of elements in the
8785% \texttt{TEI xml} file} 8785% \texttt{TEI xml} file}
8786% \changes{v1.5}{2025/03/09}{direct insertion of empty elements in the 8786% \changes{v1.5}{2025/04/02}{direct insertion of empty elements in the
8787% \texttt{TEI xml} file} 8787% \texttt{TEI xml} file}
8788% \cs{teidirect}\oarg{xml attributes}\marg{xml element}\marg{code} 8788% \cs{teidirect}\oarg{xml attributes}\marg{xml element}\marg{code}
8789% does nothing in \LaTeX. It is only used to insert elements in the 8789% does nothing in \LaTeX. It is only used to insert elements in the
@@ -8798,7 +8798,7 @@ Sample text with a \textcolor{red}{word} in red.
8798% \end{macro} 8798% \end{macro}
8799% \end{macro} 8799% \end{macro}
8800% \begin{macro}{\getTEIxmlid} 8800% \begin{macro}{\getTEIxmlid}
8801% \changes{v1.5}{2025/03/09}{returns \texttt{TEI xml:ids} from a 8801% \changes{v1.5}{2025/04/02}{returns \texttt{TEI xml:ids} from a
8802% csv-list of ids} This command returns from a csv-list of unique 8802% csv-list of ids} This command returns from a csv-list of unique
8803% identifiers declared in commands such as \cs{DeclareWitness} and the 8803% identifiers declared in commands such as \cs{DeclareWitness} and the
8804% like a space-separated list of their corresponding |xml:id|s, each 8804% like a space-separated list of their corresponding |xml:id|s, each
@@ -9274,7 +9274,7 @@ Sample text with a \textcolor{red}{word} in red.
9274\newlength{\ekd@app@localheight} 9274\newlength{\ekd@app@localheight}
9275% \end{macrocode} 9275% \end{macrocode}
9276% \begin{macro}{\localappheight} 9276% \begin{macro}{\localappheight}
9277% \changes{v1.5}{2025/03/09}{changes the height of the apparatus 9277% \changes{v1.5}{2025/04/02}{changes the height of the apparatus
9278% criticus} 9278% criticus}
9279% \cs{localappheight}\marg{dimen} can be used to change locally the 9279% \cs{localappheight}\marg{dimen} can be used to change locally the
9280% length of \cs{ekd@app@height} set by the |appheight| option of 9280% length of \cs{ekd@app@height} set by the |appheight| option of
@@ -9293,7 +9293,7 @@ Sample text with a \textcolor{red}{word} in red.
9293% \end{macrocode} 9293% \end{macrocode}
9294% \end{macro} 9294% \end{macro}
9295% \begin{macro}{\addtoappheight} 9295% \begin{macro}{\addtoappheight}
9296% \changes{v1.5}{2025/03/09}{increases or decreases the height of the 9296% \changes{v1.5}{2025/04/02}{increases or decreases the height of the
9297% apparatus criticus} 9297% apparatus criticus}
9298% As the name suggests, in contrast to \cs{localappheight}, 9298% As the name suggests, in contrast to \cs{localappheight},
9299% \cs{addtoappheight}\marg{dimen} is used to increase or decrease 9299% \cs{addtoappheight}\marg{dimen} is used to increase or decrease
@@ -9582,7 +9582,7 @@ Sample text with a \textcolor{red}{word} in red.
9582% The following commands are provided to set and control the maximum 9582% The following commands are provided to set and control the maximum
9583% number of lines printed on each page. 9583% number of lines printed on each page.
9584% \begin{macro}{\setmaxlines} 9584% \begin{macro}{\setmaxlines}
9585% \changes{v1.5}{2025/03/09}{limits the number of lines per page} 9585% \changes{v1.5}{2025/04/02}{limits the number of lines per page}
9586% \cs{setmaxlines}\marg{n}, where \meta{n} is a positive integer 9586% \cs{setmaxlines}\marg{n}, where \meta{n} is a positive integer
9587% $\geq 1$, can be used either in the preamble or at any point of the 9587% $\geq 1$, can be used either in the preamble or at any point of the
9588% document to set the maximum number of lines to be printed on each 9588% document to set the maximum number of lines to be printed on each
@@ -9593,7 +9593,7 @@ Sample text with a \textcolor{red}{word} in red.
9593% \end{macrocode} 9593% \end{macrocode}
9594% \end{macro} 9594% \end{macro}
9595% \begin{macro}{\localmaxlines} 9595% \begin{macro}{\localmaxlines}
9596% \changes{v1.5}{2025/03/09}{changes the maximum number of lines 9596% \changes{v1.5}{2025/04/02}{changes the maximum number of lines
9597% locally} 9597% locally}
9598% Once a maximum number of lines per page has been set, 9598% Once a maximum number of lines per page has been set,
9599% \cs{localmaxlines}\marg{n} can be used to adjust this number on a 9599% \cs{localmaxlines}\marg{n} can be used to adjust this number on a
@@ -9606,7 +9606,7 @@ Sample text with a \textcolor{red}{word} in red.
9606% \end{macrocode} 9606% \end{macrocode}
9607% \end{macro} 9607% \end{macro}
9608% \begin{macro}{\addtomaxlines} 9608% \begin{macro}{\addtomaxlines}
9609% \changes{v1.5}{2025/03/09}{adds or subtracts lines from a given page} 9609% \changes{v1.5}{2025/04/02}{adds or subtracts lines from a given page}
9610% Unlike \cs{localmaxlines}, \cs{addtomaxlines}\meta{n} takes as 9610% Unlike \cs{localmaxlines}, \cs{addtomaxlines}\meta{n} takes as
9611% argument the number of lines one wishes to add or substract from the 9611% argument the number of lines one wishes to add or substract from the
9612% number that has been set by \cs{setmaxlines}. As a result, \meta{n} 9612% number that has been set by \cs{setmaxlines}. As a result, \meta{n}
@@ -9619,7 +9619,7 @@ Sample text with a \textcolor{red}{word} in red.
9619% \end{macrocode} 9619% \end{macrocode}
9620% \end{macro} 9620% \end{macro}
9621% \begin{macro}{\nomaxlines} 9621% \begin{macro}{\nomaxlines}
9622% \changes{v1.5}{2025/03/09}{unsets \cs{setmaxlines}} 9622% \changes{v1.5}{2025/04/02}{unsets \cs{setmaxlines}}
9623% \cs{nomaxlines} unsets any limit previously set by \cs{setmaxlines}. 9623% \cs{nomaxlines} unsets any limit previously set by \cs{setmaxlines}.
9624% \begin{macrocode} 9624% \begin{macrocode}
9625\def\nomaxlines{\luadirect{tex.sprint(ekdosis.resetlocalmaxlines())}} 9625\def\nomaxlines{\luadirect{tex.sprint(ekdosis.resetlocalmaxlines())}}
@@ -9683,7 +9683,7 @@ Sample text with a \textcolor{red}{word} in red.
9683% \end{macrocode} 9683% \end{macrocode}
9684% \end{macro} 9684% \end{macro}
9685% \begin{macro}{\App} 9685% \begin{macro}{\App}
9686% \changes{v1.5}{2025/03/09}{To be used conjointly with 9686% \changes{v1.5}{2025/04/02}{To be used conjointly with
9687% \texttt{ekdosis.el}} 9687% \texttt{ekdosis.el}}
9688% In contrast to \cs{app}, \cs{App} takes two mandatory arguments and 9688% In contrast to \cs{app}, \cs{App} takes two mandatory arguments and
9689% accepts one optional argument like so: 9689% accepts one optional argument like so:
@@ -10668,7 +10668,7 @@ Sample text with a \textcolor{red}{word} in red.
10668} 10668}
10669% \end{macrocode} 10669% \end{macrocode}
10670% \begin{macro}{\SetFootnotes} 10670% \begin{macro}{\SetFootnotes}
10671% \changes{v1.5}{2025/03/09}{footnotes combined into a single 10671% \changes{v1.5}{2025/04/02}{footnotes combined into a single
10672% paragraph} \cs{SetFootnotes}\marg{options} can be used in the 10672% paragraph} \cs{SetFootnotes}\marg{options} can be used in the
10673% preamble or at any point of the document. |layout=paragraph| 10673% preamble or at any point of the document. |layout=paragraph|
10674% instructs \pkg{ekdosis} to combine all footnotes into a single 10674% instructs \pkg{ekdosis} to combine all footnotes into a single
@@ -10899,7 +10899,7 @@ Sample text with a \textcolor{red}{word} in red.
10899% \end{macro} 10899% \end{macro}
10900% \paragraph{Lacunae} 10900% \paragraph{Lacunae}
10901% \begin{macro}{\ilabel} 10901% \begin{macro}{\ilabel}
10902% \changes{v1.5}{2025/03/09}{recalls and sets the ending label of 10902% \changes{v1.5}{2025/04/02}{recalls and sets the ending label of
10903% lemmas used to mark lacunae in witnesses} When \cs{lem} has been 10903% lemmas used to mark lacunae in witnesses} When \cs{lem} has been
10904% used with the optional argument |ilabel=<label>|, 10904% used with the optional argument |ilabel=<label>|,
10905% \cs{ilabel}\marg{label} must be used to mark the point where the 10905% \cs{ilabel}\marg{label} must be used to mark the point where the
@@ -11239,7 +11239,7 @@ Sample text with a \textcolor{red}{word} in red.
11239% \end{macrocode} 11239% \end{macrocode}
11240% \end{macro} 11240% \end{macro}
11241% \begin{macro}{\ekdEOprint} 11241% \begin{macro}{\ekdEOprint}
11242% \changes{v1.5}{2025/03/09}{Sets headers and footers on 11242% \changes{v1.5}{2025/04/02}{Sets headers and footers on
11243% \enquote{paired} facing pages} 11243% \enquote{paired} facing pages}
11244% To set headers and footers on \enquote{paired} facing pages, 11244% To set headers and footers on \enquote{paired} facing pages,
11245% \cs{ekdEOprint} accepts two mandatory, self-evident arguments, like 11245% \cs{ekdEOprint} accepts two mandatory, self-evident arguments, like
@@ -11279,7 +11279,7 @@ Sample text with a \textcolor{red}{word} in red.
11279% counter to set the value of the page numbers. This counter should be 11279% counter to set the value of the page numbers. This counter should be
11280% incremented every two pages. 11280% incremented every two pages.
11281% \begin{counter}{pairedpage} 11281% \begin{counter}{pairedpage}
11282% \changes{v1.5}{2025/03/09}{A counter incremented every two pages} 11282% \changes{v1.5}{2025/04/02}{A counter incremented every two pages}
11283% |pairedpage| is first set as a global counter:--- 11283% |pairedpage| is first set as a global counter:---
11284% \begin{macrocode} 11284% \begin{macrocode}
11285\newcounter{pairedpage} 11285\newcounter{pairedpage}
@@ -11287,19 +11287,19 @@ Sample text with a \textcolor{red}{word} in red.
11287% \end{macrocode} 11287% \end{macrocode}
11288% \end{counter} 11288% \end{counter}
11289% \begin{macro}{\setpairedpagenum} 11289% \begin{macro}{\setpairedpagenum}
11290% \changes{v1.5}{2025/03/09}{sets the same page number on paired 11290% \changes{v1.5}{2025/04/02}{sets the same page number on paired
11291% pages} \cs{setpairedpagenum}\marg{number} is used just ahead of 11291% pages} \cs{setpairedpagenum}\marg{number} is used just ahead of
11292% the alignment environment to set the number of the first left-hand 11292% the alignment environment to set the number of the first left-hand
11293% paired page. 11293% paired page.
11294% \begin{macro}{\setpairedpage} 11294% \begin{macro}{\setpairedpage}
11295% \changes{v1.5}{2025/03/09}{sets the page number of the first paired 11295% \changes{v1.5}{2025/04/02}{sets the page number of the first paired
11296% page} \cs{setpairedpage} is an argument-less command meant to be 11296% page} \cs{setpairedpage} is an argument-less command meant to be
11297% issued in commands used to set headers or footers before 11297% issued in commands used to set headers or footers before
11298% \cs{thepage}. This command has the counter |pairedpage| 11298% \cs{thepage}. This command has the counter |pairedpage|
11299% incremented on right-hand pages only, and sets |page| $\leftarrow$ 11299% incremented on right-hand pages only, and sets |page| $\leftarrow$
11300% |pairedpage| on every page. 11300% |pairedpage| on every page.
11301% \begin{macro}{\resetpagenumber} 11301% \begin{macro}{\resetpagenumber}
11302% \changes{v1.5}{2025/03/09}{resets normal running page numbers} 11302% \changes{v1.5}{2025/04/02}{resets normal running page numbers}
11303% \cs{resetpagenumber} must be used right out of \enquote{mirrored} 11303% \cs{resetpagenumber} must be used right out of \enquote{mirrored}
11304% paired pages alignment environments. This argument-less command 11304% paired pages alignment environments. This argument-less command
11305% corrects any numbering error on the page following the edition 11305% corrects any numbering error on the page following the edition
@@ -13101,6 +13101,7 @@ local function close_ndivs_at_end(str)
13101 end 13101 end
13102end 13102end
13103 13103
13104--[[ -- this needs to be looked into, maybe in favor of the fn below
13104local function close_ekddivs_in_between(str) 13105local function close_ekddivs_in_between(str)
13105 local maxdepth = 1 13106 local maxdepth = 1
13106 for i in string.gmatch(str, "<div.-[Dd]epth=\"(%d)\".->", "%1") 13107 for i in string.gmatch(str, "<div.-[Dd]epth=\"(%d)\".->", "%1")
@@ -13138,6 +13139,47 @@ local function close_ekddivs_in_between(str)
13138 end 13139 end
13139 return str 13140 return str
13140end 13141end
13142--]]
13143
13144---[[
13145local function close_ekddivs_in_between(str)
13146 local maxdepth = 1
13147 for i in string.gmatch(str, "<div.-[Dd]epth=\"(%d)\".->", "%1")
13148 do
13149 if tonumber(i) > tonumber(maxdepth)
13150 then
13151 maxdepth = i
13152 else
13153 end
13154 end
13155 for ndivi = 1, maxdepth
13156 do
13157 str = string.gsub(str, "(<div [^%>]-depth%=\")("..ndivi..")(\".->)(.-)(<div [^%>]-depth%=\")(%d)(\".->)",
13158 function(bdivi, ndivi, edivi, between, bdivii, ndivii, edivii)
13159 local firstdiv = tonumber(ndivi)
13160 local firstdivcnt = tonumber(ndivi)
13161 local lastdiv = tonumber(ndivii)
13162 local closedivs = ""
13163 if not string.find(between, "</div>")
13164 then
13165 if firstdiv >= lastdiv
13166 then
13167 while firstdivcnt >= lastdiv
13168 do
13169 closedivs = closedivs.."</div>"
13170 firstdivcnt = firstdivcnt - 1
13171 bdivi = string.gsub(bdivi, "depth", "Depth")
13172 end
13173 end
13174 end
13175 return string.format("%s%s%s%s%s%s%s%s",
13176 bdivi, ndivi, edivi, between,
13177 closedivs, bdivii, ndivii, edivii)
13178 end)
13179 end
13180 return str
13181end
13182--]]
13141 13183
13142local function clean_ekddivs(str) 13184local function clean_ekddivs(str)
13143 str = string.gsub(str, "(<div.-)(%s[Dd]epth%=\"%d\")(.->)", "%1%3") 13185 str = string.gsub(str, "(<div.-)(%s[Dd]epth%=\"%d\")(.->)", "%1%3")
@@ -13145,10 +13187,11 @@ local function clean_ekddivs(str)
13145 return str 13187 return str
13146end 13188end
13147 13189
13190---[[ -- this needs to be looked into maybe in favor of the fn that follows
13148local function close_ndivs_in_between(str) 13191local function close_ndivs_in_between(str)
13149 for ndivi = 1, 6 13192 for ndivi = 1, 6
13150 do 13193 do
13151 str = string.gsub(str, "(<[Dd]iv)("..ndivi..")(.->)(.-)(<div)([1-6])(.->)", 13194 str = string.gsub(str, "(<div)("..ndivi..")(.->)(.-)(<div)([1-6])(.->)",
13152 function(bdivi, ndivi, edivi, between, bdivii, ndivii, edivii) 13195 function(bdivi, ndivi, edivi, between, bdivii, ndivii, edivii)
13153 local firstdiv = ndivi 13196 local firstdiv = ndivi
13154 local lastdiv = ndivii 13197 local lastdiv = ndivii
@@ -13157,22 +13200,57 @@ local function close_ndivs_in_between(str)
13157 firstdivindex = tonumber(firstdivindex) 13200 firstdivindex = tonumber(firstdivindex)
13158 lastdivindex = tonumber(lastdivindex) 13201 lastdivindex = tonumber(lastdivindex)
13159 local closedivs = "" 13202 local closedivs = ""
13160 if firstdivindex >= lastdivindex 13203 if not string.find(between, "</div[1-6]>")
13161 then 13204 then
13162 while firstdivindex >= lastdivindex 13205 if firstdivindex >= lastdivindex
13163 do 13206 then
13164 closedivs = closedivs.."</div"..used_ndivs[firstdivindex].a..">" 13207 while firstdivindex >= lastdivindex
13165 firstdivindex = firstdivindex - 1 13208 do
13166 bdivii = string.gsub(bdivii, "div", "Div") 13209 closedivs = closedivs.."</div"..used_ndivs[firstdivindex].a..">"
13210 firstdivindex = firstdivindex - 1
13211 bdivi = string.gsub(bdivi, "div", "Div")
13212 end
13167 end 13213 end
13168 end 13214 end
13169 return string.format("%s%s%s%s%s%s%s%s", 13215 return string.format("%s%s%s%s%s%s%s%s",
13170 bdivi, ndivi, edivi, between, 13216 bdivi, ndivi, edivi, between,
13171 closedivs, bdivii, ndivii, edivii) 13217 closedivs, bdivii, ndivii, edivii)
13172 end) 13218 end)
13173 end 13219 end
13174 return str 13220 return str
13175end 13221end
13222--]]
13223
13224--[[
13225local function close_ndivs_in_between(str)
13226 for ndivi = 1, 6
13227 do
13228 str = string.gsub(str, "(<div)("..ndivi..")(.->)(.-)(<div)([1-6])(.->)",
13229 function(bdivi, ndivi, edivi, between, bdivii, ndivii, edivii)
13230 local firstdiv = tonumber(ndivi)
13231 local firstdivcnt = tonumber(ndivi)
13232 local lastdiv = tonumber(ndivii)
13233 local closedivs = ""
13234 if not string.find(between, "</div[1-6]>")
13235 then
13236 if firstdiv >= lastdiv
13237 then
13238 while firstdivcnt >= lastdiv
13239 do
13240 closedivs = closedivs.."</div"..firstdiv..">"
13241 firstdivcnt = firstdivcnt - 1
13242 bdivi = string.gsub(bdivi, "div", "Div")
13243 end
13244 end
13245 end
13246 return string.format("%s%s%s%s%s%s%s%s",
13247 bdivi, ndivi, edivi, between,
13248 closedivs, bdivii, ndivii, edivii)
13249 end)
13250 end
13251 return str
13252end
13253--]]
13176 13254
13177local function clean_latexdivs(str) 13255local function clean_latexdivs(str)
13178 str = string.gsub(str, "(<Div)([1-6])(.->)", "<div%2%3") 13256 str = string.gsub(str, "(<Div)([1-6])(.->)", "<div%2%3")