strc-tnt.mkiv /size: 3576 b    last modification: 2020-07-01 14:35
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
=
1
0
]
% * will use the real space
57 58
\appendtoks
59
\setuevalue
{
\currenttextnote
}{
\educ_textnote
{
\currenttextnote
}}
%
60
\to
\everydefinetextnote
61 62
\unexpanded
\def
\educ_textnote
#
1
%
63
{
\dontleavehmode
64
\begingroup
65
\def
\currenttextnote
{
#
1
}
%
66
\dosingleempty
\educ_textnote_indeed
}
67 68
\def
\educ_textnote_indeed
[#
1
]#
2
% we could use setups but it's overkill
69
{
\iffirstargument
\setupcurrenttextnote
[#
1
]
\fi
70
\edef
\p_n
{
\textnoteparameter
\c!n
}
%
71
\edef
\p_empty
{
\textnoteparameter
\c!empty
}
%
72
\edef
\currentbar
{
\textnoteparameter
\c!rule
}
%
73
\edef
\currentnote
{
\textnoteparameter
\c!note
}
%
74
\ifx
\p_n
\wildcardsymbol
75
\donefalse
76
\ifx
\p_empty
\v!yes
77
\donetrue
78
\else\ifx
\p_empty
\v!number
79
\donetrue
80
\else\ifx
\p_empty
\v!none
81
\donetrue
82
\fi\fi\fi
83
\ifdone
84
\setupbar
[
\currentbar
][
\c!empty
=
\v!yes
]
%
85
\fi
86
\inlinebar
[
\currentbar
]
\bgroup
87
\wordboundary
#
2
%
88
\ifx
\p_empty
\v!yes
89
\setnotetext
[
\currentnote
]
{
#
2
}
%
90
\else\ifx
\p_empty
\v!number
91
\runninghbox
{
\resetbar\setnote
[
\currentnote
]
{
#
2
}}
%
92
\else\ifx
\p_empty
\v!none
93
\setupnote
[
\currentnote
][
\c!location
=
\v!none
]
%
94
\runninghbox
{
\resetbar\setnote
[
\currentnote
]
{
#
2
}}
%
95
\fi\fi\fi
96
\egroup
97
\else
98
\inlinebar
[
\currentbar
]
\bgroup
99
\scratchcounter
\numexpr
\p_n
/
\plustwo
\relax
100
\ifx
\p_empty
\v!yes
101
\interwordspacesbefore
\scratchcounter
102
\setnotetext
[
\currentnote
]
{
#
2
}
%
103
\interwordspacesafter
\scratchcounter
104
\else\ifx
\p_empty
\v!number
105
\interwordspacesbefore
\scratchcounter
106
\zwnj
\runninghbox
{
\resetbar\setnote
[
\currentnote
]
{
#
2
}}
\zwnj
107
\interwordspacesafter
\scratchcounter
108
\else\ifx
\p_empty
\v!none
109
\setupnote
[
\currentnote
][
\c!location
=
\v!none
]
%
110
\interwordspacesbefore
\scratchcounter
111
\zwnj
\runninghbox
{
\resetbar\setnote
[
\currentnote
]
{
#
2
}}
\zwnj
112
\interwordspacesafter
\scratchcounter
113
\else
114
#
2
%
115
\fi\fi\fi
116
\egroup
117
\fi
118
\endgroup
}
119 120
\protect
\endinput
121