Debian Codegraph @

ru/stylesheets/nuthtml.dsl

raw
1 <!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
2 <!ENTITY docbook.dsl PUBLIC "-//Norman Walsh//DOCUMENT DocBook HTML Stylesheet//EN" CDATA dsssl>
3 ]>
4
5 <style-sheet>
6 <style-specification id="html" use="docbook">
7 <style-specification-body>
8
9 (define %default-variablelist-termlength% 0)
10
11 (define %stylesheet% "dbtdg.css")
12
13 (define show-comments #f)
14 (define html-help #f)
15 (define %html-ext% ".html")
16
17 (define (chunk-element-list)
18 (list (normalize "preface")
19 (normalize "chapter")
20 (normalize "appendix")
21 (normalize "article")
22 (normalize "glossary")
23 (normalize "bibliography")
24 (normalize "index")
25 (normalize "colophon")
26 (normalize "setindex")
27 (normalize "reference")
28 (normalize "refentry")
29 (normalize "part")
30 (normalize "book") ;; just in case nothing else matches...
31 (normalize "set") ;; sets are definitely chunks...
32 ))
33
34 (define (nav-banner elemnode)
35 (let* ((root (sgml-root-element))
36 (title (book-title root))
37 (info (select-elements (children root) (normalize "bookinfo")))
38 (subtitle (select-elements (children info) (normalize "subtitle"))))
39 (with-mode xref-title-mode
40 (make sequence
41 (process-node-list title)
42 (literal ": ")
43 (process-node-list subtitle)))))
44
45 (define read-entity
46 (external-procedure "UNREGISTERED::James Clark//Procedure::read-entity"))
47
48 (element emphasis
49 (if (equal? (attribute-string (normalize "role")) "bold")
50 ($bold-seq$)
51 ($italic-seq$)))
52
53 (element command
54 ($italic-seq$))
55
56 (define %section-autolabel% #t)
57 (define %chapter-autolabel% #t)
58
59 (define %generate-legalnotice-link% #t)
60
61 (define %admon-graphics% #t)
62 (define %admon-graphics-path% "figures/")
63
64 (define ($html-body-end$)
65 (let* ((book (ancestor-member (current-node) (list (normalize "book"))))
66 (info (select-elements (children book) (normalize "bookinfo")))
67 (notice (select-elements (children info) (normalize "legalnotice"))))
68 (make element gi: "P"
69 (if (node-list-empty? notice)
70 (literal "Copyright")
71 (make element gi: "A"
72 attributes: (list
73 (list "HREF"
74 ($legalnotice-link-file$
75 (node-list-first notice))))
76 (literal "Copyright")))
77 (literal " ")
78 (make entity-ref name: "copy")
79 (literal " 1999 O'Reilly ")
80 (make entity-ref name: "amp")
81 (literal " Associates, Inc. All rights reserved.")
82
83 )))
84
85 (define %graphic-default-extension% "gif")
86
87 ;; ======================================================================
88
89 (element informalexample
90 (let ((role (attribute-string (normalize "role"))))
91 (if (or (equal? role "example-source")
92 (equal? role "example-output"))
93 (make element gi: "DIV"
94 attributes: (list (list "CLASS" role))
95 (process-children))
96 (next-match))))
97
98 ;; HACK HACK HACK. Get synchronous HTML markup from asynchronous DocBook!
99 (element anchor
100 (let ((role (attribute-string (normalize "role"))))
101 (if (equal? role "HACK-ex.out.start")
102 (make formatting-instruction
103 data: "&#60;DIV CLASS=\"example-output\">")
104 (if (equal? role "HACK-ex.out.end")
105 (make formatting-instruction
106 data: "&#60;/DIV>")
107 (next-match)))))
108
109 ;; ======================================================================
110
111 (element informaltable
112 (if (equal? (attribute-string (normalize "role")) "elemsynop")
113 ($element-synopsis$)
114 ($informal-object$)))
115
116 (define ($element-synopsis$)
117 (let* ((table (current-node))
118 (rows (select-elements (descendants table) (normalize "row"))))
119 (with-mode elemsynop (process-node-list rows))))
120
121 (mode elemsynop
122 (element (entry emphasis)
123 (if (equal? (attribute-string (normalize "role")) "bold")
124 ($charseq$)
125 ($italic-seq$)))
126
127 (element row
128 (let* ((entries (select-elements (children (current-node))
129 (normalize "entry")))
130 (entry (node-list-first entries))
131 (entry2 (node-list-first (node-list-rest entries))))
132 (case (attribute-string (normalize "role"))
133 (("cmtitle")
134 (make element gi: "H3"
135 (process-node-list (children entry))))
136 (("cmsynop")
137 (process-node-list (children entry)))
138 (("incltitle")
139 (make element gi: "H3"
140 (process-node-list (children entry))))
141 (("inclsynop")
142 (process-node-list (children entry)))
143 (("excltitle")
144 (make element gi: "H3"
145 (process-node-list (children entry))))
146 (("exclsynop")
147 (process-node-list (children entry)))
148 (("attrtitle")
149 (make sequence
150 (make element gi: "H3"
151 (process-node-list (children entry)))
152 (make element gi: "P"
153 (process-node-list (children entry2)))))
154 (("attrheader")
155 (make sequence
156 ;; we got some work to do here...
157 (let* ((rows (select-elements (children (parent (current-node)))
158 (normalize "row")))
159 (attrrows (let loop ((nl rows) (attr (empty-node-list)))
160 (if (node-list-empty? nl)
161 attr
162 (if (equal? (attribute-string
163 (normalize "role")
164 (node-list-first nl))
165 "attr")
166 (loop (node-list-rest nl)
167 (node-list attr
168 (node-list-first nl)))
169 (loop (node-list-rest nl) attr))))))
170 (make element gi: "TABLE"
171 attributes: '(("BORDER" "1")
172 ("WIDTH" "100%"))
173 (make element gi: "TR"
174 (process-children))
175 (let loop ((nl attrrows))
176 (if (node-list-empty? nl)
177 (empty-sosofo)
178 (make sequence
179 (make element gi: "TR"
180 (process-node-list
181 (children (node-list-first nl))))
182 (loop (node-list-rest nl)))))))))
183 (("attr") (empty-sosofo))
184 (("tmtitle")
185 (make element gi: "H3"
186 (process-node-list (children entry))))
187 (("tmsynop")
188 (process-node-list (children entry)))
189 (("petitle")
190 (make sequence
191 (make element gi: "H3"
192 (process-node-list (children entry)))
193
194 ;; we got some work to do here...
195 (let* ((rows (select-elements (children (parent (current-node)))
196 (normalize "row")))
197 (attrrows (let loop ((nl rows) (attr (empty-node-list)))
198 (if (node-list-empty? nl)
199 attr
200 (if (equal? (attribute-string
201 (normalize "role")
202 (node-list-first nl))
203 "pe")
204 (loop (node-list-rest nl)
205 (node-list attr
206 (node-list-first nl)))
207 (loop (node-list-rest nl) attr))))))
208 (make element gi: "TABLE"
209 attributes: '(("BORDER" "0")
210 ("WIDTH" "100%"))
211 (let loop ((nl attrrows))
212 (if (node-list-empty? nl)
213 (empty-sosofo)
214 (make sequence
215 (make element gi: "TR"
216 (process-node-list
217 (children (node-list-first nl))))
218 (loop (node-list-rest nl)))))))))
219 (("pe") (empty-sosofo))
220 (("vle-pe") (empty-sosofo))
221 (("vle-petitle")
222 (make sequence
223 (make element gi: "P"
224 (make element gi: "B"
225 (process-node-list (children entry))))
226
227 ;; we got some work to do here...
228 (let* ((rows (select-elements (children (parent (current-node)))
229 (normalize "row")))
230 (attrrows (let loop ((nl rows) (attr (empty-node-list)))
231 (if (node-list-empty? nl)
232 attr
233 (if (equal? (attribute-string
234 (normalize "role")
235 (node-list-first nl))
236 "vle-pe")
237 (loop (node-list-rest nl)
238 (node-list attr
239 (node-list-first nl)))
240 (loop (node-list-rest nl) attr))))))
241 (make element gi: "TABLE"
242 attributes: '(("BORDER" "0")
243 ("WIDTH" "100%"))
244 (let loop ((nl attrrows))
245 (if (node-list-empty? nl)
246 (empty-sosofo)
247 (make sequence
248 (make element gi: "TR"
249 (process-node-list
250 (children (node-list-first nl))))
251 (loop (node-list-rest nl)))))))))
252 (("vle-cmtitle")
253 (make element gi: "P"
254 (make element gi: "B"
255 (literal "Parameter entity content:")))))))
256
257 (element entry
258 (let ((tablegi (if (equal? (attribute-string (normalize "role")) "TH")
259 "TH"
260 "TD")))
261 (make element gi: tablegi
262 attributes: '(("ALIGN" "LEFT")
263 ("VALIGN" "TOP")
264 ("WIDTH" "33%"))
265 (process-children)))))
266
267 ;; ======================================================================
268
269 (element (entry simplelist)
270 (make element gi: "P"
271 (process-children)))
272
273 (element (entry simplelist member)
274 (make sequence
275 (if (equal? (child-number) 1)
276 (empty-sosofo)
277 (make empty-element gi: "BR"))
278 (process-children)))
279
280 (element (varlistentry term)
281 (make sequence
282 (make element gi: "B"
283 (process-children-trim))
284 (if (not (last-sibling?))
285 (literal ", ")
286 (literal ""))))
287
288 (element sgmltag
289 (let* ((class (if (attribute-string (normalize "class"))
290 (attribute-string (normalize "class"))
291 (normalize "element")))
292 (role (attribute-string "role"))
293 (content (data (current-node)))
294 (linkend (if (equal? class (normalize "paramentity"))
295 ;; hack; some of the paramentity ids don't start
296 ;; with dbre...
297 (if (node-list-empty? (element-with-id
298 (string-append "dbre.pent."
299 content)))
300 (string-append "pent." content)
301 (string-append "dbre.pent." content))
302 (string-append "dbre.elem." content)))
303 (target (if (equal? role "NOLINK")
304 (empty-node-list)
305 (element-with-id linkend)))
306 ; (err (if (and (not (equal? role "NOLINK"))
307 ; (node-list-empty? target))
308 ; (debug (string-append
309 ; "Unresolved SGMLTAG (CLASS="
310 ; class
311 ; "): "
312 ; content))
313 ; "")))
314 )
315 <![CDATA[
316 (cond
317 ((equal? class (normalize "attribute")) ($charseq$))
318 ((equal? class (normalize "attvalue")) ($mono-seq$))
319
320 ((equal? class (normalize "element"))
321 (if (or (has-ancestor-member? (current-node)
322 (list (normalize "link")))
323 (node-list-empty? target))
324 ($mono-seq$)
325 (make element gi: "A"
326 attributes: (list (list "HREF" (href-to target)))
327 ($mono-seq$))))
328
329 ((equal? class (normalize "endtag")) ($mono-seq$ (make sequence
330 (literal "</")
331 (process-children)
332 (literal ">"))))
333 ((equal? class (normalize "genentity")) ($mono-seq$ (make sequence
334 (literal "&")
335 (process-children)
336 (literal ";"))))
337 ((equal? class (normalize "numcharref")) ($mono-seq$ (make sequence
338 (literal "&#")
339 (process-children)
340 (literal ";"))))
341 ((equal? class (normalize "paramentity"))
342 (if (or (has-ancestor-member? (current-node)
343 (list (normalize "link")))
344 (node-list-empty? target))
345 ($mono-seq$ (make element gi: "NOBR"
346 (literal "%")
347 (process-children)
348 (literal ";")))
349 (make element gi: "A"
350 attributes: (list (list "HREF" (href-to target)))
351 ($mono-seq$ (make element gi: "NOBR"
352 (literal "%")
353 (process-children)
354 (literal ";"))))))
355
356 ((equal? class (normalize "pi"))
357 ($mono-seq$ (make element gi: "NOBR"
358 (literal "<?")
359 (process-children)
360 (literal "?>"))))
361 ((equal? class (normalize "starttag"))
362 ($mono-seq$ (make element gi: "NOBR"
363 (literal "<")
364 (process-children)
365 (literal ">"))))
366 ((equal? class (normalize "sgmlcomment"))
367 ($mono-seq$ (make element gi: "NOBR"
368 (literal "<!--")
369 (process-children)
370 (literal "-->"))))
371 ]]>
372 (else ($charseq$)))))
373
374 (element ulink
375 (let ((role (attribute-string "role")))
376 (if (equal? (normalize role) (normalize "embed"))
377 (let ((content (read-entity (attribute-string "url"))))
378 (make element gi: "PRE"
379 (literal content)))
380 (make element gi: "A"
381 attributes: (list
382 (list "HREF" (attribute-string (normalize "url")))
383 (list "TARGET" "_top"))
384 (process-children)))))
385
386 ;; fix the title page
387
388 (define (book-titlepage-recto-elements)
389 (list (normalize "title")
390 (normalize "subtitle")
391 (normalize "corpauthor")
392 (normalize "authorgroup")
393 (normalize "author")
394 (normalize "releaseinfo")
395 (normalize "pubdate")
396 (normalize "copyright")
397 (normalize "legalnotice")
398 (normalize "publisher")))
399
400 (define (book-titlepage-separator side)
401 (if (equal? side 'recto)
402 (if html-help
403 (empty-sosofo)
404 (make empty-element gi: "HR"))
405 (empty-sosofo)))
406
407 (mode book-titlepage-recto-mode
408 (element title
409 (make sequence
410 (make element gi: "H1"
411 attributes: (list (list "CLASS" (gi))
412 (list "ALIGN" "CENTER"))
413 (make element gi: "A"
414 attributes: (list (list "NAME" (element-id)))
415 (process-children-trim)))))
416
417 (element subtitle
418 (make element gi: "H2"
419 attributes: (list (list "CLASS" (gi))
420 (list "ALIGN" "CENTER"))
421 (process-children-trim)))
422
423 (element authorgroup
424 (make sequence
425 (process-children)))
426
427 (element author
428 (let ((author-name (author-string))
429 (author-affil (select-elements (children (current-node))
430 (normalize "affiliation"))))
431 (make sequence
432 (if (first-sibling? (current-node))
433 (make element gi: "P"
434 attributes: '(("ALIGN" "CENTER"))
435 (make element gi: "I"
436 (make element gi: "FONT"
437 attributes: '(("SIZE" "-1"))
438 (literal "by"))))
439 (empty-sosofo))
440
441 (if (last-sibling? (current-node))
442 (make element gi: "P"
443 attributes: '(("ALIGN" "CENTER"))
444 (make element gi: "I"
445 (make element gi: "FONT"
446 attributes: '(("SIZE" "-1"))
447 (literal "and"))))
448 (empty-sosofo))
449
450 (make element gi: "H3"
451 attributes: (list (list "CLASS" (gi))
452 (list "ALIGN" "CENTER"))
453 (literal author-name))
454 (process-node-list author-affil))))
455
456 (element pubdate
457 (make sequence
458 (make element gi: "H4"
459 attributes: '(("ALIGN" "CENTER"))
460 (process-children))))
461
462 (element releaseinfo
463 (make sequence
464 (make element gi: "H4"
465 attributes: '(("ALIGN" "CENTER"))
466 (process-children))))
467
468 (element copyright
469 (let ((years (select-elements (descendants (current-node))
470 (normalize "year")))
471 (holders (select-elements (descendants (current-node))
472 (normalize "holder")))
473 (legalnotice (select-elements (children (parent (current-node)))
474 (normalize "legalnotice"))))
475 (make element gi: "P"
476 attributes: (list
477 (list "CLASS" (gi))
478 (list "ALIGN" "CENTER"))
479 (if (and %generate-legalnotice-link%
480 (not (node-list-empty? legalnotice)))
481 (make sequence
482 (make element gi: "A"
483 attributes: (list
484 (list "HREF"
485 ($legalnotice-link-file$
486 (node-list-first legalnotice))))
487 (literal (gentext-element-name (gi (current-node)))))
488 (literal " ")
489 (literal (dingbat "copyright"))
490 (literal " ")
491 (process-node-list years)
492 (literal (string-append " " (gentext-by) " "))
493 (process-node-list holders))
494 (make sequence
495 (literal (gentext-element-name (gi (current-node))))
496 (literal " ")
497 (literal (dingbat "copyright"))
498 (literal " ")
499 (process-node-list years)
500 (literal (string-append " " (gentext-by) " "))
501 (process-node-list holders))))))
502
503 (element publisher
504 (let* ((cities (select-elements (descendants (current-node))
505 (normalize "city")))
506 (firstcity (node-list-first cities))
507 (restcities (node-list-rest cities)))
508 (make element gi: "p"
509 attributes: '(("class" "publisher"))
510 (process-node-list firstcity)
511 (let loop ((cities restcities))
512 (if (node-list-empty? cities)
513 (empty-sosofo)
514 (make sequence
515 (literal " * ")
516 (process-node-list (node-list-first cities))
517 (loop (node-list-rest cities))))))))
518
519 (element city
520 (process-children))
521
522 )
523
524 (define ($refentry-body$)
525 (let* ((role (attribute-string (normalize "role") (current-node)))
526 (rev (attribute-string (normalize "revision") (current-node)))
527 (imgf (cond
528 ((equal? rev "3.1") "figures/rev_3.1.gif")
529 ((equal? rev "4.0") "figures/rev_4.0.gif")
530 ((equal? rev "5.0") "figures/rev_5.0.gif")
531 (else "MISSING_REVISION_FIGURE"))))
532 (make sequence
533 (make element gi: "H1"
534 (if (equal? role "new")
535 (make sequence
536 (make empty-element gi: "IMG"
537 attributes: (list (list "SRC" imgf)
538 (list "ALT"
539 (string-append "(" rev ")"))))
540 (make entity-ref name: "nbsp"))
541 (empty-sosofo))
542 (element-title-sosofo (current-node)))
543 (process-children))))
544
545 (element (refsect2 title)
546 (let* ((role (attribute-string (normalize "role") (parent (current-node))))
547 (rev (attribute-string (normalize "revision")
548 (parent (current-node))))
549 (imgf (cond
550 ((equal? rev "3.1") "figures/rev_3.1.gif")
551 ((equal? rev "4.0") "figures/rev_4.0.gif")
552 ((equal? rev "5.0") "figures/rev_5.0.gif")
553 (else "MISSING_REVISION_FIGURE")))
554 (tgi "H3"))
555 (make element gi: tgi
556 (if (equal? role "fu")
557 (make sequence
558 (make empty-element gi: "IMG"
559 attributes: (list (list "SRC" imgf)
560 (list "ALT"
561 (string-append "(" rev ")"))))
562 (make entity-ref name: "nbsp"))
563 (empty-sosofo))
564 (process-children))))
565
566 (element (appendix bibliography)
567 (make sequence
568 (make element gi: "A"
569 attributes: (list (list "NAME" (element-id)))
570 (empty-sosofo))
571 (bibliography-content)))
572
573 (element comment
574 (if show-comments
575 (make element gi: "P"
576 attributes: '(("CLASS" "COMMENT"))
577 (make element gi: "FONT"
578 attributes: '(("COLOR" "RED"))
579 (process-children)))
580 (empty-sosofo)))
581
582 </style-specification-body>
583 </style-specification>
584
585 <external-specification id="docbook" document="docbook.dsl">
586
587 </style-sheet>