print.dsl
branchstyles
changeset 0 08de8d15f932
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/print.dsl	Tue Dec 27 13:55:27 2005 -0500
@@ -0,0 +1,471 @@
+<!doctype dsssl-specification [
+<!entity % decls "(features? & char-repertoire?)">
+<!element dsssl-specification O O (%decls;, style-specification+)>
+<!attlist dsssl-specification
+  dsssl name #fixed dsssl-specification
+>
+<!element style-specification - O (%decls;, style*)>
+<!attlist style-specification
+  dsssl name #fixed style-specification
+  id id #required
+  partial (partial | complete) complete
+  use idrefs #implied
+>
+<!element char-repertoire - o empty>
+<!attlist char-repertoire
+  dsssl name #fixed character-repertoire
+  name cdata #required
+>
+<!element features - o (#pcdata)>
+<!element style - - rcdata>
+<!attlist style
+  dsssl name #fixed style-specification-body
+>
+]>
+<dsssl-specification>
+<style-specification id=common partial>
+<char-repertoire name="UNREGISTERED::SGML Open//Character Repertoire::ISO/IEC 10646">
+<features>table</features>
+<style>
+(element quote
+  (sosofo-append
+   (make character
+     char: #\left-double-quotation-mark)
+   (process-children)
+   (make character
+     char: #\right-double-quotation-mark)))
+
+(element emph
+  (make sequence
+    font-weight: 'bold))
+
+(define monospace-font-family "iso-monospace")
+
+(element code
+  (make sequence
+    font-family: monospace-font-family))
+
+(declare-initial-value writing-mode 'left-to-right)
+(declare-initial-value font-size 12pt)
+(declare-initial-value line-spacing 14pt)
+(declare-initial-value font-family "iso-serif")
+
+(define-unit mm .001m)
+(define-unit in 25.4mm)
+(define-unit pt (/ 1in 72))
+(define-unit pi (/ 1in 6))
+
+(define paragraph-indent 20pt)
+
+(element p
+  (make paragraph
+    first-line-start-indent: (if (first-sibling?)
+                                 0pt
+                                 paragraph-indent)))
+
+(define chapter-title-style
+  (style
+    font-size: 18pt
+    line-spacing: 24pt
+    quadding: 'center))
+
+(element (chapter title)
+  (sosofo-append
+    (make paragraph
+      use: chapter-title-style
+      span: 2
+      (literal "Chapter "
+               (format-number (child-number) "1")))
+    (make paragraph
+      use: chapter-title-style
+      span: 2)))
+
+(element (section title)
+  (make paragraph
+    quadding: 'start
+    (format-number-list (hierarchical-number '("CHAPTER" "SECTION"))
+                        "1"
+                        ".")
+    (literal ". ")
+    (process-children)))
+
+(define indent-step 60pt)
+
+(element ol
+  (make sequence
+    start-indent: (+ (inherited-start-indent)
+                     indent-step)))
+
+(element li
+  (make paragraph
+    first-line-start-indent: (- indent-step)
+    (make line-field
+      field-width: indent-step
+      field-align: 'start
+      (literal (format-number (child-number)
+                              (if (have-ancestor? '("OL" "OL"))
+                                  "a"
+                                  "1"))))
+    (process-children)))
+
+(element dl
+  (make table
+    table-width: (- (display-size)
+                    (inherited-start-indent)
+                    (inherited-end-indent))
+    (make sequence
+      start-indent: 0pt
+      end-indent: 0pt
+      (make table-column
+        column-number: 2
+        width: (table-unit 1))
+      (process-children))))
+
+(element dt
+  (make table-cell
+    starts-row?: #t))
+
+(element dd
+  (make table-cell
+    start-indent: 10pt
+    ends-row?: #t))
+
+(element caption
+  (make paragraph))
+
+(element artwork
+  (make external-graphic
+    display?: #t
+    scale: 'to-fit
+    notation-system-id: (notation-generated-system-id
+                         (entity-notation
+                          (attribute-string "CONTENT")))
+    system-id: (entity-generated-system-id
+                (attribute-string "CONTENT"))))
+
+(element xref
+  (with-mode xref
+    (process-node-list (element-with-id (attribute-string "REFID")))))
+
+</style>
+</style-specification>
+<style-specification id=softcopy use=common>
+<style>
+
+(mode xref
+  (element chapter
+    (make link
+      destination: (current-node-address)
+      color: blue-color
+      (process-first-descendant 'title)))
+  (element figure
+    (make multi-mode
+      multi-modes: '(#f popup)
+      principal-mode-simultaneous?: #t
+      (process-first-descendant 'caption)
+      (make vertical-scroll
+        label: 'popup
+        (with-mode #f
+          (process-node-list (current-node)))))))
+
+(define rgb
+  (color-space "ISO/IEC 10179:1995//Color Space Family::Device RGB"))
+
+(define blue-color (rgb 0 0 1))
+
+(element doc
+  (make vertical-scroll
+    left-margin: 20pt))
+
+(element (doc title)
+  (make paragraph
+    font-size: 28pt
+    line-spacing: 32pt
+    quadding: 'center))
+
+(element note
+  (make multi-mode
+    multi-modes: '(#f expand)
+    (make marginalia
+      marginalia-side: 'start
+      (make character
+	font-name: "UNREGISTERED::SGML Open//Font::Icons"
+        glyph-id: "UNREGISTERED::SGML Open//Glyph::Light bulb icon"))
+    (make vertical-scroll
+      label: 'expand
+      (make paragraph))))
+
+</style>
+</style-specification>
+<style-specification id=hardcopy use=common>
+<features>page multi-column query expression</features>
+<style>
+
+(define chapter-opening-sink 12pi)
+(define column-measure 20pi)
+(define column-separation 2pi)
+(define page-width 210mm)
+(define page-height 297mm)
+(define inner-margin 6pi)
+(define column-depth 54pi)
+(define top-margin 9pi)                 ; top of page to top of column
+(define header-margin 5pi)              ; top of page to top of header
+(define header-line-spacing 12pt)
+(define footer-line-spacing 12pt)
+(define folio-margin 5pi) ; from bottom of folio to bottom of page
+
+(define page-region-width
+  (+ column-measure column-separation column-measure))
+(define footer-height
+  (- page-height top-margin column-depth folio-margin))
+(define header-height
+  (- top-margin header-margin))
+(define normal-page-region-height
+  (- page-height header-margin folio-margin))
+
+(element (doc title)
+  (sosofo-append
+   (make page-sequence
+     initial-page-models: (list chapter-first-page)
+     (make paragraph
+       font-size: 28pt
+       line-spacing: 32pt
+       quadding: 'center))
+   (table-of-contents)))
+
+(declare-reference-value-type chapter-title)
+(declare-reference-value-type section-title)
+
+(element (chapter title)
+  (sosofo-append
+    (make paragraph
+      use: chapter-title-style
+      span: 2
+      (literal "Chapter "
+               (format-number (child-number) "1")))
+    (make paragraph
+      use: chapter-title-style
+      span: 2
+      chapter-title: (process-children))))
+
+(element (section title)
+  (make paragraph
+    quadding: 'start
+    section-title: (process-children)
+    (format-number-list (hierarchical-number '("CHAPTER" "SECTION"))
+                        "1"
+                        ".")
+    (literal ". ")
+    (process-children)))
+
+(define-page-model chapter-first-page
+  (region
+   (x-origin inner-margin)
+   (y-origin folio-margin)
+   (width page-region-width)
+   (height (- page-height top-margin chapter-opening-sink folio-margin))
+   (flow #f)
+   (footer
+    (contents-alignment 'end)
+    (height footer-height)
+    (generate (make-page-footer)))
+   (filling-direction 'top-to-bottom)))
+
+(define-page-model chapter-recto-page
+  (region
+   (x-origin inner-margin)
+   (y-origin folio-margin)
+   (width page-region-width)
+   (height normal-page-region-height)
+   (header
+    (generate (make paragraph
+                line-spacing: header-line-spacing
+                quadding: 'end
+                font-posture: 'italic
+                (asis-indirect-sosofo
+                 (find-reference-value 'section-title))))
+    (contents-alignment 'start)
+    (height header-height))
+   (footer
+    (contents-alignment 'end)
+    (height footer-height)
+    (generate (make-page-footer)))
+   (flow #f))
+  (filling-direction 'top-to-bottom))
+
+(define-page-model chapter-verso-page
+  (region
+   (x-origin (- page-width inner-margin page-region-width))
+   (y-origin folio-margin)
+   (width page-region-width)
+   (height normal-page-region-height)
+   (header
+    (generate (make paragraph
+                line-spacing: header-line-spacing
+                quadding: 'start
+                font-posture: 'italic
+                (asis-indirect-sosofo
+                 (find-reference-value 'chapter-title))))
+    (contents-alignment start)
+    (height header-height))
+   (footer
+    (contents-alignment 'end)
+    (height footer-height)
+    (generate (make-page-footer)))
+   (flow #f))
+  (filling-direction 'top-to-bottom))
+
+(define (find-reference-value type)
+  (first-area-reference-value type
+                              default: (last-preceding-area-reference-value
+                                        type)))
+
+(define (make-page-footer)
+  (make paragraph
+    quadding: 'center
+    line-spacing: footer-line-spacing
+    (number-indirect-sosofo (page-number))))
+
+(element chapter
+  (make page-sequence
+    force-first-page: 'front
+    initial-page-models: (list chapter-first-page)
+    repeat-page-models: (list chapter-verso-page
+                              chapter-recto-page)
+    blank-back-page-model: chapter-verso-page
+    (make column-set-sequence
+      column-set-model: double-columns)))
+
+(define-column-set-model double-columns
+  (column-subset
+   (column
+    (x-origin 0pt)
+    (width column-measure))
+   (column
+    (x-origin (+ column-measure column-separation))
+    (width column-measure))
+   (flow
+    (main body-text)
+    (figure top-float bottom-float)
+    (footnote footnote))))
+
+(element figure
+  (sync (make anchor
+          display?: #t)
+        (make sequence
+          keep: #t
+          label: 'figure
+          span: (if (equal? (attribute-string "SPAN")
+                            "SPAN")
+                    2
+                    1))
+        type: 'page
+        max: 1))
+
+(define footnote-font-size 8pt)
+(define superscript-shift-ems .4) ; ems to shift up superscript for footnote
+;; factor by which to multiply font size for superscripts
+(define superscript-size-factor .6)
+
+(element note
+  (let ((footnote-label
+         (literal (format-number (note-number) "1"))))
+    (sync (make sequence
+            font-size: (* (inherited-font-size)
+                          superscript-size-factor)
+            placement-offset: (- (* (inherited-font-size)
+                                    superscript-shift-ems))
+            footnote-label)
+          (make paragraph
+            label: 'footnote
+            font-size: footnote-font-size
+            footnote-label
+            (literal ". ")
+            (process-children))
+          type: 'page)))
+
+;; Footnotes are numbered per chapter.
+
+(define (note-number)
+  (list-ref (element-number-list '("CHAPTER" "NOTE"))
+            1))
+
+(mode xref
+  (element figure
+    (sosofo-append
+     (literal "Figure "
+              (format-number (element-number) "1"))
+     (literal ", page")
+     (number-indirect-sosofo (page-number))))
+  (element chapter
+    (sosofo-append
+     (literal "Chapter "
+              (format-number (child-number) "1")
+              ", ")
+     (make sequence
+       font-posture: 'italic
+       (process-first-descendant 'title))
+     (literal ", page")
+     (number-indirect-sosofo (page-number)))))
+
+(define (table-of-contents)
+  (make page-sequence
+    force-first-page: 'front
+    repeat-page-models: (list chapter-first-page)
+    (make sequence
+      (make paragraph
+        use: chapter-title-style
+        (literal "Table of Contents"))
+      (with-mode toc
+        (process-node-list (q-element 'title (tree-root (current-node))))))))
+
+(mode toc
+  (element title
+    (make paragraph
+      (literal (format-number (ancestor-child-number "CHAPTER") "1"))
+      (if (have-ancestor? "SECTION")
+          (literal "."
+                   (format-number (ancestor-child-number "SECTION") "1"))
+          (empty-sosofo))
+      (literal ". "))
+      (process-children)
+      (make leader (literal "."))
+      (number-indirect-sosofo (page-number))))
+
+</style>
+</style-specification>
+<style-specification id=hardcopy2 use=hardcopy>
+<style>
+(element xref
+  (map-constructor (let ((x (current-node)))
+                     (lambda()
+                       (process-xref x)))
+                   (element-with-id (attribute-string "REFID"))))
+
+(define (process-xref xref-node)
+  (if (match-element? 'chapter (current-node))
+      (with-mode xref
+        (process-node-list (current-node)))
+      (sosofo-append
+       (literal "Figure "
+                (format-number (element-number) "1"))
+       (general-indirect-sosofo page-ref-if-different
+                                (page-number first-area-of-node: (current-node))
+                                (page-number first-area-of-node: xref-node)))))
+
+(define (page-ref-if-different figure-page current-page)
+  (if (equal? figure-page current-page)
+      (empty-sosofo)
+      (literal ", page "
+               (format-number figure-page "1"))))
+
+</style>
+</style-specification>
+</dsssl-specification>
+<!-- Keep this comment at the end of the file
+Local variables:
+mode: dsssl
+sgml-indent-step:0
+sgml-indent-data:nil
+End:
+-->