1
<!-- $FreeBSD: doc/share/sgml/freebsd.dsl,v 1.68 2002/11/20 19:41:10 ceri Exp $ -->
3
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
4
<!ENTITY % output.html "IGNORE">
5
<!ENTITY % output.html.images "IGNORE">
6
<!ENTITY % output.print "IGNORE">
7
<!ENTITY % output.print.pdf "IGNORE">
8
<!ENTITY % output.print.justify "IGNORE">
9
<!ENTITY % output.print.twoside "IGNORE">
12
<!ENTITY docbook.dsl PUBLIC "-//Norman Walsh//DOCUMENT DocBook HTML Stylesheet//EN" CDATA DSSSL>
15
<!ENTITY docbook.dsl PUBLIC "-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN" CDATA DSSSL>
21
<style-specification use="docbook">
22
<style-specification-body>
24
(declare-flow-object-class formatting-instruction
25
"UNREGISTERED::James Clark//Flow Object Class::formatting-instruction")
27
<!-- HTML only .................................................... -->
30
<!-- Configure the stylesheet using documented variables -->
32
(define %hyphenation% #f) <!-- Silence a warning -->
34
(define %gentext-nav-use-tables%
35
;; Use tables to build the navigation headers and footers?
39
;; Default extension for HTML output files
42
(define %shade-verbatim%
43
;; Should verbatim environments be shaded?
46
(define %use-id-as-filename%
47
;; Use ID attributes as name for component HTML files?
50
(define %root-filename%
51
;; Name for the root HTML document
58
(define %generate-legalnotice-link%
59
;; Should legal notices be a link to a separate file?
61
;; Naturally, this has no effect if you're building one big
65
(define (book-titlepage-recto-elements)
66
(list (normalize "title")
67
(normalize "subtitle")
69
(normalize "mediaobject")
70
(normalize "corpauthor")
71
(normalize "authorgroup")
74
(normalize "copyright")
75
(normalize "abstract")
76
(normalize "legalnotice")
79
<!-- This is the text to display at the bottom of each page.
80
Defaults to nothing. The individual stylesheets should
81
redefine this as necessary. -->
82
(define ($email-footer$)
85
(define html-index-filename
93
<!-- This code handles displaying $email-footer$ at the bottom
96
If "nochunks" is turned on then we make sure that an <hr>
99
Then create a centered paragraph ("<p>"), and reduce the font
100
size ("<small>"). Then run $email-footer$, which should
101
create the text and links as necessary. -->
102
(define ($html-body-end$)
103
(if (equal? $email-footer$ (normalize ""))
107
(make empty-element gi: "hr")
111
(define %refentry-xref-link%
112
;; REFENTRY refentry-xref-link
113
;; PURP Generate URL links when cross-referencing RefEntrys?
115
;; If true, a web link will be generated, presumably
116
;; to an online man->HTML gateway. The text of the link is
117
;; generated by the $create-refentry-xref-link$ function.
123
; Empty function to quiet warnings
124
(define ($create-refentry-xref-link$)
127
(element citerefentry
128
(let ((href ($create-refentry-xref-link$)))
129
(if %refentry-xref-link%
130
(create-link (list (list "HREF" href))
131
(if %refentry-xref-italic%
134
(if %refentry-xref-italic%
139
(let* ((class (attribute-string (normalize "role"))))
141
((equal? class "package")
142
(let* ((urlurl "http://www.FreeBSD.org/cgi/url.cgi")
143
(href (string-append urlurl "?ports/"
144
(data (current-node))
146
(create-link (list (list "HREF" href)) ($mono-seq$))))
147
(else ($mono-seq$)))))
149
;; Ensure that we start with no preferred mediaobject notations,
150
;; so that in the text-only case we don't choose any of the
151
;; possible images, and fallback to the most appropriate
153
(define preferred-mediaobject-notations
157
<!-- HTML with images ............................................ -->
159
<![ %output.html.images [
161
; The new Cascading Style Sheets for the HTML output are very confused
162
; by our images when used with div class="mediaobject". We can
163
; clear up the confusion by ignoring the whole mess and just
164
; displaying the image.
167
(make element gi: "P"
170
(define %graphic-default-extension%
173
(define %callout-graphics%
174
;; Use graphics in callouts?
177
(define %callout-graphics-ext%
178
;; The extension to use for callout images. This is an extension
179
;; to the stylesheets, they do not support this functionality
183
(define %callout-graphics-path%
184
;; Path to callout graphics
185
"./imagelib/callouts/")
187
;; Redefine $callout-bug$ to support the %callout-graphic-ext%
189
(define ($callout-bug$ conumber)
190
(let ((number (if conumber (format-number conumber "1") "0")))
192
(if %callout-graphics%
193
(if (<= conumber %callout-graphics-number-limit%)
194
(make empty-element gi: "IMG"
195
attributes: (list (list "SRC"
198
%callout-graphics-path%
200
%callout-graphics-ext%)))
207
(make element gi: "B"
208
(literal "(" (format-number conumber "1") ")")))
209
(make element gi: "B"
210
(literal "(" (format-number conumber "1") ")")))
211
(make element gi: "B"
215
<!-- Two-sided Print output ....................................... -->
216
<![ %output.print.twoside; [
218
;; From an email by Ian Castle to the DocBook-apps list
220
(define ($component$)
221
(make simple-page-sequence
222
page-n-columns: %page-n-columns%
223
page-number-restart?: (or %page-number-restart%
226
page-number-format: ($page-number-format$)
227
use: default-text-style
228
left-header: ($left-header$)
229
center-header: ($center-header$)
230
right-header: ($right-header$)
231
left-footer: ($left-footer$)
232
center-footer: ($center-footer$)
233
right-footer: ($right-footer$)
234
start-indent: %body-start-indent%
235
input-whitespace-treatment: 'collapse
236
quadding: %default-quadding%
242
;; From an email by Ian Castle to the DocBook-apps list
244
(define (first-part?)
245
(let* ((book (ancestor (normalize "book")))
246
(nd (ancestor-member (current-node)
248
(component-element-list)
249
(division-element-list))))
250
(bookch (children book)))
251
(let loop ((nl bookch))
252
(if (node-list-empty? nl)
254
(if (equal? (gi (node-list-first nl)) (normalize "part"))
255
(if (node-list=? (node-list-first nl) nd)
258
(loop (node-list-rest nl)))))))
261
;; From an email by Ian Castle to the DocBook-apps list
263
(define (first-chapter?)
264
;; Returns #t if the current-node is in the first chapter of a book
265
(if (has-ancestor-member? (current-node) (division-element-list))
267
(let* ((book (ancestor (normalize "book")))
268
(nd (ancestor-member (current-node)
269
(append (component-element-list)
270
(division-element-list))))
271
(bookch (children book))
272
(bookcomp (expand-children bookch (list (normalize "part")))))
273
(let loop ((nl bookcomp))
274
(if (node-list-empty? nl)
276
(if (equal? (gi (node-list-first nl)) (normalize "chapter"))
277
(if (node-list=? (node-list-first nl) nd)
280
(loop (node-list-rest nl))))))))
283
; By default, the Part I title page will be given a roman numeral,
284
; which is wrong so we have to fix it
286
(define (part-titlepage elements #!optional (side 'recto))
287
(let ((nodelist (titlepage-nodelist
288
(if (equal? side 'recto)
289
(part-titlepage-recto-elements)
290
(part-titlepage-verso-elements))
292
;; partintro is a special case...
293
(partintro (node-list-first
294
(node-list-filter-by-gi elements (list (normalize "partintro"))))))
295
(if (part-titlepage-content? elements side)
296
(make simple-page-sequence
297
page-n-columns: %titlepage-n-columns%
298
;; Make sure that page number format is correct.
299
page-number-format: ($page-number-format$)
300
;; Make sure that the page number is set to 1 if this is the first part
302
page-number-restart?: (first-part?)
303
input-whitespace-treatment: 'collapse
304
use: default-text-style
306
;; This hack is required for the RTF backend. If an
307
;; external-graphic is the first thing on the page,
308
;; RTF doesn't seem to do the right thing (the graphic
309
;; winds up on the baseline of the first line of the
310
;; page, left justified). This "one point rule" fixes
317
(let loop ((nl nodelist) (lastnode (empty-node-list)))
318
(if (node-list-empty? nl)
321
(if (or (node-list-empty? lastnode)
322
(not (equal? (gi (node-list-first nl))
324
(part-titlepage-before (node-list-first nl) side)
327
((equal? (gi (node-list-first nl)) (normalize "subtitle"))
328
(part-titlepage-subtitle (node-list-first nl) side))
329
((equal? (gi (node-list-first nl)) (normalize "title"))
330
(part-titlepage-title (node-list-first nl) side))
332
(part-titlepage-default (node-list-first nl) side)))
333
(loop (node-list-rest nl) (node-list-first nl)))))
334
(if (and %generate-part-toc%
335
%generate-part-toc-on-titlepage%
336
(equal? side 'recto))
338
(build-toc (current-node)
339
(toc-depth (current-node))))
342
;; PartIntro is a special case
343
(if (and (equal? side 'recto)
344
(not (node-list-empty? partintro))
345
%generate-partintro-on-titlepage%)
346
($process-partintro$ partintro #f)
352
<!-- Print with justification ..................................... -->
353
<![ %output.print.justify; [
355
(define %default-quadding%
358
(define %hyphenation%
362
;; The url.sty package is making all of the links purple/pink.
363
;; Someone please fix this!
366
(let ((%factor% (if %verbatim-size-factor%
367
%verbatim-size-factor%
370
font-family-name: %mono-font-family%
371
font-size: (* (inherited-font-size) %factor%)
372
(make formatting-instruction data:
375
(data (current-node))
379
(let ((%factor% (if %verbatim-size-factor%
380
%verbatim-size-factor%
383
font-family-name: %mono-font-family%
384
font-size: (* (inherited-font-size) %factor%)
385
(make formatting-instruction data:
388
(data (current-node))
391
;; Some others may check the value of %hyphenation% and be
408
<!-- Print only ................................................... -->
413
;; If a link is entered as "file://localhost/usr/ports" in the docs
414
;; then we only want to display "/usr/ports" in printed form.
416
(define (fix-url url)
417
(if (and (> (string-length url) 15)
418
(string=? (substring url 0 16) "file://localhost"))
419
(substring url 16 (string-length url))
423
(element (primaryie ulink)
424
(indexentry-link (current-node)))
425
(element (secondaryie ulink)
426
(indexentry-link (current-node)))
427
(element (tertiaryie ulink)
428
(indexentry-link (current-node)))
430
;; Override the count-footnote? definition from dbblock.dsl
431
;; to fix a bug. Basically, the original procedure would count
432
;; all ulink elements when doing %footnote-ulinks%. It's
433
;; actually harder than that, because ulink elements with no
434
;; content shouldn't generate footnotes (the ulink element
435
;; definition just inserts the url attribute in-line, thus there
436
;; is no need for a footnote with the url). So, when we figure
437
;; out which footnotes to count for the purpose of determining
438
;; footnote numbers, we only count the ulink elements containing
440
(define (count-footnote? footnote)
441
;; don't count footnotes in comments (unless you're showing comments)
442
;; or footnotes in tables which are handled locally in the table
443
(if (or (and (has-ancestor-member? footnote (list (normalize "comment")))
444
(not %show-comments%))
445
(has-ancestor-member? footnote (list (normalize "tgroup")))
446
(and (has-ancestor-member? footnote (list (normalize "ulink")))
447
(node-list-empty? (children footnote))))
453
(if (node-list-empty? (children (current-node)))
454
(literal (fix-url (attribute-string (normalize "url"))))
457
(if %footnote-ulinks%
458
(if (and (equal? (print-backend) 'tex) bop-footnotes)
460
($ss-seq$ + (literal (footnote-number (current-node))))
463
font-size: (* %footnote-size-factor% %bf-size%)
464
font-posture: 'upright
465
quadding: %default-quadding%
466
line-spacing: (* (* %footnote-size-factor% %bf-size%)
467
%line-spacing-factor%)
468
space-before: %para-sep%
469
space-after: %para-sep%
470
start-indent: %footnote-field-width%
471
first-line-start-indent: (- %footnote-field-width%)
473
field-width: %footnote-field-width%
474
(literal (footnote-number (current-node))
475
(gentext-label-title-sep (normalize "footnote"))))
476
(literal (fix-url (attribute-string (normalize "url")))))))
477
($ss-seq$ + (literal (footnote-number (current-node)))))
478
(if (and %show-ulinks%
479
(not (equal? (fix-url (attribute-string (normalize "url")))
480
(data-of (current-node)))))
484
(make formatting-instruction data:
485
(string-append "\\url{"
486
(fix-url (attribute-string
489
(literal (fix-url (attribute-string (normalize "url")))))
494
(define (toc-depth nd)
495
(if (string=? (gi nd) (normalize "book"))
499
(element programlisting
500
(if (and (equal? (attribute-string (normalize "role")) "pgpkey")
505
(define %body-start-indent%
508
(define (book-titlepage-verso-elements)
509
(list (normalize "title")
510
(normalize "subtitle")
511
(normalize "corpauthor")
512
(normalize "authorgroup")
515
(normalize "edition")
516
(normalize "pubdate")
517
(normalize "copyright")
518
(normalize "abstract")
519
(normalize "legalnotice")
520
(normalize "revhistory")
523
;; Norm's stylesheets are smart about working out what sort of
524
;; object to display. But this bites us. Since we know that the
525
;; first item is going to be displayable, always use that.
526
(define (find-displayable-object objlist notlist extlist)
527
(let loop ((nl objlist))
528
(if (node-list-empty? nl)
530
(let* ((objdata (node-list-filter-by-gi
531
(children (node-list-first nl))
532
(list (normalize "videodata")
533
(normalize "audiodata")
534
(normalize "imagedata"))))
535
(filename (data-filename objdata))
536
(extension (file-extension filename))
537
(notation (attribute-string (normalize "format") objdata)))
538
(node-list-first nl)))))
540
;; When selecting a filename to use, don't append the default
541
;; extension, instead, just use the bare filename, and let TeX
542
;; work it out. jadetex will use the .eps file, while pdfjadetex
543
;; will use the .png file automatically.
544
(define (graphic-file filename)
545
(let ((ext (file-extension filename)))
546
(if (or tex-backend ;; TeX can work this out itself
548
(not %graphic-default-extension%)
549
(member ext %graphic-extensions%))
551
(string-append filename "." %graphic-default-extension%))))
553
;; Including bitmaps in the PS and PDF output tends to scale them
554
;; horribly. The solution is to scale them down by 50%.
556
;; You could do this with 'imagedata scale="50"' in the source,
557
;; but that will affect all the output formats that we use (because
558
;; there is only one 'imagedata' per image).
560
;; Solution is to have the authors include the "FORMAT" attribute,
561
;; set to PNG or EPS as appropriate, but to omit the extension.
562
;; If we're using the tex-backend, and the FORMAT is PNG, and the
563
;; author hasn't already set a scale, then set scale to 0.5.
564
;; Otherwise, use the supplied scale, or 1, as appropriate.
565
(define ($graphic$ fileref
566
#!optional (display #f) (format #f)
567
(scale #f) (align #f))
568
(let* ((graphic-format (if format format ""))
569
(graphic-scale (if scale
570
(/ (string->number scale) 100)
572
(equal? graphic-format "PNG"))
574
(graphic-align (cond ((equal? align (normalize "center"))
576
((equal? align (normalize "right"))
580
(make external-graphic
581
entity-system-id: (graphic-file fileref)
582
notation-system-id: graphic-format
585
display-alignment: graphic-align)))
588
<![ %output.print.pdf; [
592
<!-- Both sets of stylesheets ..................................... -->
594
(define %section-autolabel%
597
(define %label-preface-sections%
600
(define %may-format-variablelist-as-table%
603
(define %indent-programlisting-lines%
606
(define %indent-screen-lines%
609
(define (article-titlepage-recto-elements)
610
(list (normalize "title")
611
(normalize "subtitle")
612
(normalize "corpauthor")
613
(normalize "authorgroup")
615
(normalize "releaseinfo")
616
(normalize "copyright")
617
(normalize "pubdate")
618
(normalize "revhistory")
619
(normalize "legalnotice")
620
(normalize "abstract")))
622
(define %admon-graphics%
623
;; Use graphics in admonitions?
626
(define %admon-graphics-path%
627
;; Path to admonition images
630
(define ($admon-graphic$ #!optional (nd (current-node)))
631
;; Admonition graphic file
632
(string-append %admon-graphics-path% (case-fold-down (gi nd)) ".png"))
634
<!-- Slightly deeper customisations -->
636
<!-- We would like the author attributions to show up in line
637
with the section they refer to. Authors who made the same
638
contribution should be listed in a single <authorgroup> and
639
only one of the <author> elements should contain a <contrib>
640
element that describes what the whole authorgroup was
641
responsible for. For example:
646
<firstname>Bob</firstname>
647
<surname>Jones</surname>
648
<contrib>Contributed by </contrib>
651
<firstname>Sarah</firstname>
652
<surname>Lee</surname>
657
Would show up as "Contributed by Bob Jones and Sarah Lee". Each
658
authorgroup shows up as a separate sentence. -->
673
(element (chapterinfo authorgroup author)
674
(literal (author-list-string)))
675
(element (sect1info authorgroup author)
676
(literal (author-list-string)))
677
(element (sect2info authorgroup author)
678
(literal (author-list-string)))
679
(element (sect3info authorgroup author)
680
(literal (author-list-string)))
681
(element (sect4info authorgroup author)
682
(literal (author-list-string)))
683
(element (sect5info authorgroup author)
684
(literal (author-list-string)))
686
(define (custom-authorgroup)
689
(process-node-list (select-elements (descendants (current-node))
690
(normalize "contrib")))
694
(element (chapterinfo authorgroup)
695
(custom-authorgroup))
696
(element (sect1info authorgroup)
697
(custom-authorgroup))
698
(element (sect2info authorgroup)
699
(custom-authorgroup))
700
(element (sect3info authorgroup)
701
(custom-authorgroup))
702
(element (sect4info authorgroup)
703
(custom-authorgroup))
704
(element (sect5info authorgroup)
705
(custom-authorgroup))
707
<!-- I want things marked up with 'sgmltag' eg.,
709
<para>You can use <sgmltag>para</sgmltag> to indicate
712
to automatically have the opening and closing braces inserted,
713
and it should be in a mono-spaced font. -->
715
(element sgmltag ($mono-seq$
721
<!-- Add double quotes around <errorname> text. -->
725
<![ %output.html; [ (literal "``") ]]>
726
($mono-seq$ (process-children))
727
<![ %output.html; [ (literal "''") ]]>
730
<!-- John Fieber's 'instant' translation specification had
731
'<command>' rendered in a mono-space font, and '<application>'
734
Norm's stylesheet doesn't do this (although '<command>' is
737
Configure the stylesheet to behave more like John's. -->
739
(element command ($mono-seq$))
740
(element envar ($mono-seq$))
742
(element application ($bold-seq$))
744
<!-- Warnings and cautions are put in boxed tables to make them stand
745
out. The same effect can be better achieved using CSS or similar,
746
so have them treated the same as <important>, <note>, and <tip>
748
(element warning ($admonition$))
749
(element (warning title) (empty-sosofo))
750
(element (warning para) ($admonpara$))
751
(element (warning simpara) ($admonpara$))
752
(element caution ($admonition$))
753
(element (caution title) (empty-sosofo))
754
(element (caution para) ($admonpara$))
755
(element (caution simpara) ($admonpara$))
757
<!-- Tell the stylesheet about our local customisations -->
763
(element username ($mono-seq$))
764
(element groupname ($mono-seq$))
765
(element devicename ($mono-seq$))
766
(element maketarget ($mono-seq$))
767
(element makevar ($mono-seq$))
769
<!-- Override generate-anchor. This is used to generate a unique ID for
770
each element that can be linked to. The element-id function calls
771
this one if there's no ID attribute that it can use. Normally, we
772
would just use the current element number. However, if it's a
773
a question then use the question's number, as determined by the
774
question-answer-label function.
776
This generates anchors of the form "Qx.y.", where x.y is the
777
question label. This will probably break if question-answer-label
778
is changed to generate something that might be the same for two
779
different questions (for example, if question numbering restarts
780
for each qandaset. -->
781
(define (generate-anchor #!optional (nd (current-node)))
783
((equal? (gi nd) (normalize "question"))
784
(string-append "Q" (question-answer-label)))
786
(string-append "AEN" (number->string (all-element-number nd))))))
788
(define (xref-biblioentry target)
789
(let* ((abbrev (node-list-first
790
(node-list-filter-out-pis (children target))))
791
(label (attribute-string (normalize "xreflabel") target)))
793
(if biblio-xref-title
794
(let* ((citetitles (select-elements (descendants target)
795
(normalize "citetitle")))
796
(titles (select-elements (descendants target)
797
(normalize "title")))
798
(isbn (select-elements (descendants target)
800
(publisher (select-elements (descendants target)
801
(normalize "publishername")))
802
(title (if (node-list-empty? citetitles)
803
(node-list-first titles)
804
(node-list-first citetitles))))
805
(with-mode xref-title-mode
807
(process-node-list title))))
810
(literal "[" (number->string (bibentry-number target)) "]"))
813
(literal "[" label "]"))
814
(if (equal? (gi abbrev) (normalize "abbrev"))
816
(process-node-list abbrev))
818
(literal "[" (id target) "]"))))))))
820
<!-- The (create-link) procedure should be used by all FreeBSD
821
stylesheets to create links. It calls (can-link-here) to
822
determine whether it's okay to make a link in the current
825
This check is necessary because links aren't allowed in,
826
for example, <question> tags since the latter cause links
827
to be created by themselves. Obviously, nested links lead
828
to all kinds of evil. This normally wouldn't be a problem
829
since no one in their right mind will put a <ulink> or
830
<link> in a <question>, but it comes up when someone uses,
831
say, a man page entity (e.g., &man.ls.1;); the latter may
832
cause a link to be created, but its use inside a <question>
835
The (can-link-here) routine isn't perfect; in fact, it's a
836
hack and an ugly one at that. Ideally, it would detect if
837
the currect output would wind up in an <a> tag and return
838
#f if that's the case. Slightly less ideally it would
839
check the current mode and return #f if, say, we're
840
currently in TOC mode. Right now, it makes a best guess
841
attempt at guessing which tags might cause links to be
843
(define (can-link-here)
844
(cond ((has-ancestor-member? (current-node)
845
'("TITLE" "QUESTION")) #f)
848
(define (create-link attrlist target)
850
(make element gi: "A"
854
</style-specification-body>
855
</style-specification>
857
<external-specification id="docbook" document="docbook.dsl">