<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [

<!-- must turn on one of these with -i on the jade command line -->
<!ENTITY % html          "IGNORE">
<!ENTITY % print         "IGNORE">

<![ %html; [
<!ENTITY dbstyle PUBLIC "-//Norman Walsh//DOCUMENT DocBook HTML
Stylesheet//EN" CDATA DSSSL>
]]>

<![ %print; [
<!ENTITY dbstyle PUBLIC "-//Norman Walsh//DOCUMENT DocBook Print
Stylesheet//EN" CDATA DSSSL>
]]>

]>

<style-sheet>
 <style-specification use="docbook">
  <style-specification-body>


;; PAPER

<![ %print; [

(declare-characteristic heading-level
      "UNREGISTERED::James Clark//Characteristic::heading-level" 2)

(define %para-sep% (/ %bf-size% 4.0) )

(define %indent-programlisting-lines% "  " )

(element sect1 ($section1$))

;; Enables page break per sect1
(define ($section1$)
  (if (node-list=? (current-node) (sgml-root-element))
      (make simple-page-sequence
        page-n-columns: %page-n-columns%
        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%
        (make sequence
          ($section-title$)
          (process-children)))
      (make display-group
        space-before: %block-sep%
        space-after: %block-sep%
        start-indent: %body-start-indent%
        break-before: 'page
        (make sequence
          ($section-title$)
          (process-children)))))

(define %paper-type%
  ;; Name of paper type
  ;; "USletter"
  "A4")

(define %two-side% 
  ;; Is two-sided output being produced?
  #t)

;; Titlepage and TOC

(define %generate-article-titlepage% 
  ;; Should an article title page be produced?
  #t)

(define %generate-article-toc%
  ;; Should a Table of Contents be produced for Articles?
  #t)

(define %generate-article-toc-on-titlepage%
  ;; Should the Article TOC appear on the Article title page?
  #f)

(define (toc-depth nd)
  3)

(define %section-autolabel%
  ;; Are sections enumerated?
  #t)

(define %body-start-indent%
  ;; Default indent of body text
  0pi)

(define %hyphenation%
  ;; Allow automatic hyphenation?
  #t)

(element ( itemizedlist title )
  (
    make paragraph
    use: default-text-style
    start-indent: %body-start-indent%
  )
)

(element (funcsynopsis)  
  (
    make sequence
    use: verbatim-style
    start-indent: 0.2in
    (process-children)
  )
)

(element (synopsis)  
  (
    make sequence
    use: verbatim-style
    (process-children)
  )
)

(element (itemizedlist)  
  (
    make display-group
    start-indent: (+ (inherited-start-indent) 0.1in )
    (process-children)
  )
)

(define %para-indent-firstpara%
  ;; First line start-indent for the first paragraph
  0pt)

(define %para-indent%
  ;; First line start-indent for paragraphs (other than the first)
  0pt)

(define %block-start-indent%
  ;; Extra start-indent for block-elements
  0pt)

(define %admon-graphics%
  ;; Use graphics in admonitions?
  #f)

(define %default-quadding%
  ;; Full justification.
  'justify)

(define (book-titlepage-verso-elements)
  ;;added publisher, releaseinfo to the default list
  (list (normalize "title")
        (normalize "subtitle")
        (normalize "corpauthor")
        (normalize "authorgroup")
        (normalize "author")
        (normalize "publisher")
        (normalize "releaseinfo")
        (normalize "editor")
        (normalize "edition")
        (normalize "pubdate")
        (normalize "copyright")
        (normalize "abstract")
        (normalize "legalnotice")
        (normalize "revhistory")))
]]>


<![ %html; [


(define %generate-legalnotice-link%
  ;; put the legal notice in a separate file
  #t)

(define %html-ext%
  ;; when producing HTML files, use this extension
  ".html")

(define %generate-article-toc% 
  ;; Should a Table of Contents be produced for articles?
  #t)

;; Put date of creation into HTML header
(define %html-header-tags%
  (list 
    (list "META" '("NAME" "creation") (list "CONTENT" (time->string (time) #t)))
    '("META" ("HTTP-EQUIV" "Content-Type") ("CONTENT" "text/html; charset=utf-8"))
  )
)

(define %stylesheet%  "pg_sphere.css")

(define %generate-article-titlepage%
  ;; produce a title page for articles
  #t)

(define (chunk-skip-first-element-list)
  ;; forces the Table of Contents on separate page
  '())

(define (list-element-list)
  ;; fixes bug in Table of Contents generation
  '())

(define %root-filename%
  ;; The filename of the root HTML document (e.g, "index").
  "index")

(define ($shade-verbatim-attr$)
  ;; REFENTRY shade-verbatim-attr
  ;; PURP Attributes used to create a shaded verbatim environment.
  ;; DESC
  ;; See '%shade-verbatim%'
  ;; /DESC
  ;; AUTHOR N/A
  ;; /REFENTRY
  (list
   (list "BORDER" "0")
   (list "BGCOLOR" "#F7F7F7")
   (list "WIDTH" ($table-width$))))

;; ...but we need to do some extra work to make the above apply to PRE
;; as well.  (mostly pasted from dbverb.dsl)
(define ($verbatim-display$ indent line-numbers?)
  (let ((content (make element gi: "PRE"
                       attributes: (list
                                    (list "CLASS" (gi)))
                       (if (or indent line-numbers?)
                           ($verbatim-line-by-line$ indent line-numbers?)
                           (process-children)))))
    (if %shade-verbatim%
        (make element gi: "TABLE"
              attributes: ($shade-verbatim-attr$)
              (make element gi: "TR"
                    (make element gi: "TD"
                          content)))
	(make sequence
	  (para-check)
	  content
	  (para-check 'restart)))))

(define %shade-verbatim%
  ;; verbatim sections will be shaded if t(rue)
  #f)

(define %use-id-as-filename%
  ;; Use ID attributes as name for component HTML files?
  #t)

(define %graphic-extensions%
  ;; graphic extensions allowed
  '("jpg" "jpeg" "png"))

(define %graphic-default-extension% 
  "jpg")

(define %section-autolabel%
  ;; For enumerated sections (1.1, 1.1.1, 1.2, etc.)
  #t)

(define (toc-depth nd)
  ;; more depth (3 levels) to toc; instead of flat hierarchy
  2)

(element emphasis
  ;; make role=strong equate to bold for emphasis tag
  (if (equal? (attribute-string "role") "strong")
     (make element gi: "STRONG" (process-children))
     (make element gi: "EM" (process-children))))

(define (article-titlepage-recto-elements)
  ;; elements on an article's titlepage
  (list (normalize "title")
        (normalize "subtitle")
        (normalize "authorgroup")
        (normalize "author")
        (normalize "othercredit")
        (normalize "releaseinfo")
        (normalize "copyright")
        (normalize "pubdate")
        (normalize "revhistory")
        (normalize "abstract")
        (normalize "legalnotice")))

(define (article-title nd)
  (let* ((artchild  (children nd))
         (artheader (select-elements artchild (normalize "artheader")))
         (artinfo   (select-elements artchild (normalize "articleinfo")))
         (ahdr (if (node-list-empty? artheader)
                   artinfo
                   artheader))
         (ahtitles  (select-elements (children ahdr)
                                     (normalize "title")))
         (artitles  (select-elements artchild (normalize "title")))
         (titles    (if (node-list-empty? artitles)
                        ahtitles
                        artitles)))
    (if (node-list-empty? titles)
        ""
        (node-list-first titles))))

(mode subtitle-mode
  ;; do not print subtitle on subsequent pages
  (element subtitle (empty-sosofo)))

;; notes.
(element note
  (make sequence
    (para-check)
    ($admonition$)
    (para-check 'restart)))

]]>

  </style-specification-body>
</style-specification>

<external-specification id="docbook" document="dbstyle">

</style-sheet>
