aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2019-09-03 19:43:48 +0200
committerRobert Alessi <alessi@robertalessi.net>2019-09-03 19:43:48 +0200
commitbff091028c07c16c80bcb7f6d8330dea0844d707 (patch)
tree340d64175515160b6ed3dfc7191b631b7660db84
parenta9999419c7e009c4c691fc485f0a52eea69f0f09 (diff)
downloadekdosis-bff091028c07c16c80bcb7f6d8330dea0844d707.tar.gz
\lem now inserts begin/end line numbers. added unit delimiter and end-of-apparatus hook
-rw-r--r--ekdosis.dtx102
1 files changed, 89 insertions, 13 deletions
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.
358\RequirePackage{lineno} 358\RequirePackage{lineno}
359\RequirePackage{keyfloat} 359\RequirePackage{keyfloat}
360\RequirePackage{refcount} 360\RequirePackage{refcount}
361\RequirePackage{xspace} 361%\RequirePackage{xspace}
362\RequirePackage[user,abspage]{zref} 362\RequirePackage[user,abspage]{zref}
363\RequirePackage{ltxcmds} 363\RequirePackage{ltxcmds}
364\if@pkg@parnotes 364\if@pkg@parnotes
@@ -472,6 +472,14 @@ idno={}, msName={}, origDate={}][3]{%
472\newif\ifrtl@app 472\newif\ifrtl@app
473\NewDocumentCommand{\SetRTLapp}{}{\rtl@apptrue} 473\NewDocumentCommand{\SetRTLapp}{}{\rtl@apptrue}
474\NewDocumentCommand{\SetLTRapp}{}{\rtl@appfalse} 474\NewDocumentCommand{\SetLTRapp}{}{\rtl@appfalse}
475\edef\ekdsep{: }
476\NewDocumentCommand{\SetSeparator}{m}{\edef\ekdsep{#1}}
477\edef\ekd@end@apparatus{}
478\NewDocumentCommand{\SetEndApparatus}{m}{\edef\ekd@end@apparatus{#1}}
479\def\ekd@unit@delim{}
480\NewDocumentCommand{\SetUnitDelimiter}{m}{\def\ekd@unit@delim{#1}}
481\newif\ifsubsq@unit
482\subsq@unittrue
475\def\add@@apparatus{% 483\def\add@@apparatus{%
476 % \blfootnote{\apparatus}% 484 % \blfootnote{\apparatus}%
477 \if@pkg@parnotes\parnotes\else\fi% 485 \if@pkg@parnotes\parnotes\else\fi%
@@ -480,16 +488,16 @@ idno={}, msName={}, origDate={}][3]{%
480 \if@parnotesroman% 488 \if@parnotesroman%
481 \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi% 489 \renewcommand*{\theparnotemark}{\roman{parnotemark}}\else\fi%
482 \parnoteclear\else\fi% 490 \parnoteclear\else\fi%
483 \footnotesize\apparatus% 491 \footnotesize\apparatus\ekd@end@apparatus%
484 \if@pkg@parnotes\parnotes\parnotereset\else\fi% 492 \if@pkg@parnotes\parnotes\parnotereset\else\fi%
485 }% 493 }%
486 \unconditional@appin{\rule{5cm}{0.5pt}\newline} 494 \unconditional@appin{\rule{5cm}{0.5pt}\newline}
487} 495}
488\def\add@apparatus{% 496\def\add@apparatus{%
489 \notbool{ekd@started}{\add@@apparatus% 497 \notbool{ekd@started}{\subsq@unitfalse\add@@apparatus%
490 \global\setbool{ekd@started}{true}} 498 \global\setbool{ekd@started}{true}}
491 {\test@apparatus% 499 {\test@apparatus%
492 \ifbool{do@app}{\add@@apparatus}{}}% 500 \ifbool{do@app}{\subsq@unitfalse\add@@apparatus}{}}%
493} 501}
494\NewDocumentCommand{\append@app}{+m}{% 502\NewDocumentCommand{\append@app}{+m}{%
495 \ifekd@isinapp% 503 \ifekd@isinapp%
@@ -514,8 +522,17 @@ idno={}, msName={}, origDate={}][3]{%
514 \ifbool{ekd@state}{\add@apparatus}{}% 522 \ifbool{ekd@state}{\add@apparatus}{}%
515 \luadirect{tex.sprint(ekdosis.removesp(\luastringN{#1}))}% 523 \luadirect{tex.sprint(ekdosis.removesp(\luastringN{#1}))}%
516 \ekd@isinappfalse} 524 \ekd@isinappfalse}
517\edef\ekdsep{: } 525\def\current@ref{{\textdir TLT\noexpand\bfseries%
518\NewDocumentCommand{\SetSeparator}{m}{\edef\ekdsep{#1}} 526 \ifnum%
527 \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}
528 =
529 \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}
530 \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}%
531 \else
532 \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}--%
533 \getrefnumber{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}%
534 \fi}
535 }%
519\define@cmdkeys[ekd]{lemrdg}[ekdlr@]{wit, alt, pre, post, prewit, 536\define@cmdkeys[ekd]{lemrdg}[ekdlr@]{wit, alt, pre, post, prewit,
520 postwit} 537 postwit}
521\define@cmdkey[ekd]{lem}[ekdl@]{sep}{} 538\define@cmdkey[ekd]{lem}[ekdl@]{sep}{}
@@ -523,12 +540,21 @@ idno={}, msName={}, origDate={}][3]{%
523\define@boolkeys[ekd]{lem}[ekdl@]{nolem, nosep}[true] 540\define@boolkeys[ekd]{lem}[ekdl@]{nolem, nosep}[true]
524\define@boolkeys[ekd]{rdg}[ekdr@]{nordg}[true] 541\define@boolkeys[ekd]{rdg}[ekdr@]{nordg}[true]
525\NewDocumentCommand{\lem}{O{} m}{% 542\NewDocumentCommand{\lem}{O{} m}{%
526 #2% 543 \luadirect{ekdosis.dolnlab(\luastringN{#2})}%
544 % \linelabel{\luadirect{tex.sprint(ekdosis.getlnlab())}-b}%
545 % #2%
546 % \linelabel{\luadirect{tex.sprint(ekdosis.getlnlab())}-e}%
527 \bgroup% 547 \bgroup%
528 \setkeys[ekd]{lemrdg,lem}{#1}% 548 \setkeys[ekd]{lemrdg,lem}{#1}%
529 \ifekdl@nolem\append@ln@app{}\else% 549 \ifekdl@nolem\edef\lem@app{%
550 \hskip .75em\ifsubsq@unit%
551 \unexpanded\expandafter{\ekd@unit@delim}\else\fi%
552 \current@ref\hskip .25em}\else%
530 \ifbool{al@rlmode}{% 553 \ifbool{al@rlmode}{%
531 \edef\lem@app{% 554 \edef\lem@app{%
555 \hskip .75em\ifsubsq@unit%
556 \unexpanded\expandafter{\ekd@unit@delim}\else\fi%
557 \current@ref\hskip .25em
532 \ifdefined\ekdlr@alt 558 \ifdefined\ekdlr@alt
533 \ifdefined\ekdlr@post% 559 \ifdefined\ekdlr@post%
534 \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi 560 \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
@@ -552,6 +578,9 @@ idno={}, msName={}, origDate={}][3]{%
552 }% 578 }%
553 {% 579 {%
554 \edef\lem@app{% 580 \edef\lem@app{%
581 \hskip .75em\ifsubsq@unit%
582 \unexpanded\expandafter{\ekd@unit@delim}\else\fi%
583 \current@ref\hskip .25em
555 \ifdefined\ekdlr@alt 584 \ifdefined\ekdlr@alt
556 \ifdefined\ekdlr@pre% 585 \ifdefined\ekdlr@pre%
557 \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi 586 \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
@@ -577,9 +606,10 @@ idno={}, msName={}, origDate={}][3]{%
577 \ifekdl@nosep\else\unexpanded\expandafter{\ekdl@sep}\fi 606 \ifekdl@nosep\else\unexpanded\expandafter{\ekdl@sep}\fi
578 }% 607 }%
579 }% 608 }%
580 \append@ln@app{\lem@app}%
581 \fi% 609 \fi%
610 \append@ln@app{\lem@app}%
582 \egroup% 611 \egroup%
612 \subsq@unittrue%
583} 613}
584\NewDocumentCommand{\rdg}{O{} m}{% 614\NewDocumentCommand{\rdg}{O{} m}{%
585 \bgroup% 615 \bgroup%
@@ -958,7 +988,7 @@ function ekdosis.newscholar(id, siglum)
958 then 988 then
959 tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] 989 tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]]
960 ..id.. 990 ..id..
961 [[" already exists as a xml:id. ]] 991 [[" already exists as a xml:id. ]]
962 .. 992 ..
963 [[Please pick another id.}}]]) 993 [[Please pick another id.}}]])
964 else 994 else
@@ -1036,7 +1066,7 @@ local close_p = {
1036function ekdosis.newcmdtotag(cmd, tag, attr) 1066function ekdosis.newcmdtotag(cmd, tag, attr)
1037 if isintable(cmdtotags, cmd) 1067 if isintable(cmdtotags, cmd)
1038 then 1068 then
1039 tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] 1069 tex.print([[\unexpanded{\PackageWarning{ekdosis}{"]] --`'
1040 ..cmd.. 1070 ..cmd..
1041 [[" already exists as a known command to be processed to TEI. ]] 1071 [[" already exists as a known command to be processed to TEI. ]]
1042 .. 1072 ..
@@ -1467,10 +1497,57 @@ function ekdosis.testapparatus()
1467 end 1497 end
1468end 1498end
1469 1499
1470md5items = {} 1500local lnlabs = {}
1501local lnlab_salt = 0
1502local current_lnlab = nil
1503local current_lemma = nil
1471local salt = 0 1504local salt = 0
1472 1505
1506function ekdosis.dolnlab(str)
1507 current_lemma = str
1508 i = md5.sumhexa(str)
1509 if not mdvisintable(lnlabs, i) then
1510 table.insert(lnlabs, i)
1511 else
1512 i = i..salt
1513 table.insert(lnlabs, i)
1514 salt = salt + 1
1515 end
1516 current_lnlab = i
1517 return true
1518end
1519
1520function ekdosis.getlnlab()
1521 return current_lnlab
1522end
1523
1524local md5items = {}
1525
1473function ekdosis.mdvappend(str) 1526function ekdosis.mdvappend(str)
1527 return [[\linelabel{]] .. current_lnlab .. [[-b}\wordboundary{}]]
1528 ..
1529 current_lemma
1530 ..
1531 [[\linelabel{]] .. current_lnlab .. [[-e}]]
1532 ..
1533 [[\csname append@app\endcsname{]]
1534 -- {\textdir TLT\textbf{]]
1535 -- ..
1536 -- [[\ifnumcomp{\getrefnumber{]]..current_lnlab..[[-b}}{=}]]
1537 -- ..
1538 -- [[{\getrefnumber{]]..current_lnlab..[[-e}}]]
1539 -- ..
1540 -- [[{\getrefnumber{]]..current_lnlab..[[-b}}]]
1541 -- ..
1542 -- [[{\getrefnumber{]]
1543 -- .. current_lnlab .. [[-b}--]]
1544 -- ..
1545 -- [[\getrefnumber{]]
1546 -- .. current_lnlab .. [[-e}}}}~]]
1547 .. str .. [[}]]
1548end
1549
1550function ekdosis.mdvappend_out(str)
1474 i = md5.sumhexa(str) 1551 i = md5.sumhexa(str)
1475 if not mdvisintable(md5items, i) then 1552 if not mdvisintable(md5items, i) then
1476 table.insert(md5items, i) 1553 table.insert(md5items, i)
@@ -1488,7 +1565,6 @@ end
1488 1565
1489--was: "\\csname append@app\\endcsname{\\textbf{\\textdir TLT\\getrefnumber{"..i.."}}~"..str.."}" 1566--was: "\\csname append@app\\endcsname{\\textbf{\\textdir TLT\\getrefnumber{"..i.."}}~"..str.."}"
1490 1567
1491
1492% \end{ekdlua} 1568% \end{ekdlua}
1493% \iffalse 1569% \iffalse
1494%</lua> 1570%</lua>