-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathabicommon.dsl
138 lines (117 loc) · 4.01 KB
/
abicommon.dsl
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
;; Overrides of common functions shared between html and print
;; Are sections enumerated?
;; The number appears in their title, both in the table
;; of contents, and in the text.
(define %section-autolabel%
#t)
; Conditionally exclude an element and generate a sequence from those included.
(define (conditional-sequence nd)
(if (include-attributes? nd)
(process-children)
;($CONDITION-wrapper$ process-children)
(empty-sosofo)
))
; Non modal version
(element phrase
($phrase-CONDITION-wrapper$ (conditional-sequence (current-node)))
)
; Function to prepend the DRAFTTEXT onto the string if it's defined.
(define (prepend-draft-string tok)
<![%DRAFT;[(string-append "&DRAFTTEXT"]]>
tok
<![%DRAFT;[)]]>
)
(define (data-of node)
;; return the data characters of a node, except for the content of
;; indexterms which are suppressed.
(let loop ((nl (children node)) (result ""))
(if (node-list-empty? nl)
result
(if (equal? (node-property 'class-name (node-list-first nl)) 'element)
(if (or (equal? (gi (node-list-first nl)) (normalize "indexterm"))
(equal? (gi (node-list-first nl)) (normalize "comment"))
(equal? (gi (node-list-first nl)) (normalize "remark"))
(equal? (include-attributes? (node-list-first nl)) '#t))
(loop (node-list-rest nl) result)
(loop (node-list-rest nl)
(string-append result (data-of (node-list-first nl)))))
(if (or (equal? (node-property 'class-name (node-list-first nl))
'data-char)
(equal? (node-property 'class-name (node-list-first nl))
'sdata))
(loop (node-list-rest nl)
(string-append result (data (node-list-first nl))))
(loop (node-list-rest nl) result))))))
(define (element-title-string nd)
(let ((title (element-title nd)))
(if (string? title)
title
(prepend-draft-string (data-of title)))))
(element note
(if (include-attributes? (current-node))
($CONDITION-wrapper$ ($admonition$))
(empty-sosofo)))
(element programlisting
(if (include-attributes? (current-node))
($CONDITION-wrapper$ ($verbatim-display$
%indent-programlisting-lines%
(or %number-programlisting-lines%
(equal? (attribute-string (normalize "linenumbering")) (normalize "numbered")))))
(empty-sosofo)))
(element screen
(if (include-attributes? (current-node))
($CONDITION-wrapper$ ($verbatim-display$
%indent-screen-lines%
(or %number-screen-lines%
(equal? (attribute-string (normalize "linenumbering")) (normalize "numbered")))))
(empty-sosofo)))
(element figure
(if (include-attributes? (current-node))
($CONDITION-wrapper$
(let* ((mediaobj (select-elements (children (current-node))
(normalize "mediaobject")))
(imageobj (select-elements (children mediaobj)
(normalize "imageobject")))
(image (select-elements (children imageobj)
(normalize "imagedata")))
(graphic (select-elements (children (current-node))
(normalize "graphic")))
(align (if (node-list-empty? image)
(if (node-list-empty? graphic)
#f
(attribute-string (normalize "align")
(node-list-first graphic)))
(attribute-string (normalize "align") (node-list-first image))))
(dalign (cond ((equal? align (normalize "center"))
'center)
((equal? align (normalize "right"))
'end)
(else
'start))))
(if align
(make display-group
quadding: dalign
($formal-object$ %figure-rules% %figure-rules%))
($formal-object$ %figure-rules% %figure-rules%)))
)
(empty-sosofo)))
(element sect1
(if (include-attributes? (current-node))
($CONDITION-wrapper$ ($section$))
(empty-sosofo)))
(element sect2
(if (include-attributes? (current-node))
($CONDITION-wrapper$ ($section$))
(empty-sosofo)))
(element sect3
(if (include-attributes? (current-node))
($CONDITION-wrapper$ ($section$))
(empty-sosofo)))
(element sect4
(if (include-attributes? (current-node))
($CONDITION-wrapper$ ($section$))
(empty-sosofo)))
(element sect5
(if (include-attributes? (current-node))
($CONDITION-wrapper$ ($section$))
(empty-sosofo)))