aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ekdosis.dtx74
1 files changed, 55 insertions, 19 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index bbf23df..fb80c1a 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -443,13 +443,15 @@ idno={}, msName={}, origDate={}][3]{%
443% Multi-layer apparatuses 443% Multi-layer apparatuses
444% \begin{macrocode} 444% \begin{macrocode}
445\newif\ifekd@mapps 445\newif\ifekd@mapps
446\newkeycommand+[\|]{\declare@apparatus}[direction={}, rule={}, 446\newkeycommand+[\|]{\declare@apparatus}[enum direction={LR,RL}, rule={},
447bhook={}, ehook={}][1]{% 447 delim={}, bhook={},
448 ehook={\csname ekd@end@apparatus\endcsname}][1]{%
448 |\luadirect|{% 449 |\luadirect|{%
449 ekdosis.newapparatus( 450 ekdosis.newapparatus(
450 |\luastringN|{#1}, 451 |\luastringN|{#1},
451 |\luastringN|{\commandkey{direction}}, 452 |\luastringN|{\commandkey{direction}},
452 |\luastringN|{\commandkey{rule}}, 453 |\luastringN|{\commandkey{rule}},
454 |\luastringN|{\commandkey{delim}},
453 |\luastringN|{\commandkey{bhook}}, 455 |\luastringN|{\commandkey{bhook}},
454 |\luastringN|{\commandkey{ehook}})} 456 |\luastringN|{\commandkey{ehook}})}
455} 457}
@@ -484,12 +486,19 @@ bhook={}, ehook={}][1]{%
484\newif\ifrtl@app 486\newif\ifrtl@app
485\NewDocumentCommand{\SetRTLapp}{}{\rtl@apptrue} 487\NewDocumentCommand{\SetRTLapp}{}{\rtl@apptrue}
486\NewDocumentCommand{\SetLTRapp}{}{\rtl@appfalse} 488\NewDocumentCommand{\SetLTRapp}{}{\rtl@appfalse}
487\edef\ekdsep{: } 489\edef\ekdsep{] }
488\NewDocumentCommand{\SetSeparator}{m}{\edef\ekdsep{#1}} 490\NewDocumentCommand{\SetSeparator}{m}{\edef\ekdsep{#1}}
489\edef\ekd@end@apparatus{} 491\edef\ekd@end@apparatus{}
490\NewDocumentCommand{\SetEndApparatus}{m}{\edef\ekd@end@apparatus{#1}} 492\NewDocumentCommand{\SetEndApparatus}{m}{\edef\ekd@end@apparatus{#1}}
491\def\ekd@unit@delim{} 493\def\ekd@unit@delim{}
492\NewDocumentCommand{\SetUnitDelimiter}{m}{\def\ekd@unit@delim{#1}} 494\NewDocumentCommand{\SetUnitDelimiter}{m}{\def\ekd@unit@delim{#1}}
495\def\ekd@default@rule{\rule{2truein}{0.5pt}}
496\NewDocumentCommand{\SetDefaultRule}{m}{%
497 \def\@tempa{#1}
498 \ifx\@tempa\empty\def\ekd@default@rule{\mbox{}}%
499 \else%
500 \def\ekd@default@rule{#1}%
501 \fi}
493\newif\ifsubsq@unit 502\newif\ifsubsq@unit
494\subsq@unittrue 503\subsq@unittrue
495\def\add@@apparatus{% 504\def\add@@apparatus{%
@@ -503,7 +512,8 @@ bhook={}, ehook={}][1]{%
503 \footnotesize\apparatus\unless\ifekd@mapps\ekd@end@apparatus\fi% 512 \footnotesize\apparatus\unless\ifekd@mapps\ekd@end@apparatus\fi%
504 \if@pkg@parnotes\parnotes\parnotereset\else\fi% 513 \if@pkg@parnotes\parnotes\parnotereset\else\fi%
505 }% 514 }%
506 \unless\ifekd@mapps\unconditional@appin{\rule{2truein}{0.5pt}\newline}\fi 515 \unless\ifekd@mapps\unconditional@appin{%
516 \expandafter{\ekd@default@rule}\newline}\fi
507} 517}
508\def\add@apparatus{% 518\def\add@apparatus{%
509 \test@apparatus% 519 \test@apparatus%
@@ -645,17 +655,19 @@ bhook={}, ehook={}][1]{%
645 \setkeys[ekd]{lemrdg,lem}{#1}% 655 \setkeys[ekd]{lemrdg,lem}{#1}%
646 \ifekd@mapps% 656 \ifekd@mapps%
647 \ifnum% 657 \ifnum%
648 \luadirect{tex.sprint(ekdosis.get_bagunits(\luastringO{\ekdan@type}))} 658 \luadirect{tex.sprint(ekdosis.get_bagunits(\luastringO{\ekdan@type}))}
649 = 1 659 = 1
650 \boolfalse{subsq@unit@\ekdan@type}% 660 \boolfalse{subsq@unit@\ekdan@type}%
651 \fi% 661 \fi%
652 \luadirect{ekdosis.increment_bagunits(\luastringO{\ekdan@type})}% 662 \luadirect{ekdosis.increment_bagunits(\luastringO{\ekdan@type})}%
663 \def\ekd@munit@delim{%
664 \luadirect{tex.sprint(ekdosis.getappdelim(\luastringO{\ekdan@type}))}}%
653 \fi% 665 \fi%
654 \ifekdl@nolem\edef\lem@app{% 666 \ifekdl@nolem\edef\lem@app{%
655 \hskip .75em 667 \hskip .75em
656 \ifekd@mapps 668 \ifekd@mapps
657 \ifbool{subsq@unit@\ekdan@type}% 669 \ifbool{subsq@unit@\ekdan@type}%
658 {\unexpanded\expandafter{\ekd@unit@delim}}{}% 670 {\expandafter\noexpand\ekd@munit@delim}{}%
659 \else% 671 \else%
660 \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% 672 \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
661 \fi% 673 \fi%
@@ -666,7 +678,7 @@ bhook={}, ehook={}][1]{%
666 \hskip .75em 678 \hskip .75em
667 \ifekd@mapps 679 \ifekd@mapps
668 \ifbool{subsq@unit@\ekdan@type}% 680 \ifbool{subsq@unit@\ekdan@type}%
669 {\unexpanded\expandafter{\ekd@unit@delim}}{}% 681 {\expandafter\noexpand\ekd@munit@delim}{}%
670 \else% 682 \else%
671 \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% 683 \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
672 \fi% 684 \fi%
@@ -697,7 +709,7 @@ bhook={}, ehook={}][1]{%
697 \hskip .75em 709 \hskip .75em
698 \ifekd@mapps 710 \ifekd@mapps
699 \ifbool{subsq@unit@\ekdan@type}% 711 \ifbool{subsq@unit@\ekdan@type}%
700 {\unexpanded\expandafter{\ekd@unit@delim}}{}% 712 {\expandafter\noexpand\ekd@munit@delim}{}%
701 \else% 713 \else%
702 \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% 714 \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
703 \fi% 715 \fi%
@@ -830,6 +842,8 @@ bhook={}, ehook={}][1]{%
830 \boolfalse{subsq@unit@\ekdan@type}% 842 \boolfalse{subsq@unit@\ekdan@type}%
831 \fi% 843 \fi%
832 \luadirect{ekdosis.increment_bagunits(\luastringO{\ekdan@type})}% 844 \luadirect{ekdosis.increment_bagunits(\luastringO{\ekdan@type})}%
845 \def\ekd@munit@delim{%
846 \luadirect{tex.sprint(ekdosis.getappdelim(\luastringO{\ekdan@type}))}}%
833 \fi% 847 \fi%
834 \ifdefined\ekdn@labelb% 848 \ifdefined\ekdn@labelb%
835 \luadirect{tex.sprint(ekdosis.setnotelab(\luastringO{\ekdn@labelb}))}% 849 \luadirect{tex.sprint(ekdosis.setnotelab(\luastringO{\ekdn@labelb}))}%
@@ -841,7 +855,7 @@ bhook={}, ehook={}][1]{%
841 \hskip .75em 855 \hskip .75em
842 \ifekd@mapps 856 \ifekd@mapps
843 \ifbool{subsq@unit@\ekdan@type}% 857 \ifbool{subsq@unit@\ekdan@type}%
844 {\unexpanded\expandafter{\ekd@unit@delim}}{}% 858 {\expandafter\noexpand\ekd@munit@delim}{}%
845 \else% 859 \else%
846 \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% 860 \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
847 \fi% 861 \fi%
@@ -854,7 +868,7 @@ bhook={}, ehook={}][1]{%
854 \hskip .75em 868 \hskip .75em
855 \ifekd@mapps 869 \ifekd@mapps
856 \ifbool{subsq@unit@\ekdan@type}% 870 \ifbool{subsq@unit@\ekdan@type}%
857 {\unexpanded\expandafter{\ekd@unit@delim}}{}% 871 {\expandafter\noexpand\ekd@munit@delim}{}%
858 \else% 872 \else%
859 \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% 873 \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
860 \fi% 874 \fi%
@@ -1697,7 +1711,12 @@ end
1697local apparatuses = {} 1711local apparatuses = {}
1698local bagunits = {} 1712local bagunits = {}
1699 1713
1700function ekdosis.newapparatus(teitype, appdir, apprule, appbhook, appehook) 1714function ekdosis.newapparatus(teitype,
1715 appdir,
1716 apprule,
1717 appdelim,
1718 appbhook,
1719 appehook)
1701 if isintable(apparatuses, teitype) 1720 if isintable(apparatuses, teitype)
1702 then 1721 then
1703 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" 1722 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
@@ -1707,6 +1726,7 @@ function ekdosis.newapparatus(teitype, appdir, apprule, appbhook, appehook)
1707 table.insert(apparatuses, {a = teitype, 1726 table.insert(apparatuses, {a = teitype,
1708 direction = appdir, 1727 direction = appdir,
1709 rule = apprule, 1728 rule = apprule,
1729 delim = appdelim,
1710 bhook = appbhook, 1730 bhook = appbhook,
1711 ehook = appehook}) 1731 ehook = appehook})
1712 end 1732 end
@@ -1714,6 +1734,17 @@ function ekdosis.newapparatus(teitype, appdir, apprule, appbhook, appehook)
1714 return true 1734 return true
1715end 1735end
1716 1736
1737function ekdosis.getappdelim(str)
1738 for i = 1,#apparatuses
1739 do
1740 if apparatuses[i].a == str then
1741 delimfound = apparatuses[i].delim
1742 break
1743 end
1744 end
1745 return delimfound
1746end
1747
1717function ekdosis.get_bagunits(teitype) 1748function ekdosis.get_bagunits(teitype)
1718 return bagunits[teitype] 1749 return bagunits[teitype]
1719end 1750end
@@ -1770,16 +1801,21 @@ function ekdosis.appout()
1770 then 1801 then
1771 -- table.insert(output, "BEGIN") 1802 -- table.insert(output, "BEGIN")
1772 table.insert(output, "\\bgroup{}") 1803 table.insert(output, "\\bgroup{}")
1773 if apparatuses[n].direction ~= "" 1804 if apparatuses[n].direction == "LR"
1774 then 1805 then
1775 table.insert(output, apparatuses[n].direction) 1806 table.insert(output, "\\pardir TLT\\textdir TLT{}")
1776 else 1807 elseif apparatuses[n].direction == "RL"
1808 then
1809 table.insert(output, "\\pardir TRT\\textdir TRT{}")
1777 end 1810 end
1778 if apparatuses[n].rule ~= "" 1811 if apparatuses[n].rule == "none"
1812 then
1813 table.insert(output, "\\par\\mbox{}\\newline{}")
1814 elseif apparatuses[n].rule ~= ""
1779 then 1815 then
1780 table.insert(output, "\\par\\mbox{}" .. apparatuses[n].rule .. "\\newline{}") 1816 table.insert(output, "\\par\\mbox{}" .. apparatuses[n].rule .. "\\newline{}")
1781 else 1817 else
1782 table.insert(output, "\\par\\rule{2truein}{0.5pt}\\newline{}") 1818 table.insert(output, "\\par\\csname ekd@default@rule\\endcsname\\newline{}")
1783 end 1819 end
1784 if apparatuses[n].bhook ~= "" 1820 if apparatuses[n].bhook ~= ""
1785 then 1821 then