| 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 |
<!ENTITY dbautoc.dsl SYSTEM "hhautoc.dsl"> |
| 4 |
]> |
| 5 |
|
| 6 |
<style-sheet> |
| 7 |
<style-specification use="docbook"> |
| 8 |
<style-specification-body> |
| 9 |
|
| 10 |
;; $Id$ |
| 11 |
|
| 12 |
(define (extract-gi args) |
| 13 |
(let ((gi (member gi: args))) |
| 14 |
(if gi |
| 15 |
(car (cdr gi)) |
| 16 |
""))) |
| 17 |
|
| 18 |
(define (extract-node args) |
| 19 |
(let ((node (member node: args))) |
| 20 |
(if node |
| 21 |
(car (cdr node)) |
| 22 |
#f))) |
| 23 |
|
| 24 |
(define (extract-attributes args) |
| 25 |
(let ((attr (member attributes: args))) |
| 26 |
(if attr |
| 27 |
(car (cdr attr)) |
| 28 |
'()))) |
| 29 |
|
| 30 |
(define (extract-sosofos args) |
| 31 |
(let loop ((l args) (results '())) |
| 32 |
(if (null? l) |
| 33 |
results |
| 34 |
(if (not (keyword? (car l))) |
| 35 |
(loop (cdr l) (append results (list (car l)))) |
| 36 |
(loop (cdr (cdr l)) results))))) |
| 37 |
|
| 38 |
(define (make-element #!rest args) |
| 39 |
;; Args _MUST_ be '( gi: "gi" attributes: '() sosofo...) where sosofo |
| 40 |
;; is optional. |
| 41 |
(let* ((node (if (extract-node args) |
| 42 |
(extract-node args) |
| 43 |
(current-node))) |
| 44 |
(giname (extract-gi args)) |
| 45 |
(attr (extract-attributes args)) |
| 46 |
(sosofo (extract-sosofos args))) |
| 47 |
(sosofo-append |
| 48 |
(make formatting-instruction data: (string-append "<" giname)) |
| 49 |
(if (null? attr) |
| 50 |
(empty-sosofo) |
| 51 |
(let loop ((a attr)) |
| 52 |
(if (null? a) |
| 53 |
(empty-sosofo) |
| 54 |
(make sequence |
| 55 |
(let* ((attrlist (car a)) |
| 56 |
(name (car attrlist)) |
| 57 |
(value (car (cdr attrlist)))) |
| 58 |
(make formatting-instruction |
| 59 |
data: (string-append " " name "=\"" (if value value "whatthe") "\""))) |
| 60 |
(loop (cdr a)))))) |
| 61 |
|
| 62 |
(make formatting-instruction data: ">") |
| 63 |
(newline giname) |
| 64 |
|
| 65 |
(if sosofo |
| 66 |
(apply sosofo-append sosofo) |
| 67 |
(current-node)) |
| 68 |
|
| 69 |
(make formatting-instruction data: (string-append "</" giname ">")) |
| 70 |
(newline giname)))) |
| 71 |
|
| 72 |
(define (make-empty-element #!rest args) |
| 73 |
;; Args _MUST_ be '( gi: "gi" attributes: '() sosofo) |
| 74 |
(let* ((giname (extract-gi args)) |
| 75 |
(attributes (extract-attributes args)) |
| 76 |
(attr attributes)) |
| 77 |
(sosofo-append |
| 78 |
(make formatting-instruction data: (string-append "<" giname)) |
| 79 |
(if (null? attr) |
| 80 |
(empty-sosofo) |
| 81 |
(let loop ((a attr)) |
| 82 |
(if (null? a) |
| 83 |
(empty-sosofo) |
| 84 |
(make sequence |
| 85 |
(make formatting-instruction |
| 86 |
data: (string-append " " |
| 87 |
(car (car a)) |
| 88 |
"=\"" |
| 89 |
(car (cdr (car a))) |
| 90 |
"\"")) |
| 91 |
(loop (cdr a)))))) |
| 92 |
|
| 93 |
(make formatting-instruction data: ">") |
| 94 |
(newline giname)))) |
| 95 |
|
| 96 |
;; ###################################################################### |
| 97 |
;; Epic-specific configuration |
| 98 |
|
| 99 |
(define ($generate-chapter-toc$) #f) |
| 100 |
(define ($generate-part-toc$) #f) |
| 101 |
(define ($generate-book-toc$) #f) |
| 102 |
(define ($generate-set-toc$) #f) |
| 103 |
|
| 104 |
(define %generate-book-toc% #t) |
| 105 |
(define %generate-reference-toc% #f) |
| 106 |
(define %generate-part-toc% #f) |
| 107 |
(define %generate-set-toc% #t) |
| 108 |
|
| 109 |
(define %section-autolabel% #f) |
| 110 |
(define %chapter-autolabel% #f) |
| 111 |
|
| 112 |
(define (chunk-skip-first-element-list) '()) |
| 113 |
|
| 114 |
(define (header-navigation nd #!optional (navlist (empty-node-list))) |
| 115 |
(empty-sosofo)) |
| 116 |
|
| 117 |
;(define (footer-navigation nd) |
| 118 |
; (empty-sosofo)) |
| 119 |
|
| 120 |
(define ($paragraph$ #!optional (para-wrapper "P")) |
| 121 |
(let ((footnotes (select-elements (descendants (current-node)) (normalize "footnote"))) |
| 122 |
(tgroup (have-ancestor? (normalize "tgroup")))) |
| 123 |
(make sequence |
| 124 |
(make-element gi: para-wrapper |
| 125 |
attributes: '(("CLASS" "PARA")) |
| 126 |
(process-children)) |
| 127 |
(if (or tgroup (node-list-empty? footnotes)) |
| 128 |
(empty-sosofo) |
| 129 |
(make-element gi: "BLOCKQUOTE" |
| 130 |
attributes: (list |
| 131 |
(list "DIV" "FOOTNOTES")) |
| 132 |
(with-mode footnote-mode |
| 133 |
(process-node-list footnotes))))))) |
| 134 |
|
| 135 |
;; ############################## |
| 136 |
|
| 137 |
&dbautoc.dsl; |
| 138 |
|
| 139 |
;; ############################## |
| 140 |
|
| 141 |
(define %htmlhelp-index% "Index.hhk") |
| 142 |
(define %htmlhelp-toc% "Contents.hhc") |
| 143 |
|
| 144 |
(element helplink |
| 145 |
(let* ((title (data (current-node))) |
| 146 |
(target (element-with-id (attribute-string "topiclink"))) |
| 147 |
(href (if (node-list-empty? target) |
| 148 |
"" |
| 149 |
(href-to target)))) |
| 150 |
(make-element gi: "LI" |
| 151 |
(make-element gi: "OBJECT" |
| 152 |
attributes: '(("type" "text/sitemap")) |
| 153 |
(make-empty-element gi: "param" |
| 154 |
attributes: (list (list "name" "Name") |
| 155 |
(list "value" title))) |
| 156 |
(make-empty-element gi: "param" |
| 157 |
attributes: (list (list "name" "Local") |
| 158 |
(list "value" href))))))) |
| 159 |
|
| 160 |
;; ############################## |
| 161 |
|
| 162 |
(define (make-contents-hhc) |
| 163 |
(make entity |
| 164 |
system-id: %htmlhelp-toc% |
| 165 |
(make document-type |
| 166 |
name: "HTML" |
| 167 |
public-id: "-//IETF//DTD HTML//EN") |
| 168 |
(make-element gi: "HTML" |
| 169 |
(make-element gi: "HEAD" |
| 170 |
(make formatting-instruction data: "<!-- Sitemap 1.0 -->")) |
| 171 |
(make-element gi: "BODY" |
| 172 |
(make-element gi: "OBJECT" |
| 173 |
attributes: '(("type" "text/site properties")) |
| 174 |
(make-empty-element gi: "param" |
| 175 |
attributes: '(("name" "ImageType") |
| 176 |
("value" "Folder")))) |
| 177 |
(make-element gi: "UL" |
| 178 |
(make-element gi: "LI" |
| 179 |
(build-tocentry (current-node))) |
| 180 |
(build-toc (current-node) (toc-depth (current-node)))))))) |
| 181 |
|
| 182 |
;; ############################## |
| 183 |
|
| 184 |
(element set |
| 185 |
(let* ((setinfo (select-elements (children (current-node)) (normalize "setinfo"))) |
| 186 |
(ititle (select-elements (children setinfo) (normalize "title"))) |
| 187 |
(title (if (node-list-empty? ititle) |
| 188 |
(select-elements (children (current-node)) (normalize "title")) |
| 189 |
(node-list-first ititle))) |
| 190 |
(nl (titlepage-info-elements (current-node) setinfo)) |
| 191 |
(tsosofo (with-mode head-title-mode |
| 192 |
(process-node-list title)))) |
| 193 |
(html-document |
| 194 |
tsosofo |
| 195 |
(make-element gi: "DIV" |
| 196 |
attributes: '(("CLASS" "SET")) |
| 197 |
(if %generate-set-titlepage% |
| 198 |
(make sequence |
| 199 |
(set-titlepage nl 'recto) |
| 200 |
(set-titlepage nl 'verso)) |
| 201 |
(empty-sosofo)) |
| 202 |
|
| 203 |
(if (not (generate-toc-in-front)) |
| 204 |
(process-children) |
| 205 |
(empty-sosofo)) |
| 206 |
|
| 207 |
(if %generate-set-toc% |
| 208 |
(make-contents-hhc) |
| 209 |
(empty-sosofo)) |
| 210 |
|
| 211 |
(if (generate-toc-in-front) |
| 212 |
(process-children) |
| 213 |
(empty-sosofo)))))) |
| 214 |
|
| 215 |
(element book |
| 216 |
(let* ((bookinfo (select-elements (children (current-node)) (normalize "bookinfo"))) |
| 217 |
(ititle (select-elements (children bookinfo) (normalize "title"))) |
| 218 |
(title (if (node-list-empty? ititle) |
| 219 |
(select-elements (children (current-node)) (normalize "title")) |
| 220 |
(node-list-first ititle))) |
| 221 |
(nl (titlepage-info-elements (current-node) bookinfo)) |
| 222 |
(tsosofo (with-mode head-title-mode |
| 223 |
(process-node-list title))) |
| 224 |
(dedication (select-elements (children (current-node)) (normalize "dedication")))) |
| 225 |
(html-document |
| 226 |
tsosofo |
| 227 |
(make-element gi: "DIV" |
| 228 |
attributes: '(("CLASS" "BOOK")) |
| 229 |
(if %generate-book-titlepage% |
| 230 |
(make sequence |
| 231 |
(book-titlepage nl 'recto) |
| 232 |
(book-titlepage nl 'verso)) |
| 233 |
(empty-sosofo)) |
| 234 |
|
| 235 |
(if (node-list-empty? dedication) |
| 236 |
(empty-sosofo) |
| 237 |
(with-mode dedication-page-mode |
| 238 |
(process-node-list dedication))) |
| 239 |
|
| 240 |
(if (not (generate-toc-in-front)) |
| 241 |
(process-children) |
| 242 |
(empty-sosofo)) |
| 243 |
|
| 244 |
(if %generate-book-toc% |
| 245 |
(if (node-list-empty? (parent (current-node))) |
| 246 |
(make-contents-hhc) |
| 247 |
(empty-sosofo)) |
| 248 |
(empty-sosofo)) |
| 249 |
|
| 250 |
(if (generate-toc-in-front) |
| 251 |
(process-children) |
| 252 |
(empty-sosofo)))))) |
| 253 |
|
| 254 |
(element refmeta |
| 255 |
(process-node-list (select-elements (children (current-node)) "indexterm"))) |
| 256 |
|
| 257 |
(element indexterm |
| 258 |
(let* ((primary (select-elements (children (current-node)) "primary")) |
| 259 |
(secondary (select-elements (children (current-node)) "secondary")) |
| 260 |
(tertiary (select-elements (children (current-node)) "tertiary")) |
| 261 |
(pterm (data primary)) |
| 262 |
(sterm (if secondary |
| 263 |
(string-append |
| 264 |
(data primary) |
| 265 |
", " |
| 266 |
(data secondary)) |
| 267 |
"")) |
| 268 |
(tterm (if tertiary |
| 269 |
(string-append |
| 270 |
(data primary) |
| 271 |
", " |
| 272 |
(data secondary) |
| 273 |
", " |
| 274 |
(data tertiary)) |
| 275 |
""))) |
| 276 |
(make-element gi: "OBJECT" |
| 277 |
attributes: '(("type" "application/x-oleobject") |
| 278 |
("classid" "clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e")) |
| 279 |
(make sequence |
| 280 |
(make-empty-element gi: "param" |
| 281 |
attributes: (list (list "name" "Keyword") |
| 282 |
(list "value" pterm))) |
| 283 |
(if (not (node-list-empty? secondary)) |
| 284 |
(make sequence |
| 285 |
(make-empty-element gi: "param" |
| 286 |
attributes: (list (list "name" "Keyword") |
| 287 |
(list "value" sterm))) |
| 288 |
(if (not (node-list-empty? tertiary)) |
| 289 |
(make-empty-element gi: "param" |
| 290 |
attributes: (list (list "name" "Keyword") |
| 291 |
(list "value" tterm))) |
| 292 |
(empty-sosofo))) |
| 293 |
(empty-sosofo)))))) |
| 294 |
|
| 295 |
;; ############################## |
| 296 |
|
| 297 |
(root |
| 298 |
(make sequence |
| 299 |
(process-children) |
| 300 |
(with-mode filelist |
| 301 |
(process-children)) |
| 302 |
(with-mode manifest |
| 303 |
(process-children)))) |
| 304 |
|
| 305 |
;; ############################## |
| 306 |
|
| 307 |
(define (println #!optional (text "")) |
| 308 |
(make formatting-instruction data: (string-append text " |
| 309 |
"))) |
| 310 |
|
| 311 |
(define html-block-elements |
| 312 |
'("HTML" "HEAD" |
| 313 |
"TITLE" "META" "LINK" |
| 314 |
"BODY" "DIV" "H1" "P" |
| 315 |
"OBJECT" "param")) |
| 316 |
|
| 317 |
(define (newline #!optional (gi "")) |
| 318 |
(if (or (equal? gi "") (member gi html-block-elements)) |
| 319 |
(make formatting-instruction data: " ") |
| 320 |
(empty-sosofo))) |
| 321 |
|
| 322 |
(mode filelist |
| 323 |
;; this mode is really just a hack to get at the root element |
| 324 |
(root (process-children)) |
| 325 |
|
| 326 |
(default |
| 327 |
(if (node-list=? (current-node) (sgml-root-element)) |
| 328 |
(let* ((rootgi (case-fold-down (gi (sgml-root-element)))) |
| 329 |
(proj (string-append "the" rootgi ".hhp")) |
| 330 |
(cproj (string-append "the" rootgi ".chm")) |
| 331 |
(topic (html-base-filename (sgml-root-element))) |
| 332 |
(index %htmlhelp-index%) |
| 333 |
(toc %htmlhelp-toc%)) |
| 334 |
(make sequence |
| 335 |
(make entity |
| 336 |
system-id: proj |
| 337 |
(make sequence |
| 338 |
(println "[OPTIONS]") |
| 339 |
(println "Auto Index=Yes") |
| 340 |
(println "Compatibility=1.1") |
| 341 |
(println (string-append "Compiled file=" cproj)) |
| 342 |
(println (string-append "Contents file=" toc)) |
| 343 |
(println (string-append "Default topic=" topic)) |
| 344 |
(println "Full-text search=Yes") |
| 345 |
(println (string-append "Index file=" index)) |
| 346 |
(println "Language=0x409 English (United States)") |
| 347 |
(newline) |
| 348 |
(println "[FILES]") |
| 349 |
(let loop ((node (current-node))) |
| 350 |
(if (node-list-empty? node) |
| 351 |
(empty-sosofo) |
| 352 |
(make sequence |
| 353 |
(println (html-file node)) |
| 354 |
(loop (next-chunk-element node))))))) |
| 355 |
(make entity |
| 356 |
system-id: index |
| 357 |
(empty-sosofo)))) |
| 358 |
(empty-sosofo)))) |
| 359 |
|
| 360 |
(mode manifest |
| 361 |
;; this mode is really just a hack to get at the root element |
| 362 |
(root (process-children)) |
| 363 |
|
| 364 |
(default |
| 365 |
(if (node-list=? (current-node) (sgml-root-element)) |
| 366 |
(if html-manifest |
| 367 |
(make entity |
| 368 |
system-id: html-manifest-filename |
| 369 |
(make sequence |
| 370 |
(println %htmlhelp-toc%) |
| 371 |
(let loop ((node (current-node))) |
| 372 |
(if (node-list-empty? node) |
| 373 |
(empty-sosofo) |
| 374 |
(make sequence |
| 375 |
(println (html-file node)) |
| 376 |
(loop (next-chunk-element node))))))) |
| 377 |
(empty-sosofo)) |
| 378 |
(empty-sosofo)))) |
| 379 |
|
| 380 |
</style-specification-body> |
| 381 |
</style-specification> |
| 382 |
|
| 383 |
<external-specification id="docbook" document="docbook.dsl"> |
| 384 |
|
| 385 |
</style-sheet> |