File: dbindex.dsl

package info (click to toggle)
docbook-stylesheets 1.49-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 7,576 kB
  • ctags: 33
  • sloc: perl: 444; xml: 115; makefile: 98; sh: 27
file content (148 lines) | stat: -rw-r--r-- 4,271 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
;; $Id: dbindex.dsl,v 1.5 1998/11/19 12:39:39 nwalsh Exp $
;;
;; This file is part of the Modular DocBook Stylesheet distribution.
;; See ../README or http://www.berkshire.net/~norm/dsssl/
;;

;; ................... INDEX TERMS (EMBEDDED MARKERS) ...................

(element indexterm
  ;; This is different than (empty-sosofo) alone because the backend
  ;; will hang an anchor off the empty sequence.  This allows the index
  ;; to point to the indexterm (but only if the indexterm has an ID).
  (make sequence (empty-sosofo)))

(element primary (empty-sosofo))
(element secondary (empty-sosofo))
(element tertiary (empty-sosofo))
(element see (empty-sosofo))
(element seealso (empty-sosofo))

;; =========================== INDEX ELEMENTS ===========================

(element setindex ($component$))
(element (setindex title) (empty-sosofo))

(element index
  (make simple-page-sequence
    page-number-restart?: (or %page-number-restart% 
			      (book-start?) 
			      (first-chapter?))
    page-number-format: ($page-number-format$)
    use: default-text-style
    left-header:   ($left-header$)
    center-header: ($center-header$)
    right-header:  ($right-header$)
    left-footer:   ($left-footer$)
    center-footer: ($center-footer$)
    right-footer:  ($right-footer$)
    start-indent: %body-start-indent%
    input-whitespace-treatment: 'collapse
    quadding: %default-quadding%
    page-n-columns: 2
    (make sequence
      ($component-title$)
      (process-children))
    (make-endnotes)))


(element (index title) (empty-sosofo))

(element indexdiv ($section$))
(element (indexdiv title) (empty-sosofo))

(element indexentry (process-children))

(element primaryie
  (make paragraph
    (process-children)))

(element secondaryie
  (make paragraph
    start-indent: (+ (inherited-start-indent) 1em)
    (process-children)))

(element tertiaryie
  (make paragraph
    start-indent: (+ (inherited-start-indent) 2em)
    (process-children)))

(define (find-indexterm id)
  ;; If you have a lot of indexterms that don't have IDs, this could 
  ;; be incredibly slow.  So don't do that.
  (let* ((idtarget (element-with-id id)))
    (if (node-list-empty? idtarget)
	(let loop ((idnodes (select-elements (descendants (sgml-root-element))
					     (normalize "indexterm"))))
	  (if (node-list-empty? idnodes)
	      (empty-node-list)
	      (if (equal? id (string-append "AEN" 
					    (number->string 
					     (all-element-number 
					      (node-list-first idnodes)))))
		  (node-list-first idnodes)
		  (loop (node-list-rest idnodes)))))
	idtarget)))

(define (indexentry-link nd)
  (let* ((id        (attribute-string (normalize "role") nd))
	 (target    (find-indexterm id))
	 (preferred (not (node-list-empty?
			  (select-elements (children (current-node))
					   (normalize "emphasis")))))
	 (sosofo    (if (node-list-empty? target) 
			(literal "?")
			(make link
			  destination: (node-list-address target)
			  (with-mode toc-page-number-mode
			    (process-node-list target))))))
    (if preferred
	(make sequence
	  font-weight: 'bold
	  sosofo)
	sosofo)))

(element (primaryie ulink)
  (indexentry-link (current-node)))

(element (secondaryie ulink)
  (indexentry-link (current-node)))

(element (tertiaryie ulink)
  (indexentry-link (current-node)))

(element seeie
  (let ((indent (cond ((node-list-empty? 
			(select-elements
			 (children (parent (current-node)))
			 (normalize "secondaryie")))
		       1em)
		      ((node-list-empty? 
			(select-elements
			 (children (parent (current-node)))
			 (normalize "tertiaryie")))
		       2em)
		      (else 3em))))
    (make paragraph
      start-indent: (+ (inherited-start-indent) indent)
      (literal "(" (gentext-index-see) " ")
      (process-children)
      (literal ")"))))

(element seealsoie
  (let ((indent (cond ((node-list-empty? 
			(select-elements
			 (children (parent (current-node)))
			 (normalize "secondaryie")))
		       1em)
		      ((node-list-empty? 
			(select-elements
			 (children (parent (current-node)))
			 (normalize "tertiaryie")))
		       2em)
		      (else 3em))))
    (make paragraph
      start-indent: (+ (inherited-start-indent) indent)
      (literal "(" (gentext-index-seealso) " ")
      (process-children)
      (literal ")"))))