1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16\writestatus{loading}{ConTeXt Backend Macros XML export}
17
18\newinteger\tagparcounter
19
20\registerctxluafile{backexp} {autosuffix}
21\registerctxluafile{backexpimptag}{autosuffix}
22\registerctxluafile{backexpimpmth}{autosuffix}
23\registerctxluafile{backexpimpref}{autosuffix}
24
25
26
27
28
29
30
31\unprotect
32
33
34
35
36\definesystemattribute[taggedpar][public]
37
38\permanent\tolerant\protected\def\setelementexporttag[#1]#*[#2]#*[#3]
39 {\ifarguments\or\or
40 \clf_settagproperty{#1}{export}{#2}
41 \or
42 \clf_settagproperty{#1}{#2}{#3}
43 \fi}
44
45
46
47\permanent\def\taggedctxcommand
48 {\iftrialtypesetting
49 \expandafter\gobbleoneargument
50 \else
51 \expandafter\ctxcommand
52 \fi}
53
54\permanent\protected\lettonothing\dotagsetparcounter
55\permanent\protected\lettonothing\doresetparcounter
56
57\appendtoks
58 \doresetparcounter
59\to \everyflushatnextpar
60
61
62
63
64
65\prependtoks
66 \dotagsetparcounter
67\to \everypar
68
69
70
71
72
73\prependtoks
74 \dotagsetparcounter
75\to \neverypar
76
77\appendtoks
78 \dotagsetparcounter
79\to \everytabulatepar
80
81\appendtoks
82 \enforced\permanent\protected\def\dotagTABLEcell
83 {\iftrialtypesetting\else
84 \clf_settagtablecell
85 \numexpr\tablecellrows\relax
86 \numexpr\tablecellcolumns\relax
87 \numexpr\raggedstatus\relax
88 \fi}
89
90 \enforced\permanent\protected\def\dotagTABLEsignal
91 {\signalcharacter}
92\to \everyenableelements
93
94\appendtoks
95 \enforced\permanent\protected\def\dotagtabulatecell
96 {\iftrialtypesetting\else
97 \clf_settagtabulatecell\c_tabl_tabulate_align\c_tabl_tabulate_kind
98 \fi}
99 \enforced\permanent\protected\def\dotagtabulatesignal
100 {\dontleavehmode\signalcharacter\ignorespaces\ignorepars}
101\to \everyenableelements
102
103\appendtoks
104 \enforced\permanent\protected\def\dotagsynonym
105 {\iftrialtypesetting\else\clf_settagsynonym{\currentsynonymtag}\fi}
106\to \everyenableelements
107
108\appendtoks
109 \enforced\permanent\protected\def\dotagsorting
110 {\iftrialtypesetting\else\clf_settagsorting{\currentsortingtag}\fi}
111\to \everyenableelements
112
113\appendtoks
114 \enforced\permanent\protected\def\dotagconstruct
115 {\iftrialtypesetting\else
116 \clf_settagconstruct
117 {\currentstartstop}
118 {\startstopparameter\c!style}
119 \c_attr_color
120 \ifvmode\plusone\else\zerocount\fi
121 \relax
122 \fi}
123\to \everyenableelements
124
125\appendtoks
126 \enforced\permanent\protected\def\dotaghighlight
127 {\iftrialtypesetting\else
128 \clf_settaghighlight
129 {\currenthighlight}
130 {\highlightparameter\c!style}
131 \c_attr_color
132 \ifvmode\plusone\else\zerocount\fi
133 \relax
134 \fi}
135\to \everyenableelements
136
137\appendtoks
138 \enforced\permanent\protected\def\dotagfigure
139 {\iftrialtypesetting\else
140 \clf_settagfigure
141 {\figurefileoriginal}
142 {\figurefullname}
143 {\figurefilepage}
144 \dimexpr\figurewidth\relax
145 \dimexpr\figureheight\relax
146 {\figurelabel}
147 \fi}
148\to \everyenableelements
149
150\appendtoks
151 \enforced\permanent\protected\def\dotagcombination
152 {\iftrialtypesetting\else
153 \clf_settagcombination
154 \numexpr\combinationparameter\c!nx\relax
155 \numexpr\combinationparameter\c!ny\relax
156 \fi}
157\to \everyenableelements
158
159\appendtoks
160 \enforced\permanent\protected\def\dotagsetparcounter
161 {\global\advanceby\tagparcounter\plusone\c_attr_taggedpar\tagparcounter}
162 \enforced\permanent\protected\def\doresetparcounter
163 {\c_attr_taggedpar\attributeunsetvalue}
164\to \everyenableelements
165
166\appendtoks
167 \enforced\permanent\protected\def\dotagsetitemgroup
168 {\iftrialtypesetting\else
169 \clf_settagitemgroup
170 \ifconditional\c_strc_itemgroups_pack true\else false\fi\space
171 \numexpr\currentitemlevel\relax
172 {\currentitemgroupsymbol}
173 \fi}
174 \enforced\permanent\protected\def\dotagsetitem#1
175 {\iftrialtypesetting\else
176 \clf_settagitem{#1}
177 \fi}
178\to \everyenableelements
179
180
181
182
183
184
185
186
187\appendtoks
188 \enforced\permanent\protected\def\dotagsetnotation
189 {\iftrialtypesetting\else
190 \clf_settagnotation{\currentnote}\currentnotenumber\relax
191 \fi}
192\to \everyenableelements
193
194\appendtoks
195 \enforced\permanent\protected\def\dotagsetnotesymbol
196 {\iftrialtypesetting\else
197 \clf_settagnotationsymbol{\currentnote}\currentnotenumber\relax
198 \fi}
199\to \everyenableelements
200
201\appendtoks
202 \enforced\permanent\protected\def\dotagregisterlocation
203 {\iftrialtypesetting\else
204 \clf_settagregister{\currentregister}\currentregisternumber\relax
205 \fi}
206\to \everyenableelements
207
208\appendtoks
209 \enforced\permanent\protected\def\dotaglistlocation
210 {\iftrialtypesetting\else
211 \clf_settaglist\currentlistindex\relax
212 \fi}
213\to \everyenableelements
214
215\appendtoks
216 \enforced\permanent\protected\def\dotagsetdelimitedsymbol#1
217 {\iftrialtypesetting\else
218 \clf_settagdelimitedsymbol{#1}\relax
219 \fi}
220\to \everyenableelements
221
222\appendtoks
223 \enforced\permanent\protected\def\dotagsetsubsentencesymbol#1
224 {\iftrialtypesetting\else
225 \clf_settagsubsentencesymbol{#1}\relax
226 \fi}
227\to \everyenableelements
228
229\appendtoks
230 \enforced\permanent\protected\def\dotagregisterfloat#1#2
231 {\iftrialtypesetting\else
232 \clf_settagfloat{#1}{#2}\relax
233 \fi}
234\to \everyenableelements
235
236\appendtoks
237 \enforced\let\specialfixedspace \explicitfixedspace
238 \enforced\let\specialobeyedspace \explicitobeyedspace
239 \enforced\let\specialstretchedspace\explicitstretchedspace
240 \enforced\let\specialcontrolspace \explicitcontrolspace
241\to \everyenableelements
242
243\appendtoks
244 \enforced\permanent\protected\def\dotagregisterformula#1
245 {\iftrialtypesetting\else
246 \clf_settagformulacontent#1\relax
247 \fi}
248\to \everyenableelements
249
250\appendtoks
251 \enforced\permanent\protected\def\dotagmarginanchor#1
252 {\iftrialtypesetting\else\clf_settagmarginanchor#1\relax\fi}
253 \enforced\permanent\protected\def\dotagmargintext#1
254 {\iftrialtypesetting\else\clf_settagmargintext#1\relax\fi}
255\to \everyenableelements
256
257\appendtoks
258 \enforced\permanent\protected\def\dotagpublication#1#2
259 {\iftrialtypesetting\else
260 \clf_settagpublication{#1}{#2}\relax
261 \fi}
262\to \everyenableelements
263
264\appendtoks
265 \enforced\permanent\protected\def\dotagparagraph#1
266 {\iftrialtypesetting\else
267 \clf_settagparagraph{#1}\relax
268 \fi}
269\to \everyenableelements
270
271
272
273\ifdefined\dotagcodepoint \else \aliased\let\dotagcodepoint\gobbletwoarguments \fi
274
275\appendtoks
276 \enforced\permanent\protected\def\dotagcodepoint#1#2
277 {\iftrialtypesetting\else
278 \clf_settagcodepoint{#1}#2\relax
279 \fi}
280\to \everyenableelements
281
282
283
284
285
286
287
288\installcorenamespace{export}
289
290\installparameterhandler \??export {export}
291\installsetuphandler \??export {export}
292
293\setupexport
294 [\c!align=\number\raggedstatus,
295 \c!bodyfont=\bodyfontsize,
296 \c!width=\textwidth,
297 \c!title={\directinteractionparameter\c!title},
298 \c!subtitle={\directinteractionparameter\c!subtitle},
299 \c!author={\directinteractionparameter\c!author},
300
301
302 \c!properties=\v!no,
303 \c!hyphen=\v!no,
304 \c!svgstyle=,
305 \c!cssfile=,
306 \c!file=]
307
308\resetsystemmode\v!export
309
310\permanent\protected\def\doinitializeexport
311 {\ifempty{\backendparameter\c!export}\else
312
313 \setuptagging[\c!state=\v!start]
314 \clf_initializeexport
315 \setsystemmode\v!export
316 \exportingtrue
317 \writestatus\m!backend\empty
318 \expand\everyinitializeexport
319 \writestatus\m!backend\empty
320 \enforced\glet\doinitializeexport\relax
321 \fi}
322
323\permanent\protected\def\dostartexport
324 {
325 \lettonothing\currentexport
326 \clf_setupexport
327 align {\exportparameter\c!align}
328 bodyfont \dimexpr\exportparameter\c!bodyfont\relax
329 width \dimexpr\exportparameter\c!width\relax
330 properties {\exportparameter\c!properties}
331 hyphen {\exportparameter\c!hyphen}
332 title {\exportparameter\c!title}
333 subtitle {\exportparameter\c!subtitle}
334 author {\exportparameter\c!author}
335 firstpage {\exportparameter\c!firstpage}
336 lastpage {\exportparameter\c!lastpage}
337 svgstyle {\exportparameter\c!svgstyle}
338 cssfile {\exportparameter\c!cssfile}
339 file {\exportparameter\c!file}
340 option {\exportparameter\c!option}
341 export {\backendparameter\c!export}
342 \relax}
343
344\permanent\protected\def\dostopexport
345 {\enforced\glet\dostopexport\relax
346 \clf_finishexport}
347
348\appendtoks
349 \doinitializeexport
350\to \everysetupbackend
351
352\appendtoks
353 \ifexporting
354 \dostartexport
355 \fi
356\to \everystarttext
357
358
359
360\appendtoks
361 \ifexporting
362 \dostopexport
363 \fi
364\to \everystoptext
365
366\appendtoks
367 \ifexporting
368 \dostartexport
369 \fi
370\to \everystartdocument
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418\installcorenamespace {boxexport}
419\installcorenamespace {mathexport}
420
421\installsetuponlycommandhandler \??boxexport {boxexport}
422\installsetuponlycommandhandler \??mathexport {mathexport}
423
424
425
426
427
428
429
430
431
432
433\permanent\tolerant\protected\def\startboxexport[#S#1]
434 {\begingroup
435 \ifempty{#1}
436 \letboxexportparameter\c!buffer\v!yes
437 \orelse\ifhastok={#1}\relax
438 \setupmathexport[#1]
439 \else
440 \setboxexportparameter\c!buffer{#1}
441 \fi
442 \setbox\nextbox\vbox\bgroup}
443
444\permanent\protected\def\stopboxexport
445 {\egroup
446 \clf_exportbox \nextbox
447 {\boxexportparameter\c!file}
448 {\boxexportparameter\c!buffer}
449 \endgroup}
450
451\permanent\tolerant\protected\def\startmathexport[#S#1]
452 {\begingroup
453 \ifempty{#1}
454 \letboxexportparameter\c!buffer\v!yes
455 \orelse\ifhastok={#1}\relax
456 \setupmathexport[#1]
457 \else
458 \setboxexportparameter\c!buffer{#1}
459 \fi
460 \clf_startcollectingmath}
461
462\permanent\protected\def\stopmathexport
463 {\clf_stopcollectingmath
464 \clf_processcollectedmath
465 {\boxexportparameter\c!file}
466 {\boxexportparameter\c!buffer}
467 \endgroup}
468
469
470
471
472
473
474\protect \endinput
475 |