aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2020-07-19 12:23:57 +0200
committerRobert Alessi <alessi@robertalessi.net>2020-07-19 12:23:57 +0200
commit34786688b350598f9da6641a1a45d9d747c17536 (patch)
treeae137460b9ef8bb85fdf1d60984bce0bef9f9545
parent274d02e351ad12de5c685dca4f235ec2da5c5a83 (diff)
downloadekdosis-34786688b350598f9da6641a1a45d9d747c17536.tar.gz
added \null at the beginning of \lem and \note. elide digits of end-range line numbers
-rw-r--r--ekdosis.dtx93
1 files changed, 87 insertions, 6 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 2cc2ead..f2bae26 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -1757,8 +1757,39 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+
1757% \section{Laying Out the Apparatus Criticus } 1757% \section{Laying Out the Apparatus Criticus }
1758% \label{sec:apparatus-layout} 1758% \label{sec:apparatus-layout}
1759% Single-layer apparatus criticus can be laid out in a variety of 1759% Single-layer apparatus criticus can be laid out in a variety of
1760% ways. 1760% ways with the following specialized commands, all of which can be
1761% used in the preamble or at any point of the document.
1761% 1762%
1763% \DescribeMacro{\SetLTRapp}
1764% \DescribeMacro{\SetRTLapp}
1765% \cs{SetLTRapp} and \cs{SetRTLapp} are two argument-less commands to
1766% set the direction of the apparatus criticus, either left-to-right or
1767% right-to-left.
1768%
1769% \DescribeMacro{\SetSeparator} \cs{SetSeparator}\marg{separator} is
1770% used to change the separator between lemma texts and variants
1771% readings. By default, the separator is a closing square bracket
1772% followed by a space (\verb*+] +).
1773%
1774% \DescribeMacro{\SetBeginApparatus}
1775% \cs{SetBeginApparatus}\marg{characters/commands} can be used to
1776% append \meta{characters} or \meta{commands} at the beginning of the
1777% apparatus block. By default, nothing is appended. For instance,
1778% \mintinline{latex}|\SetBeginApparatus{\textbf{Apparatus:}}| will
1779% append \enquote{\textbf{Apparatus:}} at the beginning of the
1780% apparatus block, while %
1781% \mintinline{latex}|\SetBeginApparatus{\hskip 1em}| will set an
1782% indentation of one em.
1783%
1784% \DescribeMacro{\SetEndApparatus}
1785% \cs{SetEndApparatus}\marg{characters} can be used to append
1786% \meta{characters} at the end of the apparatus block. By default,
1787% nothing is appended. As an example of use,
1788% \mintinline{latex}|\SetEndApparatus{.}| will have a period printed
1789% at the end of the apparatus as it is customary in some editions.
1790%
1791% \DescribeMacro{\SetUnitDelimiter}
1792% \cs{SetUnitDelimiter}
1762% 1793%
1763% \section{To Be Continued...} 1794% \section{To Be Continued...}
1764% v1.0 of \pkg{ekdosis}, which should be available by the end of July 1795% v1.0 of \pkg{ekdosis}, which should be available by the end of July
@@ -2780,7 +2811,7 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+
2780% \end{macro} 2811% \end{macro}
2781% \begin{macro}{\SetEndApparatus} 2812% \begin{macro}{\SetEndApparatus}
2782% \cs{SetEndApparatus}\marg{characters} can be used to append 2813% \cs{SetEndApparatus}\marg{characters} can be used to append
2783% characters at the end of the apparatus block\---such as a full stop, 2814% characters at the end of the apparatus block\---such as a period,
2784% as it is customary in some editions. By default, nothing is 2815% as it is customary in some editions. By default, nothing is
2785% appended:--- 2816% appended:---
2786% \begin{macrocode} 2817% \begin{macrocode}
@@ -2998,8 +3029,10 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+
2998 \fi 3029 \fi
2999 % 3030 %
3000 \else 3031 \else
3001 \LRnum{\getrefnumber{#1}}--% 3032 \luadirect{tex.sprint(ekdosis.numrange(\luastring{\getrefnumber{#1}},
3002 \LRnum{\getrefnumber{#2}}% issue the nos 3033 \luastring{\getrefnumber{#2}}))}
3034 % \LRnum{\getrefnumber{#1}}--%
3035 % \LRnum{\getrefnumber{#2}}% issue the nos
3003 \fi% 3036 \fi%
3004 \else 3037 \else
3005 \LRnum{\getrefnumber{#1}}--% 3038 \LRnum{\getrefnumber{#1}}--%
@@ -3051,8 +3084,11 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+
3051 \fi 3084 \fi
3052 % 3085 %
3053 \else 3086 \else
3054 \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--% 3087 \luadirect{tex.sprint(ekdosis.numrange(
3055 \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}% issue the nos 3088 \luastring{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}},
3089 \luastring{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}))}% issue the nos
3090 % \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--%
3091 % \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}}% issue the nos
3056 \fi% 3092 \fi%
3057 \else 3093 \else
3058 \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--% 3094 \LRnum{\getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}}--%
@@ -3099,6 +3135,7 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+
3099\NewDocumentCommand{\lem}{O{} m}{% 3135\NewDocumentCommand{\lem}{O{} m}{%
3100 \ekd@isinlemtrue% 3136 \ekd@isinlemtrue%
3101 \luadirect{ekdosis.dolnlab(\luastringN{#2})}% 3137 \luadirect{ekdosis.dolnlab(\luastringN{#2})}%
3138 \null
3102 \bgroup% 3139 \bgroup%
3103 \ekvset{lem}{#1}% 3140 \ekvset{lem}{#1}%
3104 \ifekd@mapps% 3141 \ifekd@mapps%
@@ -3300,6 +3337,7 @@ texts=latin[xml:lang="la"]+\textcolor{red}{;}+
3300% specified; otherwise \pkg{ekdosis} will issue an error message. 3337% specified; otherwise \pkg{ekdosis} will issue an error message.
3301% \begin{macrocode} 3338% \begin{macrocode}
3302\NewDocumentCommand{\note@noapp}{O{} +m}{% 3339\NewDocumentCommand{\note@noapp}{O{} +m}{%
3340 \null
3303 \bgroup% 3341 \bgroup%
3304 \ekvset{note}{#1}% 3342 \ekvset{note}{#1}%
3305 \stepcounter{ekd@lab}% 3343 \stepcounter{ekd@lab}%
@@ -5360,6 +5398,49 @@ function ekdosis.testapparatus()
5360 end 5398 end
5361end 5399end
5362 5400
5401local function get_ln_prefix(x, y)
5402 for index = 1, string.len(x)
5403 do
5404 if string.sub(x, index, index) ~= string.sub(y, index, index)
5405 then
5406 return string.sub(x, 1, index - 1)
5407 end
5408 end
5409end
5410
5411function ekdosis.numrange(x, y)
5412 xstr = tostring(x)
5413 ystr = tostring(y)
5414 if x == y -- which will never apply
5415 then
5416 return "\\LRnum{" .. xstr .. "}"
5417 elseif string.len(xstr) ~= string.len(ystr)
5418 then
5419 return "\\LRnum{" .. xstr .. "}--\\LRnum{" .. ystr .. "}"
5420 else
5421 common = get_ln_prefix(xstr, ystr)
5422 if string.len(common) == 0
5423 then
5424 return "\\LRnum{" .. xstr .. "}--\\LRnum{" .. ystr .. "}"
5425 elseif string.sub(xstr, -2, -2) == "1"
5426 then
5427 return "\\LRnum{"
5428 .. string.sub(common, 1, -2)
5429 .. string.sub(xstr, string.len(common), -1)
5430 .. "}--\\LRnum{"
5431 .. string.sub(ystr, string.len(common), -1)
5432 .. "}"
5433 else
5434 return "\\LRnum{"
5435 .. string.sub(common, 1, -1)
5436 .. string.sub(xstr, string.len(common) + 1, -1)
5437 .. "}--\\LRnum{"
5438 .. string.sub(ystr, string.len(common) + 1, -1)
5439 .. "}"
5440 end
5441 end
5442end
5443
5363local lnlabs = {} 5444local lnlabs = {}
5364local lnlab_salt = 0 5445local lnlab_salt = 0
5365local current_lnlab = nil 5446local current_lnlab = nil