strc-tnt.mkxl /size: 3515 b    last modification: 2023-12-21 09:44
1%D \module
2%D   [       file=strc-tnt,
3%D        version=2019.05.30, % based on older code
4%D          title=\CONTEXT\ Structure Macros,
5%D       subtitle=Text Notes,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\unprotect
15
16%D \macros
17%D   {definetextnote,setuptextnote}
18%D
19%D \startbuffer
20%D \definetextnote
21%D   [textnote]
22%D
23%D \startbuffer
24%D Test test test \textnote [n=5] {alpha}. test test test test tets test test
25%D \textnote [n=10] {beta}. Test test test test tets test test \textnote [n=12]
26%D {gamma}. Test test test test tets test test \textnote [n=24] {delta}. Test test
27%D test test test test \textnote {epsilon} test test \textnote [n=*] {zeta}.
28%D \stopbuffer
29%D
30%D \blank {\setuptextnote[empty=yes]    \getbuffer\par} \blank
31%D \blank {\setuptextnote[empty=number] \getbuffer\par} \blank
32%D \blank {\setuptextnote[empty=none]   \getbuffer\par} \blank
33%D \blank {                             \getbuffer\par} \blank
34%D
35%D \blank[2*big]
36%D
37%D \placenotes[textnote:note][criterium=text]
38%D \stopbuffer
39%D
40%D \typebuffer \getbuffer
41
42\installcorenamespace{textnote}
43
44\installcommandhandler \??textnote {textnote} \??textnote
45
46\definebar
47  [\v!textnote:\v!underbar]
48  [\v!underbar]
49
50\definenote
51  [\v!textnote:\v!note]
52
53\setuptextnote
54  [\c!rule=\v!textnote:\v!underbar,
55   \c!note=\v!textnote:\v!note,
56   \c!n=10] % * will use the real space
57
58\appendtoks
59    \frozen\instance\protected\edefcsname\currenttextnote\endcsname{\educ_textnote[\currenttextnote]}%
60\to \everydefinetextnote
61
62\tolerant\protected\def\educ_textnote[#1]#*[#S#2]#:#3%
63  {\dontleavehmode
64   \begingroup
65   \def\currenttextnote{#1}%
66   \ifparameter#2\or\setupcurrenttextnote[#2]\fi
67   \edef\p_n{\textnoteparameter\c!n}%
68   \edef\p_empty{\textnoteparameter\c!empty}%
69   \edef\currentbar{\textnoteparameter\c!rule}%
70   \edef\currentnote{\textnoteparameter\c!note}%
71   \ifx\p_n\wildcardsymbol
72     \donefalse
73     \ifx\p_empty\v!yes
74       \donetrue
75     \orelse\ifx\p_empty\v!number
76       \donetrue
77     \orelse\ifx\p_empty\v!none
78       \donetrue
79     \fi
80     \ifdone
81       \setupbar[\currentbar][\c!empty=\v!yes]%
82     \fi
83     \inlinebar[\currentbar]\bgroup
84       \wordboundary#3%
85       \ifx\p_empty\v!yes
86         \setnotetext[\currentnote]{#3}%
87       \orelse\ifx\p_empty\v!number
88         \runninghbox{\resetbar\setnote[\currentnote]{#3}}%
89       \orelse\ifx\p_empty\v!none
90         \setupnote[\currentnote][\c!location=\v!none]%
91         \runninghbox{\resetbar\setnote[\currentnote]{#3}}%
92       \fi
93     \egroup
94   \else
95     \inlinebar[\currentbar]\bgroup
96       \scratchcounter\numexpr\p_n/\plustwo\relax
97       \ifx\p_empty\v!yes
98         \interwordspacesbefore\scratchcounter
99         \setnotetext[\currentnote]{#3}%
100         \interwordspacesafter\scratchcounter
101       \orelse\ifx\p_empty\v!number
102         \interwordspacesbefore\scratchcounter
103         \zwnj\runninghbox{\resetbar\setnote[\currentnote]{#3}}\zwnj
104         \interwordspacesafter\scratchcounter
105       \orelse\ifx\p_empty\v!none
106         \setupnote[\currentnote][\c!location=\v!none]%
107         \interwordspacesbefore\scratchcounter
108         \zwnj\runninghbox{\resetbar\setnote[\currentnote]{#3}}\zwnj
109         \interwordspacesafter\scratchcounter
110       \else
111          #3%
112       \fi
113     \egroup
114   \fi
115   \endgroup}
116
117\protect \endinput
118