forked from ryanarn/powerabi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabi.dsl
1332 lines (1219 loc) · 48.2 KB
/
abi.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
<!ENTITY html-ss PUBLIC "-//Norman Walsh//DOCUMENT DocBook HTML Stylesheet//EN" CDATA dsssl>
<!ENTITY print-ss PUBLIC "-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN" CDATA dsssl>
<!ENTITY % UNIFIED "INCLUDE">
<!ENTITY % EABI "IGNORE">
<!ENTITY % LINUX "IGNORE">
<!ENTITY % WRAPPER "IGNORE">
<!ENTITY % TAGID "IGNORE">
<!ENTITY % DRAFT "IGNORE">
<![%EABI;[
<!ENTITY % UNIFIED "IGNORE">
<!ENTITY VARIABLEDEFS SYSTEM "eabi.dsl">
<!ENTITY INCLUDECHECKS SYSTEM "include-checks.dsl">
<!ENTITY ABITEXT "Embedded">
]]>
<![%LINUX;[
<!ENTITY % UNIFIED "IGNORE">
<!ENTITY VARIABLEDEFS SYSTEM "linuxabi.dsl">
<!ENTITY INCLUDECHECKS SYSTEM "include-checks.dsl">
<!ENTITY ABITEXT "Server">
]]>
<![%UNIFIED;[
<!ENTITY % LINUX "IGNORE">
<!ENTITY % EABI "IGNORE">
<!ENTITY VARIABLEDEFS SYSTEM "unified.dsl">
<!ENTITY INCLUDECHECKS SYSTEM "dont-include-checks.dsl">
]]>
<![%TAGID;[<!ENTITY TAGIDDEF SYSTEM "tagid.dsl">]]>
<![%WRAPPER;[
<!ENTITY WRAPPERDEF SYSTEM "wrapper.dsl">
<![%LINUX;[
<!ENTITY WRAPITDEF SYSTEM "either-wrap-attribs.dsl">
]]>
<![%EABI;[
<!ENTITY WRAPITDEF SYSTEM "either-wrap-attribs.dsl">
]]>
<![%UNIFIED;[
<!ENTITY WRAPITDEF SYSTEM "unified-wrap-attribs.dsl">
]]>
]]>
<!ENTITY TAGIDDEF SYSTEM "tagid-stub.dsl">
<!ENTITY WRAPPERDEF SYSTEM "wrapper-stub.dsl">
<!ENTITY WRAPITDEF SYSTEM "wrapit-stub.dsl">
<!ENTITY COLORDEF SYSTEM "colordef.dsl">
<!ENTITY PRINTTTLPAGE SYSTEM "print-ttlpg.dsl">
<!ENTITY HTMLTTLPAGE SYSTEM "html-ttlpg.dsl">
<!ENTITY ABICOMMON SYSTEM "abicommon.dsl">
<!ENTITY DRAFTTEXT "DRAFT: ">
<!ENTITY ABITEXT "Unified">
]>
<style-sheet>
<style-specification id="html" use="html-stylesheet">
<style-specification-body>
; Pull in the ABI particular attribute definitions which effect
; paragraph inclusion/exclusion.
&VARIABLEDEFS;
; Pull in the functions which check the INCLUDE/IGNORE status of the ABI attribute
; variables defined in VARIABLEDEFS
&INCLUDECHECKS;
; Pull in overrides of common functions that are shared between html and print
&ABICOMMON;
; Pull in the html title-page mode overloads. They're very long and the
; modifications were miniscule.
&HTMLTTLPAGE;
; Pull in the colors
&COLORDEF;
; Necessary to conditionally include/exclude phrase elements from the book
; title. Oddly enough the head-title-mode isn't used for chapters titles.
(mode head-title-mode
;; TITLE in an HTML HEAD
(element (title) ; Put DRAFTTEXT on the HTML HEAD TITLE if available.
(make sequence
<![%DRAFT;[(literal "&DRAFTTEXT")]]>
(process-children)))
(element (phrase) ; Necessary to conditionaly include phrase elements
(conditional-sequence (current-node))
)
(element graphic (empty-sosofo))
(element inlinegraphic (empty-sosofo))
)
; This affects the Chapter titles.
(mode title-mode
(element title
(make sequence
<![%DRAFT;[(literal "&DRAFTTEXT")]]>
(process-children)))
)
; This affects the navigation banner usage of the title
;; +-----------------------------------------+
;; | nav-banner |
;; +------------+---------------+------------|
;; | prevlink | nav-context | nextlink |
;; +-----------------------------------------+
;(mode title-sosofo-mode
; (element title
; (make sequence
; <![%DRAFT;[(literal "&DRAFTTEXT")]]>
; (process-children-trim)))
;
; (element citetitle
; (process-children-trim))
;
; (element refname
; (process-children-trim))
;
; (element refentrytitle
; (process-children-trim)))
; Create an element if it has a CONDITION attribute only if
; that attribute is marked INCLUDE in the VARIABLEDEFS file.
(define (conditional-element nd elem)
(if (include-attributes? (nd))
(make element gi: elem (process-children))
(empty-sosofo)))
(element listitem
(conditional-element (current-node) "LI")
)
(element para
(conditional-element (current-node) "P")
)
; Sometimes a varlistentry is excluded entirely based upon a CONDITION
; attribute.
(element varlistentry
(if (include-attributes? (current-node))
(let ((terms (select-elements (children (current-node)) (normalize "term")))
(listitem (select-elements (children (current-node)) (normalize "listitem"))))
(make sequence
(make element gi: "DT"
(if (attribute-string (normalize "id"))
(make sequence
(make element gi: "A"
attributes: (list (list "NAME" (attribute-string (normalize "id"))))
(empty-sosofo))
(process-node-list terms))
(process-node-list terms)))
(process-node-list listitem)))
(empty-sosofo)))
; This deviates from the original in that it includes/excludes based on a
; CONDITION attribute. It also prepends a ", " if the node isn't the first
; one rather than the original version which appended a ", " if the node isn't
; the last, which isn't correct when the last node is excluded based on
; CONDITION.
(element (varlistentry term)
(if (include-attributes? (current-node))
(make sequence
(if (not (first-sibling?))
(literal ", ")
(literal ""))
(process-children-trim))
(empty-sosofo)))
</style-specification-body>
</style-specification>
<style-specification id="print" use="print-stylesheet">
<style-specification-body>
; Pull in the ABI particular attribute definitions which effect
; paragraph inclusion/exclusion.
&VARIABLEDEFS;
; Pull in the functions which check the INCLUDE/IGNORE status of the ABI attribute
; variables defined in VARIABLEDEFS
&INCLUDECHECKS;
; Pull in the conditional $wrapper$ definition.
&WRAPPERDEF;
&WRAPITDEF;
; Pull in the conditional tagid definition.
&TAGIDDEF;
; Pull in overrides of common functions that are shared between html and print
&ABICOMMON;
; Pull in the print title-page mode overloads. They're very long and the
; modifications were miniscule.
&PRINTTTLPAGE;
; Pull in the colors
&COLORDEF;
; This affects the Chapter titles in the table-of-contents
(mode title-mode
(element title
(make sequence
<![%DRAFT;[(literal "&DRAFTTEXT")]]>
(process-children)))
)
; This affects the actual Chapter titles.
(mode component-title-mode
(element title
(make sequence
<![%DRAFT;[(literal "&DRAFTTEXT")]]>
(process-children))))
;(mode title-sosofo-mode
; (element title
; (make sequence
; <![%DRAFT;[(literal "&DRAFTTEXT")]]>
; (process-children-trim)))
;
; (element citetitle
; (process-children-trim))
;
; (element refname
; (process-children-trim))
;
; (element refentrytitle
; (process-children-trim)))
; Create an element if it has a CONDITION attribute only if
; that attribute is marked INCLUDE in the VARIABLEDEFS file.
(define (conditional-element nd)
(if (include-attributes? (nd))
($CONDITION-wrapper$ (make paragraph (process-children)))
(empty-sosofo)))
(element para
(if (include-attributes? (current-node))
($CONDITION-wrapper$ ($paragraph$))
(empty-sosofo)))
(define ($admonition$)
(if %admon-graphics%
($graphical-admonition$)
(make display-group
;;space-before: %block-sep%
;space-before: 0pt
;space-before: (* %block-sep% 4)
;;space-after: %block-sep%
space-before: %block-sep%
space-after: %block-sep%
;space-after: 0pt
start-indent: (if %admon-graphics%
(inherited-start-indent)
(+ (inherited-start-indent) (* (ILSTEP) 2)))
end-indent: (inherited-end-indent)
font-size: (- %bf-size% 1pt)
font-weight: 'medium
font-posture: 'upright
font-family-name: %admon-font-family%
line-spacing: (* (- %bf-size% 1pt) %line-spacing-factor%)
(process-children))))
;; Add the end-indent
(define ($list$)
(make display-group
start-indent: (if (INBLOCK?)
(inherited-start-indent)
(+ %block-start-indent% (inherited-start-indent)))
end-indent: (inherited-end-indent)
space-after: (if (INLIST?) %para-sep% %block-sep%)))
; Added to set end-indent: (inherited-end-indent)
(define (generic-list-item indent-step line-field)
(let* ((itemcontent (children (current-node)))
(first-child (node-list-first itemcontent))
(spacing (inherited-attribute-string (normalize "spacing"))))
(make display-group
space-before: 0pt
space-after: 0pt
start-indent: (+ (inherited-start-indent) indent-step)
end-indent: (inherited-end-indent)
; (make rule
; orientation: 'horizontal
; line-thickness: %object-rule-thickness%
; display-alignment: 'center
; space-after: 0pt
; space-before: 0pt
; keep-with-next?: #t)
(make paragraph
use: (cond
((equal? (gi first-child) (normalize "programlisting"))
verbatim-style)
((equal? (gi first-child) (normalize "screen"))
verbatim-style)
((equal? (gi first-child) (normalize "synopsis"))
verbatim-style)
((equal? (gi first-child) (normalize "literallayout"))
linespecific-style)
((equal? (gi first-child) (normalize "address"))
linespecific-style)
(else
nop-style))
space-before: (if (equal? (normalize "compact") spacing)
0pt
%para-sep%)
first-line-start-indent: (- indent-step)
end-indent: (inherited-end-indent)
; (make rule
; orientation: 'horizontal
; line-thickness: %object-rule-thickness%
; display-alignment: 'center
; space-after: 0pt
; space-before: 0pt
; keep-with-next?: #t)
(make sequence
line-field)
(with-mode listitem-content-mode
(process-node-list first-child)))
(process-node-list (node-list-rest itemcontent)))))
(element variablelist
(if (include-attributes? (current-node))
($CONDITION-wrapper$ (process-variablelist (current-node)))
(empty-sosofo)))
; This has been moved from the non-modal (element variablelist) so
; that we can do conditional selection there and call this in two cases.
(define (process-variablelist nd)
;(element variablelist
(let* ((termlength (if (attribute-string (normalize "termlength"))
(string->number
(attribute-string (normalize "termlength")))
%default-variablelist-termlength%))
(maxlen (if (> termlength %default-variablelist-termlength%)
termlength
%default-variablelist-termlength%))
(too-long? (variablelist-term-too-long? termlength)))
(make display-group
start-indent: (if (INBLOCK?)
(inherited-start-indent)
(+ %block-start-indent% (inherited-start-indent)))
space-before: (if (INLIST?) %para-sep% %block-sep%)
space-after: (if (INLIST?) %para-sep% %block-sep%)
(if (and (or (and termlength (not too-long?))
%always-format-variablelist-as-table%)
(or %may-format-variablelist-as-table%
%always-format-variablelist-as-table%))
(make table
space-before: (if (INLIST?) %para-sep% %block-sep%)
space-after: (if (INLIST?) %para-sep% %block-sep%)
start-indent: (if (INBLOCK?)
(inherited-start-indent)
(+ %block-start-indent%
(inherited-start-indent)))
;; Calculate the width of the column containing the terms...
;;
;; maxlen in (inherited-font-size) 72pt
;; x ---------- x ----------------------- x ------ = width
;; 12 chars 10pt in
;;
(make table-column
column-number: 1
width: (* (* (/ maxlen 12) (/ (inherited-font-size) 10pt)) 72pt))
(with-mode variablelist-table
(process-children)))
(process-children)))))
; This has been moved from the non-modal (element (itemizedlist listitem)) so
; that we can do conditional selection there and call this in two cases.
(define (process-listitem nd)
(let ((ilevel (length (hierarchical-number-recursive (normalize "itemizedlist"))))
(override (inherited-attribute-string (normalize "override")))
(mark (inherited-attribute-string (normalize "mark"))))
(generic-list-item
(ILSTEP)
(if (or (and override
(equal? (normalize override) (normalize "none")))
(and (not override)
(equal? (normalize mark) (normalize "none"))))
(make line-field
font-size: (BULLTREAT BULLSIZE ilevel override mark)
position-point-shift: (BULLTREAT BULLSHIFT ilevel override mark)
field-width: (ILSTEP)
(literal "\no-break-space;"))
(make line-field
font-size: (BULLTREAT BULLSIZE ilevel override mark)
position-point-shift: (BULLTREAT BULLSHIFT ilevel override mark)
field-width: (ILSTEP)
(literal (BULLTREAT BULLSTR ilevel override mark)))))))
; Only list the items conditionally included. The original contents of this
; function were moved to process-listitem.
(element (itemizedlist listitem)
(if (include-attributes? (current-node))
($CONDITION-wrapper$ (process-listitem (current-node)))
(empty-sosofo)))
(element itemizedlist
(if (include-attributes? (current-node))
($CONDITION-wrapper$ ($list$))
(empty-sosofo)))
; Sometimes a varlistentry is excluded entirely based upon a CONDITION
; attribute.
(element varlistentry
(if (include-attributes? (current-node))
($CONDITION-wrapper$ (process-children))
(empty-sosofo)))
; This deviates from the original in that it includes/excludes based on a
; CONDITION attribute. It also prepends a ", " if the node isn't the first
; one rather than the original version which appended a ", " if the node isn't
; the last, which isn't correct when the last node is excluded based on
; CONDITION.
(element (varlistentry term)
(if (include-attributes? (current-node))
($CONDITION-wrapper$ (make paragraph
space-before: (if (first-sibling?)
%block-sep%
0pt)
keep-with-next?: #t
first-line-start-indent: 0pt
start-indent: (inherited-start-indent)
(process-children)))
(empty-sosofo)))
; Updated the authorgroup space-after to adjust the space between the book
; title and the author group in order to fit all authors on the first page.
(define (book-titlepage-before node side)
(if (equal? side 'recto)
(cond
((equal? (gi node) (normalize "corpauthor"))
(make paragraph
space-after: (* (HSIZE 5) %head-after-factor% 8)
(literal "\no-break-space;")))
((equal? (gi node) (normalize "authorgroup"))
(if (have-sibling? (normalize "corpauthor") node)
(empty-sosofo)
(make paragraph
;space-after: (* (HSIZE 5) %head-after-factor% 2)
space-after: 0pt
(literal "\no-break-space;"))))
((equal? (gi node) (normalize "author"))
(if (or (have-sibling? (normalize "corpauthor") node)
(have-sibling? (normalize "authorgroup") node))
(empty-sosofo)
(make paragraph
space-after: (* (HSIZE 5) %head-after-factor% 8)
(literal "\no-break-space;"))))
(else (empty-sosofo)))
(empty-sosofo)))
(element informaltable
(let ((attrib (attribute-string "CONDITION" (current-node))))
(if (include-attributes? (current-node))
($CONDITION-wrapper$ (with-mode mutual-exclusion-table-mode ($informal-object$ %informaltable-rules% %informaltable-rules%)) )
(empty-sosofo))))
(mode mutual-exclusion-table-mode
(element (thead)
($mutual-exclusion-table-body$ (current-node)))
(element (tbody)
($mutual-exclusion-table-body$ (current-node)))
)
(define (INCONDITION?)
(inherited-attribute-string "CONDITION" (current-node)))
(define ($informal-object$ #!optional (rule-before? #f) (rule-after? #f))
(make display-group
start-indent: (+ %block-start-indent% (inherited-start-indent))
space-before: (if (INLIST?) %block-sep%
(if (INCONDITION?) 0pt (/ %block-sep% 8)))
space-after: (if (INLIST?) %block-sep%
(if (INCONDITION?) 0pt (/ %block-sep% 8)))
keep-with-previous?: #f
keep: 'page
(if rule-before?
(make rule
orientation: 'horizontal
line-thickness: %object-rule-thickness%
display-alignment: 'center
space-after: (/ %block-sep% 2)
;keep-with-previous?: #f
keep-with-next?: #t)
(empty-sosofo))
(process-children)
(if rule-after?
(make rule
orientation: 'horizontal
line-thickness: %object-rule-thickness%
display-alignment: 'center
space-before: (/ %block-sep% 2)
keep-with-previous?: #t)
(empty-sosofo))))
; It's stupid that the following three defines are necessary just to override
; the 'bolding' of the thead cell.
(define ($mutual-exclusion-table-body$ body)
(let* ((tgroup (ancestor (normalize "tgroup") body))
(cols (string->number (attribute-string (normalize "cols") tgroup)))
(blabel (cond
((equal? (gi body) (normalize "thead")) 'thead)
((equal? (gi body) (normalize "tbody")) 'tbody)
((equal? (gi body) (normalize "tfoot")) 'tfoot))))
(make sequence
label: blabel
(let loop ((rows (select-elements (children body) (normalize "row")))
(overhang (constant-list 0 cols)))
(if (node-list-empty? rows)
(empty-sosofo)
(make sequence
($mutual-exclusion-process-row$ (node-list-first rows) overhang)
(loop (node-list-rest rows)
(update-overhang (node-list-first rows) overhang))))))))
(define ($mutual-exclusion-process-row$ row overhang)
(let* ((tgroup (ancestor (normalize "tgroup") row))
(maxcol (string->number (attribute-string
(normalize "cols") tgroup)))
(lastentry (node-list-last (node-list-filter-out-pis
(children row))))
(table (parent tgroup)))
;; there's no point calculating the row or colsep here, each cell
;; specifies it which overrides anything we might say here...
(make table-row
(let loop ((cells (node-list-filter-out-pis (children row)))
(prevcell (empty-node-list)))
(if (node-list-empty? cells)
(empty-sosofo)
(make sequence
($mutual-exclusion-process-cell$ (node-list-first cells) prevcell row overhang)
(loop (node-list-rest cells) (node-list-first cells)))))
;; add any necessary empty cells to the end of the row
(let loop ((colnum (+ (cell-column-number lastentry overhang)
(hspan lastentry))))
(if (> colnum maxcol)
(empty-sosofo)
(make sequence
($process-empty-cell$ colnum row)
(loop (+ colnum 1))))))))
(define ($mutual-exclusion-process-cell$ entry preventry row overhang)
(let* ((colnum (cell-column-number entry overhang))
(lastcellcolumn (if (node-list-empty? preventry)
0
(- (+ (cell-column-number preventry overhang)
(hspan preventry))
1)))
(lastcolnum (if (> lastcellcolumn 0)
(overhang-skip overhang lastcellcolumn)
0))
(font-name (if (have-ancestor? (normalize "thead") entry)
%title-font-family%
%body-font-family%))
(weight (if (have-ancestor? (normalize "thead") entry)
'normal
'normal))
(adjust-size (if (have-ancestor? (normalize "thead") entry)
(/ %smaller-size-factor% 1.2)
1))
(fontcolor color-black)
(align (cell-align entry colnum)))
(make sequence
;; This is a little bit complicated. We want to output empty cells
;; to skip over missing data. We start count at the column number
;; arrived at by adding 1 to the column number of the previous entry
;; and skipping over any MOREROWS overhanging entrys. Then for each
;; iteration, we add 1 and skip over any overhanging entrys.
(let loop ((count (overhang-skip overhang (+ lastcolnum 1))))
(if (>= count colnum)
(empty-sosofo)
(make sequence
($process-empty-cell$ count row)
(loop (overhang-skip overhang (+ count 1))))))
;; Now we've output empty cells for any missing entries, so we
;; are ready to output the cell for this entry...
(make table-cell
column-number: colnum
n-columns-spanned: (hspan entry)
n-rows-spanned: (vspan entry)
cell-row-alignment: (cell-valign entry colnum)
cell-after-column-border: (if (cell-colsep entry colnum)
calc-table-cell-after-column-border
#f)
cell-after-row-border: (if (cell-rowsep entry colnum)
(if (last-sibling? (parent entry))
calc-table-head-body-border
calc-table-cell-after-row-border)
#f)
cell-before-row-margin: %cals-cell-before-row-margin%
cell-after-row-margin: %cals-cell-after-row-margin%
cell-before-column-margin: %cals-cell-before-column-margin%
cell-after-column-margin: %cals-cell-after-column-margin%
;; If there is some additional indentation (because we're in a list,
;; for example) make sure that gets passed along, but don't add
;; the normal body-start-indent.
start-indent: (+ (- (inherited-start-indent) %body-start-indent%)
%cals-cell-content-start-indent%)
end-indent: %cals-cell-content-end-indent%
(if (equal? (gi entry) (normalize "entrytbl"))
(make paragraph
(literal "ENTRYTBL not supported."))
(make paragraph
font-family-name: font-name
font-weight: weight
font-size: (* (inherited-font-size) adjust-size )
color: fontcolor
quadding: align
(process-node-list (children entry))))))))
(mode abi-diff-thead-mode
(element (thead)
($abi-diff-process-table-body$ (current-node)))
(element (tbody)
($abi-diff-process-table-body$ (current-node)))
)
; It's stupid that the following three defines are necessary just to override
; the 'bolding' of the thead cell.
(define ($abi-diff-process-table-body$ body)
(let* ((tgroup (ancestor (normalize "tgroup") body))
(cols (string->number (attribute-string (normalize "cols") tgroup)))
(blabel (cond
((equal? (gi body) (normalize "thead")) 'thead)
((equal? (gi body) (normalize "tbody")) 'tbody)
((equal? (gi body) (normalize "tfoot")) 'tfoot))))
(make sequence
label: blabel
(let loop ((rows (select-elements (children body) (normalize "row")))
(overhang (constant-list 0 cols)))
(if (node-list-empty? rows)
(empty-sosofo)
(make sequence
($abi-diff-process-row$ (node-list-first rows) overhang)
(loop (node-list-rest rows)
(update-overhang (node-list-first rows) overhang))))))))
(define ($abi-diff-process-row$ row overhang)
(let* ((tgroup (ancestor (normalize "tgroup") row))
(maxcol (string->number (attribute-string
(normalize "cols") tgroup)))
(lastentry (node-list-last (node-list-filter-out-pis
(children row))))
(table (parent tgroup)))
;; there's no point calculating the row or colsep here, each cell
;; specifies it which overrides anything we might say here...
(make table-row
(let loop ((cells (node-list-filter-out-pis (children row)))
(prevcell (empty-node-list)))
(if (node-list-empty? cells)
(empty-sosofo)
(make sequence
($abi-diff-process-cell$ (node-list-first cells) prevcell row overhang)
(loop (node-list-rest cells) (node-list-first cells)))))
;; add any necessary empty cells to the end of the row
(let loop ((colnum (+ (cell-column-number lastentry overhang)
(hspan lastentry))))
(if (> colnum maxcol)
(empty-sosofo)
(make sequence
($process-empty-cell$ colnum row)
(loop (+ colnum 1))))))))
(define ($abi-diff-process-cell$ entry preventry row overhang)
(let* ((colnum (cell-column-number entry overhang))
(lastcellcolumn (if (node-list-empty? preventry)
0
(- (+ (cell-column-number preventry overhang)
(hspan preventry))
1)))
(lastcolnum (if (> lastcellcolumn 0)
(overhang-skip overhang lastcellcolumn)
0))
(font-name (if (have-ancestor? (normalize "thead") entry)
%title-font-family%
%body-font-family%))
(weight (if (have-ancestor? (normalize "thead") entry)
'normal
'medium))
(adjust-size (if (have-ancestor? (normalize "thead") entry)
(/ %smaller-size-factor% 1.5)
1))
(fontcolor (if (have-ancestor? (normalize "thead") entry)
color-medslateblue
color-purple))
(align (cell-align entry colnum)))
(make sequence
;; This is a little bit complicated. We want to output empty cells
;; to skip over missing data. We start count at the column number
;; arrived at by adding 1 to the column number of the previous entry
;; and skipping over any MOREROWS overhanging entrys. Then for each
;; iteration, we add 1 and skip over any overhanging entrys.
(let loop ((count (overhang-skip overhang (+ lastcolnum 1))))
(if (>= count colnum)
(empty-sosofo)
(make sequence
($process-empty-cell$ count row)
(loop (overhang-skip overhang (+ count 1))))))
;; Now we've output empty cells for any missing entries, so we
;; are ready to output the cell for this entry...
(make table-cell
column-number: colnum
n-columns-spanned: (hspan entry)
n-rows-spanned: (vspan entry)
cell-row-alignment: (cell-valign entry colnum)
cell-after-column-border: (if (cell-colsep entry colnum)
calc-table-cell-after-column-border
#f)
cell-after-row-border: (if (cell-rowsep entry colnum)
(if (last-sibling? (parent entry))
calc-table-head-body-border
calc-table-cell-after-row-border)
#f)
cell-before-row-margin: %cals-cell-before-row-margin%
cell-after-row-margin: %cals-cell-after-row-margin%
cell-before-column-margin: %cals-cell-before-column-margin%
cell-after-column-margin: %cals-cell-after-column-margin%
;; If there is some additional indentation (because we're in a list,
;; for example) make sure that gets passed along, but don't add
;; the normal body-start-indent.
start-indent: (+ (- (inherited-start-indent) %body-start-indent%)
%cals-cell-content-start-indent%)
end-indent: %cals-cell-content-end-indent%
(if (equal? (gi entry) (normalize "entrytbl"))
(make paragraph
(literal "ENTRYTBL not supported."))
(make paragraph
font-family-name: font-name
font-weight: weight
font-size: (* (inherited-font-size) adjust-size )
color: fontcolor
quadding: align
(process-node-list (children entry))))))))
; Extended to support ("italicstrong" "italicbold" "boldstrong" "bolditalic") and "strikethrough"
(element emphasis
(if (attribute-string (normalize "role"))
(cond
((or (equal? (attribute-string (normalize "role")) "strong")
(equal? (attribute-string (normalize "role")) "bold"))
($bold-seq$))
((or (equal? (attribute-string (normalize "role")) "italicstrong")
(equal? (attribute-string (normalize "role")) "italicbold")
(equal? (attribute-string (normalize "role")) "boldstrong")
(equal? (attribute-string (normalize "role")) "bolditalic"))
($bold-italic-seq$))
((equal? (attribute-string (normalize "role")) "strikethrough")
($score-seq$ 'through))
(else
($italic-seq$)))
($italic-seq$)))
;(define (conditional-element nd elem)
; (let * ((attrib (attribute-string "CONDITION" nd)))
; (if (or
; (equal? attrib '#f)
; (include-attributes? attrib))
;
;(element figure
; (if (include-attributes? (current-node))
; ;; FIXME: this is a bit crude...
; (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)))
;
;; Overridden to provide CONDITION-wrapper and TAGID
(element table
(if (include-attributes? (current-node))
($CONDITION-wrapper$
;; can't be a "formal-object" because it requires special handling for
;; the PGWIDE attribute
(let* ((nsep (gentext-label-title-sep (gi)))
(pgwide (attribute-string (normalize "pgwide")))
(indent (lambda () (if (not (equal? pgwide "1"))
(+ %block-start-indent%
(inherited-start-indent))
%cals-pgwide-start-indent%)))
(rule-before? %table-rules%)
(rule-after? %table-rules%)
(title-sosofo (make paragraph
font-weight: %table-title-font-weight%
space-before: (if (object-title-after)
%para-sep%
0pt)
space-after: (if (object-title-after)
0pt
%para-sep%)
start-indent: (indent)
keep-with-next?: #t
(literal (gentext-element-name (current-node)))
(if (string=? (element-label) "")
(literal nsep)
(literal " " (element-label) nsep))
(element-title-sosofo)
($TAGID$ (current-node))))
(table-sosofo (make display-group
font-weight: 'bold
space-before: 0pt
space-after: 0pt
start-indent: (indent)
keep: 'page ; This keeps the section title with the table
(process-children)))
(table (make display-group
start-indent: (+ %block-start-indent%
(inherited-start-indent))
space-before: %block-sep%
space-after: (/ %para-sep% 3)
;keep: #t
(if rule-before?
(make rule
orientation: 'horizontal
line-thickness: %object-rule-thickness%
display-alignment: 'center
space-after: (/ %block-sep% 2)
keep-with-next?: #t)
(empty-sosofo))
(if (object-title-after)
(make sequence
table-sosofo
title-sosofo)
(make sequence
title-sosofo
table-sosofo))
(if rule-after?
(make rule
orientation: 'horizontal
line-thickness: %object-rule-thickness%
display-alignment: 'center
space-before: (/ %block-sep% 2)
keep-with-previous?: #t)
(empty-sosofo)))))
(if (and (equal? (print-backend) 'tex)
formal-object-float
(float-object (current-node)))
(make page-float
table)
table))
) ;;$CONDITION-wrapper
(empty-sosofo)))
;; Override this to add $TAGID$ on the title bar.
(mode formal-object-title-mode
(element title
(let* ((object (parent (current-node)))
(nsep (gentext-label-title-sep (gi object))))
(make paragraph
font-weight: %formal-object-title-font-weight%
space-before: (if (object-title-after (parent (current-node)))
%para-sep%
0pt)
space-after: (if (object-title-after (parent (current-node)))
0pt
%para-sep%)
start-indent: (+ %block-start-indent% (inherited-start-indent))
keep-with-next?: (not (object-title-after (parent (current-node))))
(if (member (gi object) (named-formal-objects))
(make sequence
(literal (gentext-element-name object))
(if (string=? (element-label object) "")
(literal nsep)
(literal " " (element-label object) nsep))
)
(empty-sosofo))
(process-children)
($TAGID$ (parent (current-node)) )))))
;; Override this to add $TAGID$ on the title bar.
(define ($section-title$)
(let* ((sect (current-node))
(info (info-element))
(exp-children (if (node-list-empty? info)
(empty-node-list)
(expand-children (children info)
(list (normalize "bookbiblio")
(normalize "bibliomisc")
(normalize "biblioset")))))
(parent-titles (select-elements (children sect) (normalize "title")))
(info-titles (select-elements exp-children (normalize "title")))
(titles (if (node-list-empty? parent-titles)
info-titles
parent-titles))
(subtitles (select-elements exp-children (normalize "subtitle")))
(renderas (inherited-attribute-string (normalize "renderas") sect))
;; the apparent section level
(hlevel
;; if not real section level, then get the apparent level
;; from "renderas"
(if renderas
(section-level-by-gi #f (normalize renderas))
;; else use the real level
(SECTLEVEL)))
(hs (HSIZE (- 5 hlevel))))
(make sequence
(make paragraph
font-family-name: %title-font-family%
font-weight: (if (< hlevel 5) 'bold 'medium)
font-posture: (if (< hlevel 5) 'upright 'italic)
font-size: hs
line-spacing: (* hs %line-spacing-factor%)
space-before: (* hs %head-before-factor%)
space-after: (if (node-list-empty? subtitles)
(* hs %head-after-factor%)
0pt)
start-indent: (if (or (>= hlevel 3)
(member (gi) (list (normalize "refsynopsisdiv")
(normalize "refsect1")
(normalize "refsect2")
(normalize "refsect3"))))
%body-start-indent%
0pt)
first-line-start-indent: 0pt
quadding: %section-title-quadding%
keep-with-next?: #t
heading-level: (if %generate-heading-level% hlevel 0)
;; SimpleSects are never AUTO numbered...they aren't hierarchical
(if (string=? (element-label (current-node)) "")
(empty-sosofo)
(literal (element-label (current-node))
(gentext-label-title-sep (gi sect))))
(element-title-sosofo (current-node))
($TAGID$ (current-node))
)
(with-mode section-title-mode
(process-node-list subtitles))
($proc-section-info$ info))))
(element sidebar
(make display-group
space-before: %block-sep%
(make box
;display?: #t
;break-after: 'page
box-type: 'border
line-thickness: 1pt
start-indent: (- (inherited-start-indent) 20pt)
end-indent: (inherited-end-indent)
(if (node-list-empty? (select-elements (children (current-node))
(normalize "title")))
(make display-group
start-indent: 2pt