From bff091028c07c16c80bcb7f6d8330dea0844d707 Mon Sep 17 00:00:00 2001 From: Robert Alessi Date: Tue, 3 Sep 2019 19:43:48 +0200 Subject: \lem now inserts begin/end line numbers. added unit delimiter and end-of-apparatus hook --- ekdosis.dtx | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 89 insertions(+), 13 deletions(-) (limited to 'ekdosis.dtx') diff --git a/ekdosis.dtx b/ekdosis.dtx index 590456c..63663be 100644 --- a/ekdosis.dtx +++ b/ekdosis.dtx @@ -358,7 +358,7 @@ Running "make install" installs the files in the local TeX tree. \RequirePackage{lineno} \RequirePackage{keyfloat} \RequirePackage{refcount} -\RequirePackage{xspace} +%\RequirePackage{xspace} \RequirePackage[user,abspage]{zref} \RequirePackage{ltxcmds} \if@pkg@parnotes @@ -472,6 +472,14 @@ idno={}, msName={}, origDate={}][3]{% \newif\ifrtl@app \NewDocumentCommand{\SetRTLapp}{}{\rtl@apptrue} \NewDocumentCommand{\SetLTRapp}{}{\rtl@appfalse} +\edef\ekdsep{: } +\NewDocumentCommand{\SetSeparator}{m}{\edef\ekdsep{#1}} +\edef\ekd@end@apparatus{} +\NewDocumentCommand{\SetEndApparatus}{m}{\edef\ekd@end@apparatus{#1}} +\def\ekd@unit@delim{} +\NewDocumentCommand{\SetUnitDelimiter}{m}{\def\ekd@unit@delim{#1}} +\newif\ifsubsq@unit +\subsq@unittrue \def\add@@apparatus{% % \blfootnote{\apparatus}% \if@pkg@parnotes\parnotes\else\fi% @@ -480,16 +488,16 @@ idno={}, msName={}, origDate={}][3]{% \if@parnotesroman% \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi% \parnoteclear\else\fi% - \footnotesize\apparatus% + \footnotesize\apparatus\ekd@end@apparatus% \if@pkg@parnotes\parnotes\parnotereset\else\fi% }% \unconditional@appin{\rule{5cm}{0.5pt}\newline} } \def\add@apparatus{% - \notbool{ekd@started}{\add@@apparatus% + \notbool{ekd@started}{\subsq@unitfalse\add@@apparatus% \global\setbool{ekd@started}{true}} {\test@apparatus% - \ifbool{do@app}{\add@@apparatus}{}}% + \ifbool{do@app}{\subsq@unitfalse\add@@apparatus}{}}% } \NewDocumentCommand{\append@app}{+m}{% \ifekd@isinapp% @@ -514,8 +522,17 @@ idno={}, msName={}, origDate={}][3]{% \ifbool{ekd@state}{\add@apparatus}{}% \luadirect{tex.sprint(ekdosis.removesp(\luastringN{#1}))}% \ekd@isinappfalse} -\edef\ekdsep{: } -\NewDocumentCommand{\SetSeparator}{m}{\edef\ekdsep{#1}} +\def\current@ref{{\textdir TLT\noexpand\bfseries% + \ifnum% + \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b} + = + \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e} + \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}% + \else + \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}--% + \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}% + \fi} + }% \define@cmdkeys[ekd]{lemrdg}[ekdlr@]{wit, alt, pre, post, prewit, postwit} \define@cmdkey[ekd]{lem}[ekdl@]{sep}{} @@ -523,12 +540,21 @@ idno={}, msName={}, origDate={}][3]{% \define@boolkeys[ekd]{lem}[ekdl@]{nolem, nosep}[true] \define@boolkeys[ekd]{rdg}[ekdr@]{nordg}[true] \NewDocumentCommand{\lem}{O{} m}{% - #2% + \luadirect{ekdosis.dolnlab(\luastringN{#2})}% + % \linelabel{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}% + % #2% + % \linelabel{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}% \bgroup% \setkeys[ekd]{lemrdg,lem}{#1}% - \ifekdl@nolem\append@ln@app{}\else% + \ifekdl@nolem\edef\lem@app{% + \hskip .75em\ifsubsq@unit% + \unexpanded\expandafter{\ekd@unit@delim}\else\fi% + \current@ref\hskip .25em}\else% \ifbool{al@rlmode}{% \edef\lem@app{% + \hskip .75em\ifsubsq@unit% + \unexpanded\expandafter{\ekd@unit@delim}\else\fi% + \current@ref\hskip .25em \ifdefined\ekdlr@alt \ifdefined\ekdlr@post% \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi @@ -552,6 +578,9 @@ idno={}, msName={}, origDate={}][3]{% }% {% \edef\lem@app{% + \hskip .75em\ifsubsq@unit% + \unexpanded\expandafter{\ekd@unit@delim}\else\fi% + \current@ref\hskip .25em \ifdefined\ekdlr@alt \ifdefined\ekdlr@pre% \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi @@ -577,9 +606,10 @@ idno={}, msName={}, origDate={}][3]{% \ifekdl@nosep\else\unexpanded\expandafter{\ekdl@sep}\fi }% }% - \append@ln@app{\lem@app}% \fi% + \append@ln@app{\lem@app}% \egroup% + \subsq@unittrue% } \NewDocumentCommand{\rdg}{O{} m}{% \bgroup% @@ -958,7 +988,7 @@ function ekdosis.newscholar(id, siglum) then tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] ..id.. - [[" already exists as a xml:id. ]] + [[" already exists as a xml:id. ]] .. [[Please pick another id.}}]]) else @@ -1036,7 +1066,7 @@ local close_p = { function ekdosis.newcmdtotag(cmd, tag, attr) if isintable(cmdtotags, cmd) then - tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] + tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] --`' ..cmd.. [[" already exists as a known command to be processed to TEI. ]] .. @@ -1467,10 +1497,57 @@ function ekdosis.testapparatus() end end -md5items = {} +local lnlabs = {} +local lnlab_salt = 0 +local current_lnlab = nil +local current_lemma = nil local salt = 0 +function ekdosis.dolnlab(str) + current_lemma = str + i = md5.sumhexa(str) + if not mdvisintable(lnlabs, i) then + table.insert(lnlabs, i) + else + i = i..salt + table.insert(lnlabs, i) + salt = salt + 1 + end + current_lnlab = i + return true +end + +function ekdosis.getlnlab() + return current_lnlab +end + +local md5items = {} + function ekdosis.mdvappend(str) + return [[\linelabel{]] .. current_lnlab .. [[-b}\wordboundary{}]] + .. + current_lemma + .. + [[\linelabel{]] .. current_lnlab .. [[-e}]] + .. + [[\csname append@app\endcsname{]] + -- {\textdir TLT\textbf{]] + -- .. + -- [[\ifnumcomp{\getrefnumber{]]..current_lnlab..[[-b}}{=}]] + -- .. + -- [[{\getrefnumber{]]..current_lnlab..[[-e}}]] + -- .. + -- [[{\getrefnumber{]]..current_lnlab..[[-b}}]] + -- .. + -- [[{\getrefnumber{]] + -- .. current_lnlab .. [[-b}--]] + -- .. + -- [[\getrefnumber{]] + -- .. current_lnlab .. [[-e}}}}~]] + .. str .. [[}]] +end + +function ekdosis.mdvappend_out(str) i = md5.sumhexa(str) if not mdvisintable(md5items, i) then table.insert(md5items, i) @@ -1488,7 +1565,6 @@ end --was: "\\csname append@app\\endcsname{\\textbf{\\textdir TLT\\getrefnumber{"..i.."}}~"..str.."}" - % \end{ekdlua} % \iffalse % -- cgit v1.2.3