1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Structure Macros Descriptions}
15
16\unprotect
17
18\installcorenamespace{description}
19
20\installcommandhandler \??description {description} \??description
21
22\aliased\let\setupdescriptions\setupdescription
23
24
25
26
27
28\setupdescription
29 [\c!alternative=\v!left,
30 \c!headstyle=\v!bold,
31 \c!titlestyle=\v!bold,
32
33
34
35
36 \c!width=7\emwidth,
37 \c!distance=\emwidth,
38 \c!titledistance=.5\emwidth,
39
40
41
42
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
52 \c!closecommand=\wordright,
53 \c!display=\v!yes,
54
55 \c!titlecommand=,
56 \c!expansion=\v!no,
57
58
59 \c!title=\v!yes,
60
61 \c!define=\v!yes,
62 ]
63
64\appendtoks
65 \ifempty\currentdescriptionparent
66 \defineconstruction[\currentdescription][\currentdescriptionparent][\s!handler=\v!description,\c!level=1]
67 \else
68 \defineconstruction[\currentdescription][\s!handler=\v!description,\c!level=1]
69 \fi
70
71 \ifcstok{\descriptionparameter\c!define}\v!yes
72 \frozen\protected\instance\edefcsname \currentdescription\endcsname{\nameddescription[\currentdescription]}
73 \frozen\protected\instance\edefcsname\e!start\currentdescription\endcsname{\startnameddescription[\currentdescription]}
74 \frozen\protected\instance \defcsname \e!stop\currentdescription\endcsname{\stopnameddescription}
75 \fi
76\to \everydefinedescription
77
78\protected\defcsname\??constructioninitializer\v!description\endcsname
79 {\let \currentdescription \currentconstruction
80 \enforced\let\constructionparameter \descriptionparameter
81 \enforced\let\constructionnamespace \??description
82 \enforced\let\detokenizedconstructionparameter\detokenizeddescriptionparameter
83 \enforced\let\letconstructionparameter \letdescriptionparameter
84 \enforced\let\useconstructionstyleandcolor \usedescriptionstyleandcolor
85 \enforced\let\setupcurrentconstruction \setupcurrentdescription
86 \ifcstok{\constructionparameter\c!title}\v!yes
87 \c_strc_constructions_title_state\conditionaltrue
88 \else
89 \c_strc_constructions_title_state\conditionalfalse
90 \fi}
91
92
93
94
95
96
97
98
99
100
101
102\tolerant\permanent\protected\def\startnameddescription[#1]#*[#S#2]
103 {\begingroup
104 \strc_constructions_initialize{#1}
105 \ifhastok={#2}
106 \expandafter\strc_descriptions_start_setups
107 \orelse\ifconditional\c_strc_constructions_title_state
108 \expandafter\strc_descriptions_start_title
109 \else
110 \expandafter\strc_descriptions_start_reference
111 \fi[#2]}
112
113
114
115
116
117
118
119
120
121\protected\def\strc_descriptions_start_setups[#S#1]
122 {\strc_constructions_register[][\c!reference=,\c!title=,\c!bookmark=,\c!list=,\c!referencetext=,#1]
123 \csname\??constructionstarthandler\currentconstructionhandler\endcsname}
124
125\protected\tolerant\def\strc_descriptions_start_title[#1]#*#=
126 {\strc_constructions_register[][\c!reference={#1},\c!title={#2},\c!bookmark=,\c!list=,\c!referencetext=]
127 \csname\??constructionstarthandler\currentconstructionhandler\endcsname}
128
129\protected\def\strc_descriptions_start_reference[#1]
130 {\strc_constructions_register[][\c!reference={#1},\c!title=,\c!bookmark=,\c!list=,\c!referencetext=]
131 \csname\??constructionstarthandler\currentconstructionhandler\endcsname}
132
133\permanent\protected\def\stopnameddescription
134 {\csname\??constructionstophandler\currentconstructionhandler\endcsname}
135
136
137
138
139\tolerant\permanent\protected\def\nameddescription[#1]#*[#S#2]
140 {\begingroup
141 \strc_constructions_initialize{#1}
142 \ifhastok={#2}
143 \expandafter\strc_descriptions_command_setups
144 \orelse\ifconditional\c_strc_constructions_title_state
145 \expandafter\strc_descriptions_command_title
146 \else
147 \expandafter\strc_descriptions_command_reference
148 \fi[#2]}
149
150\protected\def\strc_descriptions_command_setups[#S#1]
151 {\strc_constructions_register[][\c!label={\descriptionparameter\c!text},\c!reference=,\c!title=,\c!bookmark=,\c!list=,\c!referencetext=,#1]
152 \csname\??constructioncommandhandler\currentconstructionhandler\endcsname}
153
154\protected\tolerant\def\strc_descriptions_command_title[#1]#:#*#=
155 {\strc_constructions_register[][\c!label={\descriptionparameter\c!text},\c!reference={#1},\c!title={#2},\c!bookmark=,\c!list=,\c!referencetext=]
156 \csname\??constructioncommandhandler\currentconstructionhandler\endcsname}
157
158\protected\def\strc_descriptions_command_reference[#1]
159 {\strc_constructions_register[][\c!label={\descriptionparameter\c!text},\c!reference={#1},\c!title=,\c!bookmark=,\c!list=,\c!referencetext=]
160 \csname\??constructioncommandhandler\currentconstructionhandler\endcsname}
161
162
163
164\letcsname\??constructionmainhandler \v!description\expandafter\endcsname\csname\??constructionmainhandler \v!construction\endcsname
165\letcsname\??constructioncommandhandler\v!description\expandafter\endcsname\csname\??constructioncommandhandler\v!construction\endcsname
166\letcsname\??constructiontexthandler \v!description\expandafter\endcsname\csname\??constructiontexthandler \v!construction\endcsname
167
168\protected\defcsname\??constructioncommandhandler\v!description\endcsname
169 {\dowithpar
170 {\csname\??constructionstarthandler\v!construction\endcsname}
171 {\csname\??constructionstophandler \v!construction\endcsname\endgroup}}
172
173\protected\defcsname\??constructionstarthandler\v!description\endcsname
174 {\dogotopar
175 {\csname\??constructionstarthandler\v!construction\endcsname}}
176
177\protected\defcsname\??constructionstophandler\v!description\endcsname
178 {\csname\??constructionstophandler\v!construction\endcsname
179 \endgroup}
180
181
182
183\definedescription
184 [tab]
185 [\c!alternative=\v!left,
186 \c!headstyle=\v!normal,
187 \c!headcolor=,
188 \c!style=\v!normal,
189 \c!color=,
190 \c!width=\v!broad,
191 \c!sample=\kern4\emwidth,
192 \c!before=,
193 \c!after=]
194
195\permanent\protected\def\setuptab{\setupdescription[tab]}
196
197
198
199\protect \endinput
200 |