1 ;; $Id: dbsect.dsl,v 1.8 2003/03/25 19:53:41 adicarlo Exp $
3 ;; This file is part of the Modular DocBook Stylesheet distribution.
4 ;; See ../README or http://docbook.sourceforge.net/projects/dsssl/
7 ;; ============================== SECTIONS ==============================
9 (define (SECTLEVEL #!optional (sect (current-node)))
10 (section-level-by-node (not nochunks) sect))
12 ;; BRIDGEHEAD isn't a proper section, but appears to be a section title
14 (let* ((renderas (attribute-string "renderas"))
15 ;; the apparent section level
17 ;; if not real section level, then get the apparent level
20 (section-level-by-gi (not nochunks) (normalize renderas))
21 ;; else use the real level
24 (string-append "H" (number->string hlevel))))
25 (make element gi: helem
26 attributes: '(("CLASS" "BRIDGEHEAD"))
28 attributes: (list (list "NAME" (element-id)))
32 (define ($section-separator$)
33 (let* (;; There are several situations in which we don't want a
35 ;; 1. This document is being chunked:
36 (chunks (not nochunks))
37 ;; 2. This node is the root element of the document:
38 (isroot (node-list=? (current-node) (sgml-root-element)))
39 ;; 3. This node is the first section in the root element
40 ;; and no other content (except the *info elements and
41 ;; the title) precedes it. This means that the
42 ;; titlepage-separator was the last thing we put out.
43 ;; No one expects two separators in a row, or the Spanish
45 (s1ofrt (node-list=? (parent (current-node)) (sgml-root-element)))
46 (precnd (ipreced (current-node)))
47 (infond (info-element (parent (current-node))))
48 (isfirst (or (equal? (gi precnd) (normalize "title"))
49 (node-list=? precnd infond))))
50 (if (or chunks isroot isfirst)
52 (make empty-element gi: "HR"))))
55 (html-document (with-mode head-title-mode
56 (literal (element-title-string (current-node))))
59 (define ($section-body$)
60 (make element gi: "DIV"
61 attributes: (list (list "CLASS" (gi)))
65 (if (not (node-list-empty? (select-elements (children (current-node))
66 (normalize "refentry"))))
67 (build-toc (current-node) 1)
72 (define ($section-title$)
73 (let* ((sect (current-node))
75 (subtitles (select-elements (children info) (normalize "subtitle")))
76 (renderas (inherited-attribute-string (normalize "renderas") sect))
77 ;; the apparent section level
79 ;; if not real section level, then get the apparent level
82 (section-level-by-gi (not nochunks) (normalize renderas))
83 ;; else use the real level
86 (string-append "H" (number->string hlevel)))
88 (string-append "H" (number->string (+ hlevel 1))))
90 (isep (gentext-intra-label-sep (gi sect)))
91 (nsep (gentext-label-title-sep (gi sect))))
93 (make element gi: h1elem
94 attributes: (list (list "CLASS" (gi sect)))
96 attributes: (list (list "NAME" name))
98 (if (string=? (element-label (current-node)) "")
100 (literal (element-label (current-node)) nsep))
101 (element-title-sosofo sect))))
102 (if (node-list-empty? subtitles)
104 (with-mode subtitle-mode
105 (make element gi: h2elem
106 (process-node-list subtitles))))
107 ($proc-section-info$ info))))
109 (define ($proc-section-info$ info)
110 (cond ((equal? (gi) (normalize "sect1"))
112 ((equal? (gi) (normalize "sect2"))
114 ((equal? (gi) (normalize "sect3"))
116 ((equal? (gi) (normalize "sect4"))
118 ((equal? (gi) (normalize "sect5"))
120 ((equal? (gi) (normalize "section"))
121 ($section-info$ info))
122 ((equal? (gi) (normalize "refsect1"))
123 ($refsect1-info$ info))
124 ((equal? (gi) (normalize "refsect2"))
125 ($refsect2-info$ info))
126 ((equal? (gi) (normalize "refsect3"))
127 ($refsect3-info$ info))
128 (else (empty-sosofo))))
130 (define ($sect1-info$ info) (empty-sosofo))
131 (define ($sect2-info$ info) (empty-sosofo))
132 (define ($sect3-info$ info) (empty-sosofo))
133 (define ($sect4-info$ info) (empty-sosofo))
134 (define ($sect5-info$ info) (empty-sosofo))
135 (define ($section-info$ info) (empty-sosofo))
136 (define ($refsect1-info$ info) (empty-sosofo))
137 (define ($refsect2-info$ info) (empty-sosofo))
138 (define ($refsect3-info$ info) (empty-sosofo))
140 (element section ($section$))
141 (element (section title) (empty-sosofo))
143 (element sect1 ($section$))
144 (element (sect1 title) (empty-sosofo))
146 (element sect2 ($section$))
147 (element (sect2 title) (empty-sosofo))
149 (element sect3 ($section$))
150 (element (sect3 title) (empty-sosofo))
152 (element sect4 ($section$))
153 (element (sect4 title) (empty-sosofo))
155 (element sect5 ($section$))
156 (element (sect5 title) (empty-sosofo))
158 (element simplesect ($section$))
159 (element (simplesect title) (empty-sosofo))