aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Alessi <alessi@robertalessi.net>2019-10-03 22:49:24 +0200
committerRobert Alessi <alessi@robertalessi.net>2019-10-03 22:49:24 +0200
commit7248b185b2a0837a53d47658c03c23d59af5f91a (patch)
treebfe957f6e25b5436b19643bdc21edb56a1a94789
parent90de9739be28a99d767bd4ddf0b8eb16c87373b0 (diff)
downloadekdosis-7248b185b2a0837a53d47658c03c23d59af5f91a.tar.gz
added hooks to \DeclareApparatus
-rw-r--r--ekdosis.dtx63
1 files changed, 49 insertions, 14 deletions
diff --git a/ekdosis.dtx b/ekdosis.dtx
index 180e041..bbf23df 100644
--- a/ekdosis.dtx
+++ b/ekdosis.dtx
@@ -443,11 +443,21 @@ 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\NewDocumentCommand{\DeclareApparatus}{m}{ 446\newkeycommand+[\|]{\declare@apparatus}[direction={}, rule={},
447bhook={}, ehook={}][1]{%
448 |\luadirect|{%
449 ekdosis.newapparatus(
450 |\luastringN|{#1},
451 |\luastringN|{\commandkey{direction}},
452 |\luastringN|{\commandkey{rule}},
453 |\luastringN|{\commandkey{bhook}},
454 |\luastringN|{\commandkey{ehook}})}
455}
456\NewDocumentCommand{\DeclareApparatus}{m O{}}{
447 \newbool{subsq@unit@#1} 457 \newbool{subsq@unit@#1}
448 \booltrue{subsq@unit@#1} 458 \booltrue{subsq@unit@#1}
449 \unless\ifekd@mapps\global\ekd@mappstrue\fi 459 \unless\ifekd@mapps\global\ekd@mappstrue\fi
450 \luadirect{ekdosis.newapparatus(\luastringN{#1})} 460 \declare@apparatus[#2]{#1}
451} 461}
452\@onlypreamble\DeclareApparatus 462\@onlypreamble\DeclareApparatus
453% \end{macrocode} 463% \end{macrocode}
@@ -661,10 +671,10 @@ idno={}, msName={}, origDate={}][3]{%
661 \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% 671 \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
662 \fi% 672 \fi%
663 \current@ref\hskip .25em 673 \current@ref\hskip .25em
664 \ifdefined\ekdlr@alt 674 \ifdefined\ekdlr@alt%
665 \ifdefined\ekdlr@post% 675 \ifdefined\ekdlr@post%
666 \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi 676 \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
667 {\textdir TRT\unexpanded\expandafter{\ekdlr@alt}} 677 {\textdir TRT\unexpanded\expandafter{\ekdlr@alt}}%
668 \ifdefined\ekdlr@pre% 678 \ifdefined\ekdlr@pre%
669 \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi 679 \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
670 \else 680 \else
@@ -692,13 +702,13 @@ idno={}, msName={}, origDate={}][3]{%
692 \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi% 702 \ifsubsq@unit\unexpanded\expandafter{\ekd@unit@delim}\fi%
693 \fi% 703 \fi%
694 \current@ref\hskip .25em 704 \current@ref\hskip .25em
695 \ifdefined\ekdlr@alt 705 \ifdefined\ekdlr@alt%
696 \ifdefined\ekdlr@pre% 706 \ifdefined\ekdlr@pre%
697 \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi 707 \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
698 \ltx@ifpackageloaded{babel}% 708 \ltx@ifpackageloaded{babel}%
699 {\noexpand\selectlanguage{\languagename}% 709 {\noexpand\selectlanguage{\languagename}%
700 \unexpanded\expandafter{\ekdlr@alt}}% 710 \unexpanded\expandafter{\ekdlr@alt}}%
701 {\unexpanded\expandafter{\ekdlr@alt}} 711 {\unexpanded\expandafter{\ekdlr@alt}}%
702 \ifdefined\ekdlr@post% 712 \ifdefined\ekdlr@post%
703 \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi 713 \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
704 \else 714 \else
@@ -743,10 +753,10 @@ idno={}, msName={}, origDate={}][3]{%
743 \else% 753 \else%
744 \ifbool{al@rlmode}{% 754 \ifbool{al@rlmode}{%
745 \edef\rdg@app{% 755 \edef\rdg@app{%
746 \ifdefined\ekdlr@alt 756 \ifdefined\ekdlr@alt%
747 \ifdefined\ekdlr@post% 757 \ifdefined\ekdlr@post%
748 \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi 758 \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
749 {\textdir TRT\unexpanded\expandafter{\ekdlr@alt}} 759 {\textdir TRT\unexpanded\expandafter{\ekdlr@alt}}%
750 \ifdefined\ekdlr@pre% 760 \ifdefined\ekdlr@pre%
751 \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi 761 \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
752 \else 762 \else
@@ -765,13 +775,13 @@ idno={}, msName={}, origDate={}][3]{%
765 }% 775 }%
766 {% 776 {%
767 \edef\rdg@app{% 777 \edef\rdg@app{%
768 \ifdefined\ekdlr@alt 778 \ifdefined\ekdlr@alt%
769 \ifdefined\ekdlr@pre% 779 \ifdefined\ekdlr@pre%
770 \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi 780 \space\unexpanded\expandafter{\ekdlr@pre}\space\else\fi
771 \ltx@ifpackageloaded{babel}% 781 \ltx@ifpackageloaded{babel}%
772 {\noexpand\selectlanguage{\languagename}% 782 {\noexpand\selectlanguage{\languagename}%
773 \unexpanded\expandafter{\ekdlr@alt}}% 783 \unexpanded\expandafter{\ekdlr@alt}}%
774 {\unexpanded\expandafter{\ekdlr@alt}} 784 {\unexpanded\expandafter{\ekdlr@alt}}%
775 \ifdefined\ekdlr@post% 785 \ifdefined\ekdlr@post%
776 \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi 786 \space\unexpanded\expandafter{\ekdlr@post}\space\else\fi
777 \else 787 \else
@@ -1687,14 +1697,18 @@ end
1687local apparatuses = {} 1697local apparatuses = {}
1688local bagunits = {} 1698local bagunits = {}
1689 1699
1690function ekdosis.newapparatus(teitype) 1700function ekdosis.newapparatus(teitype, appdir, apprule, appbhook, appehook)
1691 if isintable(apparatuses, teitype) 1701 if isintable(apparatuses, teitype)
1692 then 1702 then
1693 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\"" 1703 tex.print("\\unexpanded{\\PackageWarning{ekdosis}{\""
1694 ..teitype.. 1704 ..teitype..
1695 "\" already exists.}}") 1705 "\" already exists.}}")
1696 else 1706 else
1697 table.insert(apparatuses, { a = teitype }) 1707 table.insert(apparatuses, {a = teitype,
1708 direction = appdir,
1709 rule = apprule,
1710 bhook = appbhook,
1711 ehook = appehook})
1698 end 1712 end
1699 bagunits[teitype] = 1 1713 bagunits[teitype] = 1
1700 return true 1714 return true
@@ -1755,13 +1769,34 @@ function ekdosis.appout()
1755 if string.match(t, "<"..cur_abs_pg.."%-"..n..">.-</"..cur_abs_pg.."%-"..n..">") 1769 if string.match(t, "<"..cur_abs_pg.."%-"..n..">.-</"..cur_abs_pg.."%-"..n..">")
1756 then 1770 then
1757 -- table.insert(output, "BEGIN") 1771 -- table.insert(output, "BEGIN")
1758 table.insert(output, "\\par\\rule{2truein}{0.5pt}\\newline") 1772 table.insert(output, "\\bgroup{}")
1773 if apparatuses[n].direction ~= ""
1774 then
1775 table.insert(output, apparatuses[n].direction)
1776 else
1777 end
1778 if apparatuses[n].rule ~= ""
1779 then
1780 table.insert(output, "\\par\\mbox{}" .. apparatuses[n].rule .. "\\newline{}")
1781 else
1782 table.insert(output, "\\par\\rule{2truein}{0.5pt}\\newline{}")
1783 end
1784 if apparatuses[n].bhook ~= ""
1785 then
1786 table.insert(output, apparatuses[n].bhook)
1787 else
1788 end
1759 for i in string.gmatch(t, 1789 for i in string.gmatch(t,
1760 "<"..cur_abs_pg.."%-"..n..">.-</"..cur_abs_pg.."%-"..n..">") 1790 "<"..cur_abs_pg.."%-"..n..">.-</"..cur_abs_pg.."%-"..n..">")
1761 do 1791 do
1762 table.insert(output, i) 1792 table.insert(output, i)
1763 end 1793 end
1764 table.insert(output, "\\csname ekd@end@apparatus\\endcsname") 1794 if apparatuses[n].ehook ~= ""
1795 then
1796 table.insert(output, apparatuses[n].ehook)
1797 else
1798 end
1799 table.insert(output, "\\egroup{}")
1765 -- table.insert(output, "END") 1800 -- table.insert(output, "END")
1766 end 1801 end
1767 n = n + 1 1802 n = n + 1