strc-des.mkvi /size: 9717 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=strc-des,
3
%D version=2008.10.20,
4
%D title=\CONTEXT\ Structure Macros,
5
%D subtitle=Descriptions,
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
\writestatus
{
loading
}{
ConTeXt
Structure
Macros
/
Descriptions
}
15 16
\unprotect
17 18
\installcorenamespace
{
description
}
19 20
\installcommandhandler
\??description
{
description
}
\??description
21 22
\let
\setupdescriptions\setupdescription
23 24
% \setupdescription % check with old
25
% [\c!alternative=\descriptionparameter\c!location,
26
% \c!location=\v!left]
27 28
\setupdescription
% check with old
29
[
\c!alternative
=
\v!left
,
30
\c!headstyle
=
\v!bold
,
31
\c!titlestyle
=
\v!bold
,
32
%\c!style=,
33
%\c!color=,
34
%\c!headcolor=,
35
%\c!titlecolor=,
36
\c!width
=
7
\emwidth
,
37
\c!distance
=
\emwidth
,
38
\c!titledistance
=
.
5
\emwidth
,
39
%\c!hang=,
40
%\c!sample=,
41
%\c!align=,
42
%\c!headalign=,
43
\c!margin
=
\v!no
,
44
\c!before
=
\blank
,
45
\c!inbetween
=
\blank
,
46
\c!after
=
\blank
,
47
\c!indentnext
=
\v!yes
,
48
\c!indenting
=
\v!never
,
49
\c!titleleft
=(
,
50
\c!titleright
=)
,
51
%\c!closesymbol=,
52
\c!closecommand
=
\wordright
,
53
\c!display
=
\v!yes
,
54
%\c!command=,
55
\c!titlecommand
=
,
56
\c!expansion
=
\v!no
,
57
%\c!xmlsetup=,
58
%\s!catcodes=,
59
\c!title
=
\v!yes
,
60
%\c!text=,
61
]
62 63
\appendtoks
64
\ifx
\currentdescriptionparent
\empty
65
\defineconstruction
[
\currentdescription
][
\currentdescriptionparent
][
\s!handler
=
\v!description
,
\c!level
=
1
]
%
66
\else
67
\defineconstruction
[
\currentdescription
][
\s!handler
=
\v!description
,
\c!level
=
1
]
%
68
\fi
69
\setuevalue
{
\currentdescription
}{
\strc_descriptions_command
{
\currentdescription
}}
%
70
\setuevalue
{
\e!start
\currentdescription
}{
\strc_descriptions_start
{
\currentdescription
}}
%
71
\setuevalue
{
\e!stop
\currentdescription
}{
\strc_descriptions_stop
}
%
72
\to
\everydefinedescription
73 74
\let
\p_strc_constructions_title
\empty
75 76
\unexpanded\setvalue
{
\??constructioninitializer\v!description
}
%
77
{
\let
\currentdescription
\currentconstruction
78
\let
\constructionparameter
\descriptionparameter
79
\let
\constructionnamespace
\??description
80
\let
\detokenizedconstructionparameter
\detokenizeddescriptionparameter
81
\let
\letconstructionparameter
\letdescriptionparameter
82
\let
\useconstructionstyleandcolor
\usedescriptionstyleandcolor
83
\let
\setupcurrentconstruction
\setupcurrentdescription
84
\edef
\p_strc_constructions_title
{
\constructionparameter
\c!title
}
%
85
\ifx
\p_strc_constructions_title
\v!yes
86
\settrue
\c_strc_constructions_title_state
87
\else
88
\setfalse
\c_strc_constructions_title_state
89
\fi
}
90 91
% We keep the command variant around but rather would move to the
92
% start-stop one. Also, passing the title as argument has some
93
% history so we need to keep that as well.
94 95
% \startdescription [reference] text \stopdescription
96
% \startdescription [reference]{title} text \stopdescription
97
% \startdescription [title=,title=,reference=] text \stopdescription
98 99
% A bit over the top, the optional title but mkii has it too.
100 101
\unexpanded
\def
\strc_descriptions_start
#
1
%
102
{
\begingroup
103
\strc_constructions_initialize
{
#
1
}
%
104
\doifelsenextoptionalcs
\strc_descriptions_start_yes
\strc_descriptions_start_nop
}
105 106
\unexpanded
\def
\strc_descriptions_start_yes
[#
1
]
%
107
{
\doifelseassignment
{
#
1
}
\strc_descriptions_start_yes_assignment
\strc_descriptions_start_yes_reference
[#
1
]
}
108 109
\unexpanded
\def
\strc_descriptions_start_yes_assignment
[#
1
]
% todo userdata
110
{
\strc_constructions_register
[][
\c!label
=
{
\descriptionparameter
\c!text
}
,
\c!reference
=
,
\c!title
=
,
\c!bookmark
=
,
\c!list
=
,
#
1
]
%
111
\csname
\??constructionstarthandler
\currentconstructionhandler
\endcsname
}
112 113
\unexpanded
\def
\strc_descriptions_start_yes_reference
114
{
\ifconditional
\c_strc_constructions_title_state
115
\expandafter
\strc_descriptions_start_yes_titled
116
\else
117
\expandafter
\strc_descriptions_start_yes_normal
118
\fi
}
119 120
\unexpanded
\def
\strc_descriptions_start_yes_titled
[#
1
]
%
121
{
\doifelsenextbgroup
122
{
\strc_descriptions_start_yes_titled_indeed
[#
1
]
}
%
123
{
\setfalse
\c_strc_constructions_title_state
124
\strc_descriptions_start_yes_normal
[#
1
]
}}
125 126
\unexpanded
\def
\strc_descriptions_start_yes_titled_indeed
[#
1
]#
2
% todo userdata
127
{
\strc_constructions_register
[][
\c!label
=
{
\descriptionparameter
\c!text
}
,
\c!reference
=
{
#
1
}
,
\c!title
=
{
#
2
}
,
\c!bookmark
=
,
\c!list
=]
%
128
\csname
\??constructionstarthandler
\currentconstructionhandler
\endcsname
}
129 130
\unexpanded
\def
\strc_descriptions_start_yes_normal
[#
1
]
% todo userdata
131
{
\strc_constructions_register
[][
\c!label
=
{
\descriptionparameter
\c!text
}
,
\c!reference
=
{
#
1
}
,
\c!title
=
,
\c!bookmark
=
,
\c!list
=]
%
132
\csname
\??constructionstarthandler
\currentconstructionhandler
\endcsname
}
133 134
\unexpanded
\def
\strc_descriptions_start_nop
135
{
\ifconditional
\c_strc_constructions_title_state
136
\expandafter
\strc_descriptions_start_nop_titled
137
\else
138
\expandafter
\strc_descriptions_start_nop_normal
139
\fi
}
140 141
\unexpanded
\def
\strc_descriptions_start_nop_titled
142
{
\doifelsenextbgroup
143
{
\strc_descriptions_start_nop_titled_indeed
}
%
144
{
\setfalse
\c_strc_constructions_title_state
145
\strc_descriptions_start_nop_normal
}}
%
146 147
\unexpanded
\def
\strc_descriptions_start_nop_titled_indeed
#
1
%
148
{
\strc_constructions_register
[][
\c!label
=
{
\descriptionparameter
\c!text
}
,
\c!reference
=
,
\c!title
=
{
#
1
}
,
\c!bookmark
=
,
\c!list
=]
%
149
\csname
\??constructionstarthandler
\currentconstructionhandler
\endcsname
}
150 151
\unexpanded
\def
\strc_descriptions_start_nop_normal
152
{
\strc_constructions_register
[][
\c!label
=
{
\descriptionparameter
\c!text
}
,
\c!reference
=
,
\c!title
=
,
\c!bookmark
=
,
\c!list
=]
%
153
\csname
\??constructionstarthandler
\currentconstructionhandler
\endcsname
}
154 155
\unexpanded
\def
\strc_descriptions_stop
156
{
\csname
\??constructionstophandler
\currentconstructionhandler
\endcsname
}
157 158
% \description [reference] text \par
159
% \description [reference] {title} text \par
160 161
\unexpanded
\def
\strc_descriptions_command
#
1
%
162
{
\begingroup
163
\strc_constructions_initialize
{
#
1
}
%
164
\doifelsenextoptionalcs
\strc_descriptions_yes
\strc_descriptions_nop
}
165 166
\unexpanded
\def
\strc_descriptions_yes
167
{
\ifconditional
\c_strc_constructions_title_state
168
\expandafter
\strc_descriptions_yes_titled
169
\else
170
\expandafter
\strc_descriptions_yes_normal
171
\fi
}
172 173
\unexpanded
\def
\strc_descriptions_yes_titled
[#
1
]#
2
%
174
{
\strc_constructions_register
[][
\c!label
=
{
\descriptionparameter
\c!text
}
,
\c!reference
=
{
#
1
}
,
\c!title
=
{
#
2
}
,
\c!bookmark
=
,
\c!list
=]
%
175
\csname
\??constructioncommandhandler
\currentconstructionhandler
\endcsname
}
176 177
\unexpanded
\def
\strc_descriptions_yes_titled
[#
1
]
%
178
{
\doifelsenextbgroup
179
{
\strc_descriptions_yes_titled_indeed
[#
1
]
}
%
180
{
\setfalse
\c_strc_constructions_title_state
181
\strc_descriptions_yes_normal
[#
1
]
}}
182 183
\unexpanded
\def
\strc_descriptions_yes_titled_indeed
[#
1
]#
2
%
184
{
\strc_constructions_register
[][
\c!label
=
{
\descriptionparameter
\c!text
}
,
\c!reference
=
{
#
1
}
,
\c!title
=
{
#
2
}
,
\c!bookmark
=
,
\c!list
=]
%
185
\csname
\??constructioncommandhandler
\currentconstructionhandler
\endcsname
}
186 187
\unexpanded
\def
\strc_descriptions_yes_normal
[#
1
]
%
188
{
\strc_constructions_register
[][
\c!label
=
{
\descriptionparameter
\c!text
}
,
\c!reference
=
{
#
1
}
,
\c!title
=
,
\c!bookmark
=
,
\c!list
=]
%
189
\csname
\??constructioncommandhandler
\currentconstructionhandler
\endcsname
}
190 191
\unexpanded
\def
\strc_descriptions_nop
192
{
\ifconditional
\c_strc_constructions_title_state
193
\expandafter
\strc_descriptions_nop_titled
194
\else
195
\expandafter
\strc_descriptions_nop_normal
196
\fi
}
197 198
\unexpanded
\def
\strc_descriptions_nop_titled
199
{
\doifelsenextbgroup
200
{
\strc_descriptions_nop_titled_indeed
}
%
201
{
\setfalse
\c_strc_constructions_title_state
202
\strc_descriptions_nop_normal
}}
203 204
\unexpanded
\def
\strc_descriptions_nop_titled_indeed
#
1
%
205
{
\strc_constructions_register
[][
\c!label
=
{
\descriptionparameter
\c!text
}
,
\c!reference
=
,
\c!title
=
{
#
1
}
,
\c!bookmark
=
,
\c!list
=]
%
206
\csname
\??constructioncommandhandler
\currentconstructionhandler
\endcsname
}
207 208
\unexpanded
\def
\strc_descriptions_nop_normal
209
{
\strc_constructions_register
[][
\c!label
=
{
\descriptionparameter
\c!text
}
,
\c!reference
=
,
\c!title
=
,
\c!bookmark
=
,
\c!list
=]
%
210
\csname
\??constructioncommandhandler
\currentconstructionhandler
\endcsname
}
211 212
%D Handlers:
213 214
\expandafter\let\csname
\??constructionmainhandler
\v!description
\expandafter\endcsname\csname
\??constructionmainhandler
\v!construction
\endcsname
215
\expandafter\let\csname
\??constructioncommandhandler\v!description
\expandafter\endcsname\csname
\??constructioncommandhandler\v!construction
\endcsname
216
\expandafter\let\csname
\??constructiontexthandler
\v!description
\expandafter\endcsname\csname
\??constructiontexthandler
\v!construction
\endcsname
217 218
\unexpanded\setvalue
{
\??constructioncommandhandler\v!description
}
%
219
{
\dowithpar
220
{
\csname
\??constructionstarthandler\v!construction
\endcsname
}
%
221
{
\csname
\??constructionstophandler
\v!construction
\endcsname\endgroup
}}
222 223
\unexpanded\setvalue
{
\??constructionstarthandler\v!description
}
%
224
{
\dogotopar
225
{
\csname
\??constructionstarthandler\v!construction
\endcsname
}}
226 227
\unexpanded\setvalue
{
\??constructionstophandler\v!description
}
%
228
{
\csname
\??constructionstophandler\v!construction
\endcsname
229
\endgroup
}
230 231
%D For historic reasons we have (from now on undocumented):
232 233
\definedescription
234
[
tab
]
235
[
\c!alternative
=
\v!left
,
236
\c!headstyle
=
\v!normal
,
237
\c!headcolor
=
,
238
\c!style
=
\v!normal
,
239
\c!color
=
,
240
\c!width
=
\v!broad
,
241
\c!sample
=
\kern
4
\emwidth
,
% was \hskip but that no longer is okay
242
\c!before
=
,
243
\c!after
=]
244 245
\unexpanded
\def
\setuptab
246
{
\setupdescription
[
tab
]
}
247 248
%D Maybe we should remove this definition.
249 250
\protect
\endinput
251