From 31a924b7a69348fa0136b26ba3a29d14118125b409104382ba624a221cbfd410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Fri, 3 May 2024 12:07:10 +0200 Subject: [PATCH] Sync from SUSE:SLFO:Main docbook-dsssl-stylesheets revision 026d6e8cf02357d44c3ad32e466d0e8e --- .gitattributes | 23 + dbtohtml.dsl | 2247 +++++++++++++++++++++++++ docbkdsl.dif | 20 + docbook-dsssl-1.79.tar.gz | 3 + docbook-dsssl-doc-1.79.tar.gz | 3 + docbook-dsssl-stylesheets-README.SUSE | 14 + docbook-dsssl-stylesheets.changes | 331 ++++ docbook-dsssl-stylesheets.spec | 161 ++ ld2db.dsl | 860 ++++++++++ 9 files changed, 3662 insertions(+) create mode 100644 .gitattributes create mode 100644 dbtohtml.dsl create mode 100644 docbkdsl.dif create mode 100644 docbook-dsssl-1.79.tar.gz create mode 100644 docbook-dsssl-doc-1.79.tar.gz create mode 100644 docbook-dsssl-stylesheets-README.SUSE create mode 100644 docbook-dsssl-stylesheets.changes create mode 100644 docbook-dsssl-stylesheets.spec create mode 100644 ld2db.dsl diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/dbtohtml.dsl b/dbtohtml.dsl new file mode 100644 index 0000000..eca3e25 --- /dev/null +++ b/dbtohtml.dsl @@ -0,0 +1,2247 @@ + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; dbtohtml.dsl - DSSSL style sheet for DocBook to HTML conversion (jadeware) +; +; Author : Mark Burton (markb@ordern.com) +; Created On : Fri Jun 13 18:21:14 1997 +; Last Modified By: Mark Burton +; Last Modified On: Sat Nov 21 22:04:53 1998 +; +; $Id: dbtohtml.dsl,v 1.23 1998/11/21 22:11:14 markb Exp $ +; +; Usage: +; +; jade -d dbtohtml.dsl -t sgml yourdoc.sgm +; +; Additional command line options: +; +; -V %no-split-output% sends all the output to one file +; -V %no-make-index% disables index creation +; -V %no-make-toc% disables TOC creation +; -V %no-shade-screen% disables grey background to SCREEN regions +; -V %show-comments% includes contents of COMMENT regions +; +; See below for more variables that can be set. + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Contributors + +; Mark Eichin (eichin@cygnus.com) +; Jason Molenda (crash@cygnus.co.jp) +; Tony Graham (tgraham@mulberrytech.com) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Parameterisation + +; This style sheet can easily be parameterised by the use of a driver. +; Here is a simple example that sets the output file basename and directory. +; If the driver is foo.dsl, use: jade -d foo.dsl -t sgml yourdoc.sgm + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; declare non-standard functions + +(declare-flow-object-class element + "UNREGISTERED::James Clark//Flow Object Class::element") +(declare-flow-object-class empty-element + "UNREGISTERED::James Clark//Flow Object Class::empty-element") +(declare-flow-object-class document-type + "UNREGISTERED::James Clark//Flow Object Class::document-type") +(declare-flow-object-class processing-instruction + "UNREGISTERED::James Clark//Flow Object Class::processing-instruction") +(declare-flow-object-class entity + "UNREGISTERED::James Clark//Flow Object Class::entity") +(declare-flow-object-class entity-ref + "UNREGISTERED::James Clark//Flow Object Class::entity-ref") +(declare-flow-object-class formatting-instruction + "UNREGISTERED::James Clark//Flow Object Class::formatting-instruction") + +(declare-characteristic preserve-sdata? + "UNREGISTERED::James Clark//Characteristic::preserve-sdata?" #f) + +(define all-element-number + (external-procedure "UNREGISTERED::James Clark//Procedure::all-element-number")) + +(define debug + (external-procedure "UNREGISTERED::James Clark//Procedure::debug")) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; variables + +(define %no-split-output% #f) ; if #t puts all output in one file +(define %no-split-refentries% #f) ; if #t don't put refentries + ; in separate files +(define %no-make-toc% #f) ; if #t disables TOC creation +(define %no-make-index% #f) ; if #t disables index creation +(define %no-shade-screen% #f) ; if #t disables grey + ; background to SCREEN regions +(define %show-comments% #f) ; if #t includes contents of + ; COMMENT regions +(define %shade-width% "100%") ; width string or #f +(define %email-element% "TT") ; font changing element or #f + +(define %lineannotation-color% "green") ; colour or #f (ignored if + ; %stylesheet-name% is not #f) + +(define %warning-color% "red") ; colour or #f +(define %important-color% #f) ; colour or #f +(define %caution-color% #f) ; colour or #f +(define %tip-color% #f) ; colour or #f +(define %note-color% #f) ; colour or #f +(define %example-color% #f) ; colour or #f + +(define %display-dpi% 100) ; for converting lengths into pixels + +(define %centre-figures% #t) ; whether figures should be centred + +(define %default-graphic-format% "gif") +(define %graphic-directory% #f) ; name of directory containing + ; graphics or #f + +(define %html-public-id% "-//W3C//DTD HTML 4.0//EN") + +(define %stylesheet-name% #f) ; name of css style-sheet to + ; be used or #f +(define %have-javascript% #f) ; true if browser groks JavaScript +(define %make-nav-links% #f) ; true if pages should have + ; navigation links at their + ; top and bottom +(define %body-bgcolor% "white") ; document background colour + ; (ignored if %stylesheet-name% is + ; not #f +(define %output-directory% ".") ; where to write generated HTML +(define %output-basename% "DBTOHTML") ; generated filenames are + ; based on this +(define %output-suffix% ".html") ; generated filename suffix +(define %newline% "\U-000D") ; there must be an easier way + ; to specify \n + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; top-level sections + +(element BOOK + (if %no-split-output% ; everything goes in one file + (make-file (string-append %output-basename% %output-suffix%) + (make sequence + (process-children) + (cond ((not %no-make-index%) + (make sequence + (make-fat-rule) + (make-index))) + (#t (empty-sosofo)))) + (current-node) + (node-list) + (node-list)) + (make sequence ; split output into separate files + (let* ((content (make sequence + (process-first-descendant "TITLE") + (process-first-descendant "BOOKINFO"))) + (children (children (current-node))) + (linkable-children (node-list (select-elements children "PREFACE") + (select-elements children "ARTICLE") + (select-elements children "CHAPTER") + (select-elements children "APPENDIX")))) + (make-file (string-append %output-basename% %output-suffix%) + (if %stylesheet-name% + (make element + gi: "DIV" + attributes: '(("class" "book")) + content) + content) + (current-node) + (node-list-last linkable-children) + (node-list-first linkable-children))) + (process-matching-children "PREFACE" + "ARTICLE" + "CHAPTER" + "APPENDIX" + "BIBLIOGRAPHY" + "GLOSSARY" + "ARTHEADER") + (if %no-make-index% + (empty-sosofo) + (make-file (index-file-name) + (make sequence + (make-nav-links (current-node)) + (make-index) + (make-nav-links (current-node))) + (current-node) + (node-list) + (node-list)))))) + +(define (make-file file-name content top-node preceding-node following-node) + (make entity + system-id: (string-append %output-directory% "/" file-name) + (make sequence + (make document-type + name: "HTML" + public-id: %html-public-id%) + (make element + gi: "HTML" + (make sequence + (make element + gi: "HEAD" + (make sequence + (make element + gi: "TITLE" + (with-mode extract-title-text + (process-first-descendant "TITLE"))) + (if %stylesheet-name% + (make empty-element + gi: "LINK" + attributes: (list (list "rel" "stylesheet") + (list "type" "text/css") + (list "href" %stylesheet-name%))) + (empty-sosofo)) + (if %have-javascript% + (make element + gi: "SCRIPT" + attributes: '(("type" "text/javascript")) + (make sequence + (make formatting-instruction + data: (string-append %newline% "<" "!--" %newline%)) + (literal "var toppage='" + (link-file-name top-node) + "';" %newline% + "var nextpage='" + (if (node-list-empty? following-node) + (link-file-name top-node) + (link-file-name following-node)) + "';" %newline% + "var prevpage='" + (if (node-list-empty? preceding-node) + (link-file-name top-node) + (link-file-name preceding-node)) + "';" %newline% + (if %no-make-index% + "" + (string-append "var indexpage='" + (index-file-name) + "';" %newline%)) + ) + (make formatting-instruction + data: (string-append "// -->" %newline%)))) + (empty-sosofo)))) + (make element + gi: "BODY" + attributes: (if %stylesheet-name% + (list) + (list (list "bgcolor" %body-bgcolor%))) + (make sequence + (if %stylesheet-name% + (make element + gi: "DIV" + (make-anchor)) + (make-anchor)) + content + (make-footer)))))))) + +(define (make-footer) + (let ((copyright (select-elements (descendants (book-node)) + '("BOOKINFO" "COPYRIGHT")))) + (cond ((node-list-empty? copyright) (empty-sosofo)) + (#t (make sequence + (make-fat-rule) + (process-node-list copyright)))))) + +(define (node-list-last nl) + (node-list-ref nl (- (node-list-length nl) 1))) + +(define (filtered-preceding-node) + (let* ((preceding-node (node-list-last (preced (current-node)))) + (acceptable-neighbours '("CHAPTER" "APPENDIX" "GLOSSARY" "REFENTRY"))) + (if (member (gi preceding-node) acceptable-neighbours) + preceding-node + (node-list)))) + +(define (filtered-following-node) + (let* ((following-node (node-list-first (follow (current-node)))) + (acceptable-neighbours '("CHAPTER" "APPENDIX" "GLOSSARY" "REFENTRY"))) + (if (member (gi following-node) acceptable-neighbours) + following-node + (node-list)))) + +(define (make-nav-links up-node) + (if %make-nav-links% + (let ((gubbins + (let ((filtered-preceding-node (filtered-preceding-node)) + (filtered-following-node (filtered-following-node))) + (make sequence + (make empty-element + gi: "P") + (make element + gi: "A" + attributes: (list (list "href" (link-file-name up-node))) + (literal "Up")) + (literal " ") + (if (node-list-empty? filtered-following-node) + (empty-sosofo) + (make element + gi: "A" + attributes: (list (list "href" + (link-file-name filtered-following-node))) + (literal "Forward"))) + (literal " ") + (if (node-list-empty? filtered-preceding-node) + (empty-sosofo) + (make element + gi: "A" + attributes: (list (list "href" + (link-file-name filtered-preceding-node))) + (literal "Back"))) + (make empty-element + gi: "P"))))) + (if %stylesheet-name% + (make element + gi: "DIV" + attributes: '(("class" "navlinks")) + gubbins) + gubbins)) + (empty-sosofo))) + +(define (make-major-div) + (cond (%no-split-output% + (make sequence + (make-anchor) + (make-fat-rule) + (process-children))) + (#t + (make-file (link-file-name (current-node)) + (make sequence + (make-nav-links (book-node)) + (if %stylesheet-name% + (make element + gi: "DIV" + attributes: '(("class" "chapter")) + (process-children)) + (process-children)) + (make-nav-links (book-node))) + (book-node) + (filtered-preceding-node) + (filtered-following-node))))) + +(element ARTICLE (make-major-div)) + +(element PREFACE (make-major-div)) + +(element CHAPTER (make-major-div)) + +(element APPENDIX (make-major-div)) + +(element BEGINPAGE (make-thin-rule)) + +(element BIBLIOGRAPHY (make-major-div)) + +(element BOOKBIBLIO (process-children)) + +(element BIBLIODIV (process-children)) + +(element GLOSSARY (make-major-div)) + +; (element GLOSSDIV (make-major-div)) + +(element ARTHEADER (process-children)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; sections + +(element SECT1 + (make sequence + (make empty-element + gi: "P") + (make-anchor) + (process-children))) + +(element SECT2 + (make sequence + (make-anchor) + (process-children))) + +(element SECT3 + (make sequence + (make-anchor) + (process-children))) + +(element SECT4 + (make sequence + (make-anchor) + (process-children))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; reference pages + +(element REFENTRY + (if (or %no-split-output% %no-split-refentries%) + (make sequence + (make-anchor) + (make-fat-rule) + (process-children)) + (let ((filename (link-file-name (current-node))) + (title-text (with-mode make-toc-links (process-first-descendant "REFMETA")))) + (make sequence + (make-file filename + (make sequence + (make-nav-links (parent (current-node))) + (if %stylesheet-name% + (make element + gi: "DIV" + attributes: '(("class" "refentry")) + (process-children)) + (process-children)) + (make-nav-links (parent (current-node)))) + (parent (current-node)) + (filtered-preceding-node) + (filtered-following-node)) + (make empty-element + gi: "P") + (make element + gi: "A" + attributes: (list (list "href" filename)) + title-text))))) + +(define (refmeta) + (make sequence + (process-matching-children "REFENTRYTITLE") + (literal "(") + (process-matching-children "MANVOLNUM") + (literal ")"))) + +(define (refentrytitle) + (process-children-trim)) +(define (manvolnum) + (process-children-trim)) + +(mode make-toc-links + (element REFMETA (refmeta)) + (element REFENTRYTITLE (refentrytitle)) + (element MANVOLNUM (manvolnum))) + +(element REFMETA + (if %stylesheet-name% + (make element + gi: "DIV" + attributes: '(("style" "text-align: right")) + (refmeta)) + (refmeta))) + +(element REFENTRYTITLE (refentrytitle)) +(element MANVOLNUM (manvolnum)) + +(element REFNAMEDIV + (make sequence + (make element + gi: "H2" + (literal "NAME")) + (process-matching-children "REFNAME") + (literal " - ") + (process-matching-children "REFPURPOSE"))) + +(element REFNAME (process-children-trim)) +(element REFPURPOSE (process-children-trim)) + +(element REFSYNOPSISDIV (process-children)) +(element REFSECT1 (process-children)) +(element REFSECT2 (process-children)) +(element REFSECT3 (process-children)) +(element REFSECT4 (process-children)) + +(element CMDSYNOPSIS + (make element + gi: "TT")) + +(element ARG + (let ((optional (equal? (attribute-string "CHOICE") "OPT")) + (repeat (equal? (attribute-string "REP") "REPEAT")) + (content (process-children-trim))) + (if optional + (make sequence + (literal " [ ") + content + (if repeat + (literal " ... ") + (empty-sosofo)) + (literal " ] ")) + (make sequence + (literal " ") + content + (if repeat + (literal " ... ") + (empty-sosofo)) + (literal " "))))) + +(element FUNCSYNOPSIS + (let ((gubbins (make sequence + (process-matching-children "FUNCSYNOPSISINFO") + (process-matching-children "FUNCDEF" "PARAMDEF")))) + (if %stylesheet-name% + gubbins + (make element + gi: "TT" + gubbins)))) + +(element FUNCSYNOPSISINFO + (make element + gi: "PRE" + attributes: '(("class" "funcsynopsisinfo")))) + +(element FUNCDEF + (make sequence + (make empty-element + gi: "TABLE") + (make empty-element + gi: "TR" + attributes: (list '("valign" "top"))) + (make empty-element + gi: "TD") + (make empty-element + gi: "PRE" + attributes: '(("class" "plain"))) + (make empty-element + gi: "TT") + (process-children-trim))) + +(element PARAMDEF + (let ((head (if (equal? (gi (node-list-last (preced (current-node)))) + "PARAMDEF") + (literal ", ") + (make sequence + (literal "(") + (make empty-element + gi: "/TT") + (make empty-element + gi: "/PRE") + (make empty-element + gi: "TD") + (make empty-element + gi: "TT")))) + (tail (if (equal? (gi (node-list-first (follow (current-node)))) + "PARAMDEF") + (empty-sosofo) + (make sequence + (literal " );") + (make empty-element + gi: "/TT") + (make empty-element + gi: "/TABLE"))))) + (make sequence + head + (process-children-trim) + tail))) + +(element CITEREFENTRY + (make sequence + (process-matching-children "REFENTRYTITLE") + (literal "(") + (process-matching-children "MANVOLNUM") + (literal ")"))) + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; titles + +(mode extract-title-text + (element (TITLE) + (process-children))) + +(element (BOOK TITLE) + (let ((content (make element + gi: "H1" + attributes: '(("class" "book")) + (process-children-trim)))) + (if %stylesheet-name% + content + (make element + gi: "CENTER" + content)))) + +(element (CHAPTER TITLE) + (make element + gi: "H1" + attributes: '(("class" "chapter")) + (make sequence + (literal (chap-app-head-label "Chapter")) + (process-children-trim)))) + +(element (APPENDIX TITLE) + (make element + gi: "H1" + attributes: '(("class" "appendix")) + (make sequence + (literal (chap-app-head-label "Appendix")) + (process-children-trim)))) + +(element (BIBLIOGRAPHY TITLE) + (make element + gi: "H1" + attributes: '(("class" "bibliography")) + (make sequence + (literal (chap-app-head-label "Bibliography")) + (process-children-trim)))) + +(element (BOOKBIBLIO TITLE) + (make element + gi: "H2" + attributes: '(("class" "bookbiblio")) + (make sequence +;;; (literal (chap-app-head-label "Bibliography")) + (process-children-trim)))) + +(element (BIBLIODIV TITLE) + (make element + gi: "H2" + attributes: '(("class" "bibliodiv")) + (make sequence + (process-children-trim)))) + +(element (GLOSSARY TITLE) + (make element + gi: "H1" + attributes: '(("class" "glossary")) + (make sequence + (literal "Glossary") +; (process-children-trim) + ))) + +(element (GLOSSDIV TITLE) + (make element + gi: "H2" + attributes: '(("class" "glossdiv")) + (process-children-trim))) + +(element (ARTHEADER TITLE) + (let ((content (make element + gi: "H1" + attributes: '(("class" "artheader")) + (process-children-trim)))) + (if %stylesheet-name% + content + (make element + gi: "CENTER" + content)))) + +(element (SECT1 TITLE) + (make element + gi: "H2" + attributes: '(("class" "sect1")))) + +(element (SECT2 TITLE) + (make element + gi: "H3" + attributes: '(("class" "sect2")))) + +(element (SECT3 TITLE) + (make element + gi: "H4" + attributes: '(("class" "sect3")))) + +(element (SECT4 TITLE) + (make element + gi: "H5" + attributes: '(("class" "sect1")))) + +(element (FORMALPARA TITLE) + (make element + gi: "H4" + attributes: '(("class" "formalpara")))) + +(element (SIDEBAR TITLE) + (make element + gi: "H2" + attributes: '(("class" "sidebar")))) + +(element (REFSYNOPSISDIV TITLE) + (make element + gi: "H2" + attributes: '(("class" "refsynopsisdiv")))) + +(element (REFSECT1 TITLE) + (make element + gi: "H2" + attributes: '(("class" "refsect1")))) + +(element (REFSECT2 TITLE) + (make element + gi: "H3" + attributes: '(("class" "refsect2")))) + +(element (REFSECT3 TITLE) + (make element + gi: "H4" + attributes: '(("class" "refsect1")))) + +(element (REFSECT4 TITLE) + (make element + gi: "H5" + attributes: '(("class" "sect4")))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; font changers + +(element LINEANNOTATION + (cond (%stylesheet-name% + (make element + gi: "SPAN" + attributes: '(("class" "lineannotation")) + (process-children-trim))) + (%lineannotation-color% + (make element + gi: "FONT" + attributes: (list (list "color" %lineannotation-color%)) + (process-children-trim))) + (#t (process-children-trim)))) + + +(element EMPHASIS + (make element gi: "I")) + +(element TYPE + (make element gi: "B" + (make element gi: "TT"))) + +(element REPLACEABLE + (make element gi: "I" + (make element gi: "B" + (make element gi: "TT")))) + +(element TOKEN + (if %stylesheet-name% + (make element + gi: "SPAN" + attributes: '(("class" "token")) + (process-children-trim)) + (process-children-trim))) + +(element PARAMETER (make element gi: "I")) + +(element FIRSTTERM (make element gi: "I")) + +(element APPLICATION (make element gi: "TT")) + +(element SYSTEMITEM (make element gi: "TT")) + +(element FILENAME (make element gi: "TT")) + +(element LITERAL (make element gi: "TT")) + +(element ENVAR (make element gi: "TT")) + +(element SUBSCRIPT (make element gi: "SUB")) + +(element SUPERSCRIPT (make element gi: "SUP")) + +(element CITETITLE (make element gi: "I")) + +(element GUIBUTTON (make element gi: "I")) +(element GUIMENU (make element gi: "I")) +(element GUIMENUITEM (make element gi: "I")) +(element GUILABEL (make element gi: "I")) + +(element STRUCTNAME (make element gi: "TT")) +(element STRUCTFIELD (make element gi: "TT")) + +(element COMMAND (make element gi: "TT")) + +(element OPTION (make element gi: "TT")) + +(element USERINPUT (make element gi: "TT")) + +(element COMPUTEROUTPUT (make element gi: "TT")) + +(element PROMPT (make element gi: "TT")) + +(element PRODUCTNAME (make element gi: "I")) + +(element SGMLTAG (make element gi: "TT")) + +(element (FUNCDEF FUNCTION) + (make element + gi: "B" + (make element + gi: "TT"))) +(element FUNCTION (make element gi: "TT")) + +(element SYMBOL (make element gi: "TT")) +(element LITERALLAYOUT + (make element + gi: "PRE" + attributes: '(("class" "literallayout")))) + +(element FOREIGNPHRASE (make element gi: "I")) + +(element ABBREV (process-children-trim)) + +(element EMAIL + (if %email-element% + (make element + gi: %email-element% + (process-children-trim)) + (process-children-trim))) + +(element QUOTE + (make sequence + (make entity-ref + name: "quot") + (process-children-trim) + (make entity-ref + name: "quot"))) + +(element ADDRESS + (make element + gi: "ADDRESS" + (process-children-trim))) + +(element (ADDRESS CITY) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS COUNTRY) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS EMAIL) + (make sequence + (make empty-element + gi: "BR") + (if %email-element% + (make element + gi: %email-element% + (process-children-trim)) + (process-children-trim)))) + +(element (ADDRESS FAX) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS OTHERADDR) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS POB) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS PHONE) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element (ADDRESS POSTCODE) + (process-children-trim)) + +(element (ADDRESS STATE) + (process-children-trim)) + +(element (ADDRESS STREET) + (make sequence + (make empty-element + gi: "BR") + (process-children-trim))) + +(element PROGRAMLISTING + (make element + gi: "PRE" + attributes: '(("class" "programlisting")))) + +(element SECT2INFO + (empty-sosofo)) + +(element SYNOPSIS + (make element + gi: "PRE" + attributes: '(("class" "synopsis")))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; paragraph like things + +(element CAUTION + (if %caution-color% + (make-color-para %caution-color%) + (make-special-para))) + +(element IMPORTANT + (if %important-color% + (make-color-para %important-color%) + (make-special-para))) + +(element WARNING + (if %warning-color% + (make-color-para %warning-color%) + (make-special-para))) + +(element NOTE + (if %note-color% + (make-color-para %note-color%) + (make-special-para))) + +(element TIP + (if %tip-color% + (make-color-para %tip-color%) + (make-special-para))) + +(element EXAMPLE + (if %example-color% + (make-color-para %example-color%) + (make-special-para))) + +(element COMMENT + (if %show-comments% + (make-color-para "red") + (empty-sosofo))) + +(element PARA + (make sequence + (make empty-element + gi: "P") + (make-anchor) + (with-mode footnote-ref + (process-children)) + (with-mode footnote-def + (process-matching-children "FOOTNOTE")))) + +(element BLOCKQUOTE (make element gi: "BLOCKQUOTE")) + +(element SCREEN + (let ((gubbins (make element + gi: "PRE" + attributes: '(("class" "screen")) + (process-children)))) + (make sequence + (make empty-element + gi: "P") + (if (or %stylesheet-name% %no-shade-screen%) + gubbins + (make element + gi: "TABLE" + attributes: (append (list '("border" "0") + '("bgcolor" "#E0E0E0")) + (if %shade-width% + (list (list "width" %shade-width%)) + '())) + (make element + gi: "TR" + (make element + gi: "TD" + gubbins))))))) + +(element FORMALPARA (process-children)) + +(element PHRASE (maybe-bold-children)) + +(mode footnote-ref + (element FOOTNOTE + (let ((num (format-number (element-number (current-node)) "1"))) + (make element + gi: "SUP" + attributes: '(("class" "footnoteref")) + (make element + gi: "A" + attributes: (list (list "href" (string-append "#footnote-" num))) + (literal num)))))) + +(mode footnote-def + (element FOOTNOTE + (let ((num (format-number (element-number (current-node)) "1"))) + (make element + gi: "BLOCKQUOTE" + attributes: '(("class" "footnote")) + (make sequence + (make empty-element + gi: "P") + (make element + gi: "A" + attributes: (list (list "name" (string-append "footnote-" num))) + (make element + gi: "SUP" + attributes: '(("class" "footnote")) + (literal num))) + (process-children)))))) + +(element (CAUTION TITLE) + (make element + gi: "H5")) + +(element (IMPORTANT TITLE) + (make element + gi: "H5")) + +(element (WARNING TITLE) + (make element + gi: "H5")) + +(element (NOTE TITLE) + (make element + gi: "H5")) + +(element (TIP TITLE) + (make element + gi: "H5")) + +(element (EXAMPLE TITLE) + (make element + gi: "H5")) + +(element (BIBLIOENTRY TITLE) + (make element + gi: "H3")) + +(element (SIDEBAR) + (make sequence + (make empty-element + gi: "P") + (make element + gi: "TABLE" + attributes: '(("border" "1") + ("bgcolor" "#f0f0f0") + ("width" "100%")) + (make element + gi: "TR" + (make element + gi: "TD" + (process-children)))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; lists + +(element ITEMIZEDLIST + (make sequence + (make empty-element + gi: "P") + (make-anchor) + (make element + gi: "UL"))) + +(element ORDEREDLIST + (make sequence + (make empty-element + gi: "P") + (make-anchor) + (make element + gi: "OL"))) + +(element (ITEMIZEDLIST LISTITEM) + (make sequence + (make empty-element + gi: "LI") + (process-children) + (make empty-element + gi: "P"))) + +(element (ORDEREDLIST LISTITEM) + (make sequence + (make empty-element + gi: "LI") + (process-children) + (make empty-element + gi: "P"))) + +(element VARIABLELIST + (make sequence + (make empty-element + gi: "P") + (make-anchor) + (make element + gi: "DL"))) + +(element VARLISTENTRY (process-children)) + +(element (VARLISTENTRY LISTITEM) + (make sequence + (make empty-element + gi: "DD") + (process-children) + (make empty-element + gi: "P"))) + + +(element (VARLISTENTRY TERM) + (let ((content (make sequence + (make-anchor) + (maybe-bold-children)))) + (make sequence + (make empty-element + gi: "DT") + (cond ((equal? (inherited-element-attribute-string + "VARIABLELIST" "role") "bold") + (make element + gi: "B" + content)) + ((equal? (inherited-element-attribute-string + "VARIABLELIST" "role") "fixed") + (make element + gi: "TT" + content)) + (#t content))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; glossary + +(element GLOSSTERM (process-children)) + +(element GLOSSDIV + (make sequence + (make empty-element + gi: "P") + (process-children))) + +(element (GLOSSENTRY GLOSSSEE) + (make sequence + (make empty-element + gi: "DD") + (literal "See ") + (make element + gi: "A" + attributes: (list (list "href" + (string-append "#" + (if + (string? + (attribute-string "otherterm")) + (attribute-string "otherterm") + (gloss-entry-name + (current-node)))))) + (if (string? (attribute-string "otherterm")) + (with-mode glosssee + (process-element-with-id + (attribute-string "OTHERTERM"))) + (process-children-trim))) + (make empty-element + gi: "P"))) + +(define (gloss-entry-name glossterm) + (string-append "gloss-" (data glossterm))) + +(element (GLOSSENTRY GLOSSTERM) + (make sequence + (make empty-element + gi: "DT") + (make element + gi: "A" + attributes: (list (list "name" + (if (string? (inherited-attribute-string "ID")) + (inherited-attribute-string "ID") + (gloss-entry-name (current-node))))) + (empty-sosofo)) + (process-children))) + +(element GLOSSENTRY + (make element + gi: "DL" + (process-children))) + +(element (GLOSSENTRY GLOSSDEF) + (make sequence + (make empty-element + gi: "DD") + (process-children) + (make empty-element + gi: "P"))) + +(element GLOSSSEEALSO + (make sequence + (if (first-sibling?) + (make sequence + (make empty-element + gi: "P") + (make element + gi: "EM" + (literal "See also "))) + (make sequence + (make element + gi: "EM" + (literal ", ")))) + (make element + gi: "a" + attributes: (list (list "href" + (string-append + "#" + (attribute-string + "OTHERTERM")))) + (with-mode glosssee + (process-element-with-id + (attribute-string "OTHERTERM")))))) + +;; This is referenced within the GLOSSSEE and GLOSSSEEALSO element +;; construction expressions. The OTHERTERM attributes on GLOSSSEE and +;; GLOSSSEEALSO (should) refer to GLOSSENTRY elements but we're only +;; interested in the text within the GLOSSTERM. Discard the revision +;; history and the definition from the referenced term. +(mode glosssee + (element GLOSSTERM + (process-children)) + (element REVHISTORY + (empty-sosofo)) + (element GLOSSDEF + (empty-sosofo))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; index + +(define (index-entry-name indexterm) + (string-append "index." (format-number (element-number indexterm) "1"))) + +(element INDEXTERM + (make sequence + (make-anchor) + (make element + gi: "A" + attributes: (list (list "name" (index-entry-name (current-node)))) + (literal "")) + (empty-sosofo))) + +; DIY string-ci>? + +(define (string-ci>? s1 s2) + (let ((len1 (string-length s1)) + (len2 (string-length s2))) + (let loop ((i 0)) + (cond ((= i len1) #f) + ((= i len2) #t) + (#t (let ((c1 (index-char-val (string-ref s1 i))) + (c2 (index-char-val (string-ref s2 i)))) + (cond + ((= c1 c2) (loop (+ i 1))) + (#t (> c1 c2))))))))) + +(define (equal-ci? s1 s2) + (let ((len1 (string-length s1)) + (len2 (string-length s2))) + (if (= len1 len2) + (let loop ((i 0)) + (if (= i len1) + #t + (let ((c1 (index-char-val (string-ref s1 i))) + (c2 (index-char-val (string-ref s2 i)))) + (if (= c1 c2) + (loop (+ i 1)) + #f)))) + #f))) + +(define (index-char-val ch) + (case ch + ((#\A #\a) 65) + ((#\B #\b) 66) + ((#\C #\c) 67) + ((#\D #\d) 68) + ((#\E #\e) 69) + ((#\F #\f) 70) + ((#\G #\g) 71) + ((#\H #\h) 72) + ((#\I #\i) 73) + ((#\J #\j) 74) + ((#\K #\k) 75) + ((#\L #\l) 76) + ((#\M #\m) 77) + ((#\N #\n) 78) + ((#\O #\o) 79) + ((#\P #\p) 80) + ((#\Q #\q) 81) + ((#\R #\r) 82) + ((#\S #\s) 83) + ((#\T #\t) 84) + ((#\U #\u) 85) + ((#\V #\v) 86) + ((#\W #\w) 87) + ((#\X #\x) 88) + ((#\Y #\y) 89) + ((#\Z #\z) 90) + + ((#\ ) 32) + + ((#\0) 48) + ((#\1) 49) + ((#\2) 50) + ((#\3) 51) + ((#\4) 52) + ((#\5) 53) + ((#\6) 54) + ((#\7) 55) + ((#\8) 56) + ((#\9) 57) + + ; laziness precludes me from filling this out further + (else 0))) + +(define (string->number-list s) + (let loop ((i (- (string-length s) 1)) + (l '())) + (if (< i 0) + l + (loop (- i 1) (cons (index-char-val (string-ref s i)) l))))) + +(define (number-list>? l1 l2) + (cond ((null? l1) #f) + ((null? l2) #t) + ((= (car l1) (car l2)) + (number-list>? (cdr l1) (cdr l2))) + (#t (> (car l1) (car l2))))) + +; return the string data for a given index entry + +(define (get-index-entry-data entry) + (let ((primary (select-elements (children entry) "PRIMARY")) + (secondary (select-elements (children entry) "SECONDARY"))) + (if (node-list-empty? secondary) + (data primary) + (string-append (data primary) " - " (data secondary))))) + +(define (make-index-entry entry) + (let ((text (get-index-entry-data entry))) + (cons text + (make sequence + (make empty-element + gi: "LI") + (make element + gi: "A" + attributes: (list (list "href" + (string-append (link-file-name + entry) + "#" + (index-entry-name + entry)))) + (literal text)))))) + +(define (build-index nl) + (let loop ((result '()) + (nl nl)) + (if (node-list-empty? nl) + result + (loop (cons (make-index-entry (node-list-first nl)) result) + (node-list-rest nl))))) + +(define (sort-index il) + (letrec ((list-head (lambda (l n) + (if (> n 0) + (cons (car l) (list-head (cdr l) (- n 1))) + '()))) + (merge (lambda (il1 il2) + (cond ((null? il1) il2) + ((null? il2) il1) + ((string-ci>? (car (car il1)) (car (car il2))) + (cons (car il2) (merge il1 (cdr il2)))) + (#t + (cons (car il1) (merge (cdr il1) il2))))))) + (let* ((ll (length il)) + (ldiv2 (quotient ll 2))) + (if (> 2 ll) + il + (merge (sort-index (list-head il ldiv2)) + (sort-index (list-tail il ldiv2))))))) + +(define (output-index il) + (let extract-and-append ((il il) + (result (empty-sosofo))) + (if (null? il) + result + (extract-and-append (cdr il) (sosofo-append result (cdr (car il))))))) + +(define (make-index) + (make sequence + (make element + gi: "H1" + (make element + gi: "A" + attributes: (list (list "name" "INDEXTOP")) + (literal "Index"))) + (make element + gi: "UL" + (output-index + (sort-index + (build-index (select-elements (descendants (current-node)) + "INDEXTERM"))))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; links & cross-references + +(define (link-file-name target) + (if %no-split-output% + "" + (string-append + %output-basename% + (cond ((equal? (gi target) "BOOK") "") + + ((equal? (gi target) "APPENDIX") + (string-append + "-APP-" + (format-number (child-number target) "A"))) + + ((or (equal? (gi target) "CHAPTER") + (equal? (gi target) "ARTICLE") + (equal? (gi target) "GLOSSARY")) + (string-append + "-" + (substring (gi target) 0 3) + "-" + (format-number (child-number target) "1"))) + + ((equal? (gi target) "REFENTRY") + (string-append + "-REF-" + (number->string (all-element-number target)))) + + ((ancestor-child-number "APPENDIX" target) + (string-append + "-APP-" + (format-number (ancestor-child-number "APPENDIX" target) "A"))) + ((ancestor-child-number "CHAPTER" target) + (string-append + "-CHA-" + (format-number (ancestor-child-number "CHAPTER" target) "1"))) + + ((ancestor-child-number "ARTICLE" target) + (string-append + "-ART-" + (format-number (ancestor-child-number "ARTICLE" target) "1"))) + + ((ancestor-child-number "GLOSSARY" target) + (string-append + "-GLO-" + (format-number (ancestor-child-number "GLOSSARY" target) "1"))) + + (#t + (string-append + "-XXX-" + (number->string (all-element-number target))))) + %output-suffix%))) + +(element LINK + (let* ((target (element-with-id (attribute-string "linkend") + (book-node))) + (target-file-name (link-file-name target))) + (make element + gi: "A" + attributes: (list + (list "href" + (string-append + target-file-name + "#" + (attribute-string "linkend"))))))) +(element ULINK + (make element + gi: "A" + attributes: (list + (list "href" (attribute-string "url"))))) + +(element XREF + (let* ((linkend (attribute-string "linkend")) + (target (element-with-id linkend (book-node))) + (target-gi (gi target))) + (make element + gi: "A" + attributes: (append + (list (list "href" (string-append (link-file-name target) + "#" + linkend))) + (if (equal? target-gi "CO") + ;;; XREF must be in same file as CO for + ;;; backlink to work correctly + (list (list "name" (string-append "backlink-" linkend))) + '())) + (if (equal? target-gi "CO") + (literal (or (attribute-string "label" target) + "Unlabeled CO")) + (with-mode extract-xref-text + (process-node-list target)))))) + +(mode extract-xref-text + (default + (let ((titles (select-elements (children (current-node)) "TITLE"))) + (if (node-list-empty? titles) + (literal (string-append "Reference to " (id))) + (with-mode extract-title-text + (process-node-list (node-list-first titles))))))) + +(element CO + (if (id) + (make element + gi: "A" + attributes: (list (list "name" (id)) + (list "href" (string-append "#backlink-" (id)))) + (make element + gi: "SPAN" + attributes: '(("class" "co")) + (literal (or (attribute-string "label") + "Unlabeled CO")))) + (empty-sosofo))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; figures + +(element FIGURE + (let ((gubbins (make sequence + (make empty-element + gi: "P") + (make-anchor) + (process-children) + (make empty-element + gi: "P")))) + (cond (%stylesheet-name% + (make element + gi: "DIV" + attributes: '(("class" "figure")) + gubbins)) + (%centre-figures% + (make element + gi: "CENTER" + gubbins)) + (#t gubbins)))) + +(element (FIGURE TITLE) + (make sequence + (make element + gi: "H5" + attributes: '(("class" "figure")) + (make sequence + (literal "Figure: ") + (process-children-trim))) + (make empty-element + gi: "P"))) + +(element GRAPHIC + (let ((img + (make sequence + (make empty-element + gi: "P") + (make empty-element + gi: "IMG" + attributes: (let ((filename (string-append + (or (and %graphic-directory% + (string-append %graphic-directory% + "/")) + "") + (attribute-string "fileref") + "." + (or (attribute-string "format") + %default-graphic-format%)))) + (list (list "src" filename) + (list "alt" filename))))))) + (if (equal? + (attribute-string "align") + "CENTER") + (if %stylesheet-name% + (make element + gi: "DIV" + attributes: '(("class" "center")) + img) + (make element + gi: "CENTER" + img)) + img))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; tables + +(define (make-table-attributes) + (append (if (equal? (attribute-string "frame") "ALL") + '(("border" "1") ("cellpadding" "2")) + '(("border" "0"))) +; (let ((wantcolsep (equal? (attribute-string "colsep") "1")) +; (wantrowsep (equal? (attribute-string "rowsep") "1"))) +; (list +; (cond ((and wantrowsep wantcolsep) '("rules" "all")) +; (wantcolsep '("rules" "cols")) +; (wantrowsep '("rules" "rows")) +; (#t '("rules" "none"))))) + )) + +(element TABLE + (let ((table (make sequence + (make-anchor) + (let ((tab (make sequence + (make element + gi: "TABLE" + attributes: (make-table-attributes) + (make sequence + (make element + gi: "CAPTION" + (make sequence + (literal "Table: ") + (with-mode extract-title-text + (process-first-descendant "TITLE")))) + (with-mode footnote-ref + (process-children)))) + (with-mode footnote-def + (process-node-list (select-elements (descendants (current-node)) "FOOTNOTE"))))) + (roleattr (or (attribute-string "role") ""))) + (if (or + (equal-ci? roleattr + "centre") + (equal-ci? roleattr + "center")) + (if %stylesheet-name% + (make element + gi: "DIV" + attributes: '(("class" "center")) + tab) + (make element + gi: "CENTER" + tab)) + tab))))) + (if %stylesheet-name% + (make element + gi: "DIV" + attributes: '(("class" "table")) + table) + (make sequence + (make empty-element gi: "P") + table + (make empty-element gi: "P"))))) + +(element (TABLE TITLE) (empty-sosofo)) + +(element INFORMALTABLE + (make sequence + (make empty-element + gi: "P") + (let ((tab (make element + gi: "TABLE" + attributes: (make-table-attributes) + (process-children))) + (roleattr (or (attribute-string "role") + ""))) + (if (or + (equal-ci? roleattr + "centre") + (equal-ci? roleattr + "center")) + (if %stylesheet-name% + (make element + gi: "DIV" + attributes: '(("class" "center")) + tab) + (make element + gi: "CENTER" + tab)) + tab)) + (make empty-element + gi: "P"))) + +(element ENTRY + (process-children-trim)) + +; routine to convert a string consisting of a number followed by a +; unit (mm, cm, etc.) into a string consisting of just a number (in +; pixel units) + +(define (to-pixels lenstring) + (let ((num (or (string->number lenstring) 0))) + (number->string + (truncate (* %display-dpi% + 0.01388888 + (if (quantity? num) + (let ((qstr (quantity->string num))) + ;; this assumes the unit string is "pt1" + (string->number (substring qstr 0 (- (string-length qstr) 3)))) + num)))))) + +;; hairy stuff to get table entries to understand various attributes + +(define (process-table-entry entry entrycolnum span entrygi colspecs cols) + (make sequence + ;; loop through COLSPECs looking for one that has the right + ;; column number + (let loop ((specs colspecs) + (nextspeccolnum 1)) + (if (node-list-empty? specs) + ;; we didn't find a COLSPEC for this column + (let ((alignattr (or (inherited-attribute-string "align" entry) + "left"))) + (make empty-element + gi: entrygi + attributes: (append (list (list "align" alignattr)) + (if (> span 1) + (list (list "colspan" (number->string span))) + '())))) + ;; look at next COLSPEC and see if it is for this column the + ;; column number can be explicitly given with a 'colnum' + ;; attribute or implicitly one more than the last column + ;; number + (let* ((spec (node-list-first specs)) + (colnumattr (attribute-string "colnum" spec)) + (speccolnum (or (and colnumattr (string->number colnumattr)) + nextspeccolnum))) + (if (equal? speccolnum entrycolnum) + ;; we matched column numbers so extract the align + ;; attribute and do the right thing + (let ((alignattr (or (attribute-string "align" entry) + (attribute-string "align" spec) + (inherited-attribute-string "align" entry) + "left")) + (widthattr (attribute-string "colwidth" spec))) + (make empty-element + gi: entrygi + attributes: (append (if alignattr + (list (list "align" alignattr)) + '()) + (if (and widthattr (= span 1)) + (list (if %stylesheet-name% + (list "style" (string-append "width: " (to-pixels widthattr))) + (list "width" (to-pixels widthattr)))) + '()) + (if (> span 1) + (list (list "colspan" (number->string span))) + '())))) + ;; didn't match column number so look at next in list + (loop (node-list-rest specs) + (+ speccolnum 1)))))) + (process-node-list entry))) + +;; determine the column number (1, 2, ...) that corresponds to the +;; supplied column name from the supplied COLSPECs. If none of the +;; COLSPECs has a matching name and the supplied column name is +;; actually a number, we return that number. + +(define (find-column-number colspecs colname) + ;; loop searches for a COLSPEC whose name matches the supplied + ;; column name + (let loop ((specs colspecs) + (colnum 1)) + (if (node-list-empty? specs) + ;; if the column name is actually a number use that, + ;; otherwise, just return 1 + (or (string->number colname) 1) + (let* ((spec (node-list-first specs)) + (nameattr (attribute-string "colname" spec)) + (colnumattr (attribute-string "colnum" spec)) + (speccolnum (if colnumattr (string->number colnumattr) colnum))) + (if (equal? colname nameattr) + speccolnum + (loop (node-list-rest colspecs) + (+ speccolnum 1))))))) + +;; determine the number of columns spanned by the given table entry +(define (columns-spanned entry) + (let* ((colspecs (select-elements (ancestor "TGROUP" entry) "COLSPEC")) + (namest (attribute-string "namest" entry)) + (nameend (attribute-string "nameend" entry))) + (if (and namest nameend) + (+ (- (find-column-number colspecs nameend) + (find-column-number colspecs namest)) + 1) + 1))) + +(define (process-table-row sofar row entrygi entryprocessor) + (sosofo-append sofar + (make empty-element gi: "TR") + (let loop ((entries (children row)) + (result (empty-sosofo)) + (colnum 1)) + (if (node-list-empty? entries) + result + (let* ((entry (node-list-first entries)) + (span (columns-spanned entry))) + (loop (node-list-rest entries) + (sosofo-append result + (entryprocessor entry + colnum + span + entrygi)) + (+ colnum span))))))) + +(define (process-table-group sofar group entrygi rowreducer) + (sosofo-append sofar + (node-list-reduce (select-elements (children group) "ROW") + (lambda (sofar new) + (rowreducer sofar new entrygi)) + (empty-sosofo)))) + +(define (process-tgroup) + (let* ((colspecs (select-elements (children (current-node)) "COLSPEC")) + (cols (string->number (attribute-string "cols"))) + (entryprocessor (lambda (new colnum span entrygi) + (process-table-entry new colnum span entrygi colspecs cols))) + (rowreducer (lambda (sofar new entrygi) + (process-table-row sofar new entrygi entryprocessor))) + (groupreducer (lambda (sofar new entrygi) + (process-table-group sofar new entrygi rowreducer)))) + (make sequence + (node-list-reduce (select-elements (children (current-node)) "THEAD") + (lambda (sofar new) + (groupreducer sofar new "TH")) + (empty-sosofo)) + (node-list-reduce (select-elements (children (current-node)) "TBODY") + (lambda (sofar new) + (groupreducer sofar new "TD")) + (empty-sosofo)) + (node-list-reduce (select-elements (children (current-node)) "TFOOT") + (lambda (sofar new) + (groupreducer sofar new "TH")) + (empty-sosofo))))) + +(element TGROUP + (process-tgroup)) + +(element ENTRYTBL + (make element + gi: "TABLE" + attributes: (make-table-attributes) + (process-tgroup))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; book info + +(element BOOKINFO + (make sequence + (if %stylesheet-name% + (make element + gi: "DIV" + attributes: '(("class" "bookinfo")) + (process-children)) + (make element + gi: "CENTER" + (process-children))) + (cond ((not %no-make-toc%) + (make sequence + (make-fat-rule) + (make element + gi: "H2" + (literal "Contents")) + (make element + gi: "ul" + (with-mode make-toc-links + (process-node-list (book-node)))))) + (#t (empty-sosofo))))) + + +(element AUTHORGROUP + (let ((reducer (lambda (sofar new) + (sosofo-append sofar (make element + gi: "H2" + attributes: '(("class" "bookinfo")) + (process-node-list new)))))) + (make sequence + (node-list-reduce (select-elements (children (current-node)) "AUTHOR") + reducer + (empty-sosofo)) + (node-list-reduce (select-elements (children (current-node)) "EDITOR") + reducer + (empty-sosofo)) + (node-list-reduce (select-elements (children (current-node)) "CORPAUTHOR") + reducer + (empty-sosofo))))) + +(element (BIBLIOENTRY AUTHORGROUP) + (let ((reducer (lambda (sofar new) + (sosofo-append sofar (make element + gi: "H3" + (process-node-list new)))))) + (make sequence + (node-list-reduce (select-elements (children (current-node)) "AUTHOR") + reducer + (empty-sosofo)) + (node-list-reduce (select-elements (children (current-node)) "EDITOR") + reducer + (empty-sosofo)) + (node-list-reduce (select-elements (children (current-node)) "CORPAUTHOR") + reducer + (empty-sosofo))))) + +(element (BOOKINFO DATE) + (process-children-trim)) + +(element (BOOKINFO EDITION) + (make sequence + (literal "Edition ") + (process-children-trim))) + +(element COPYRIGHT + (make element + gi: "H4" + (make sequence + (make entity-ref + name: "copy") + (process-matching-children "HOLDER") + (process-matching-children "YEAR")))) + +(element HOLDER + (make sequence + (literal " ") + (process-children-trim))) + +(element YEAR + (make sequence + (literal " ") + (process-children-trim))) + +(element CORPAUTHOR + (process-children-trim)) + +(element AUTHOR + (process-children-trim)) + +(element EDITOR + (process-children-trim)) + +(element CONFGROUP + (process-children-trim)) + +(element CONFTITLE + (make sequence + (make empty-element + gi: "BR") + (make element gi: "I" (process-children)))) + +(element CONFDATES + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element HONORIFIC + (make sequence + (process-children-trim) + (literal " "))) + +(element FIRSTNAME + (make sequence + (process-children-trim) + (literal " "))) + +(element OTHERNAME + (make sequence + (process-children-trim) + (literal " "))) + +(element SURNAME + (make sequence + (process-children-trim) + (literal " "))) + +(element LINEAGE + (make sequence + (process-children-trim) + (literal " "))) + +(element TRADEMARK (process-children)) + +(element PUBLISHERNAME (process-children)) + +(element BIBLIOENTRY (process-children)) + +(element ACRONYM (process-children)) + +(element RELEASEINFO + (make sequence + (make empty-element + gi: "BR") + (make element gi: "B"))) + +(element AFFILIATION + (make sequence + (make element + gi: "I"))) + +(element ORGNAME + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element JOBTITLE + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element ORGDIV + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element PUBLISHER + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element ISBN + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element PUBDATE + (make sequence + (make empty-element + gi: "BR") + (process-children))) + +(element REVHISTORY + (empty-sosofo)) + +(element LEGALNOTICE + (make sequence + (if %stylesheet-name% + (make element + gi: "DIV" + attributes: '(("align" "left"))) + (process-children)))) + +(element KEYWORDSET + (empty-sosofo)) + +(element SUBJECTSET + (empty-sosofo)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; TOC + +(element LOF (empty-sosofo)) + +(element LOT (empty-sosofo)) + +(element TOC (empty-sosofo)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; DIY TOC + +(mode make-toc-links + (element (BOOK) + (sosofo-append + (process-children) + (cond ((not %no-make-index%) + (make sequence + (make empty-element + gi: "LI") + (make element + gi: "A" + attributes: (list (list "href" + (cond (%no-split-output% "#INDEXTOP") + (#t + (string-append (index-file-name) + "#INDEXTOP"))))) + (literal "Index")))) + (#t (empty-sosofo))))) + (element (ARTICLE) + (process-matching-children "SECT1")) + (element (CHAPTER) + (make-major-div-toc-links)) + (element (APPENDIX) + (make-major-div-toc-links)) + (element (GLOSSARY) + (make-major-div-toc-links)) + (element (SECT1) + (make sequence + (make empty-element + gi: "LI") + (let ((title-text (with-mode extract-title-text + (process-first-descendant "TITLE")))) + (make element + gi: "A" + attributes: (list (list "href" (string-append (link-file-name (current-node)) + "#" + (gi) + (number->string (all-element-number (current-node)))))) + title-text)) + (let ((refentries (select-elements (children (current-node)) "REFENTRY"))) + (if (node-list-empty? refentries) + (empty-sosofo) + (make element + gi: "ul" + (with-mode make-toc-links (process-node-list refentries))))))) + (element (REFENTRY) + (make sequence + (make empty-element + gi: "LI") + (let ((title-text (process-first-descendant "REFMETA"))) + (make element + gi: "A" + attributes: (list (list "href" (string-append (link-file-name (current-node)) + "#" + (gi) + (number->string (all-element-number (current-node)))))) + title-text)))) + + (default + (empty-sosofo))) + +(define (make-major-div-toc-links) + (make sequence + (make empty-element + gi: "LI") + (let ((title-text + (cond ((equal? (gi) "CHAPTER") + (make sequence + (literal (string-append "Chapter " + (format-number + (element-number (current-node)) + "1") + " - ")) + (with-mode extract-title-text + (process-first-descendant "TITLE")))) + + ((equal? (gi) "APPENDIX") + (make sequence + (literal + (string-append "Appendix " + (format-number + (element-number (current-node)) + "A") + " - ")) + (with-mode extract-title-text + (process-first-descendant "TITLE")))) + + ((equal? (gi) "GLOSSARY") (literal "Glossary")) + + (#t + (with-mode extract-title-text + (process-first-descendant "TITLE")))))) + (make element + gi: "A" + attributes: (list (list "href" (string-append (link-file-name (current-node)) + "#" + (gi) + (number->string (all-element-number (current-node)))))) + title-text)) + (let ((wanted (node-list-reduce (children (current-node)) + (lambda (sofar new) + (if (or (equal? (gi new) "SECT1") + (equal? (gi new) "REFENTRY")) + (node-list sofar new) + sofar)) + (node-list)))) + (if (node-list-empty? wanted) + (empty-sosofo) + (make element + gi: "UL" + (with-mode make-toc-links (process-node-list wanted))))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; make the unimplemented bits stand out + +(default + (make element + gi: "FONT" + attributes: '(("color" "red")) + (make sequence + (literal (string-append "<" (gi) ">")) + (process-children) + (literal (string-append ""))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; standard subroutines + +(define (node-list-reduce nl combine init) + (if (node-list-empty? nl) + init + (node-list-reduce (node-list-rest nl) + combine + (combine init (node-list-first nl))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; various homebrew subroutines + +(define (book-node) + (cond ((equal? (gi) "BOOK") (current-node)) + (#t (ancestor "BOOK")))) + +(define (make-fat-rule) + (make empty-element + gi: "HR" + attributes: (if %stylesheet-name% + '(("class" "fat")) + '(("size" "5"))))) + +(define (make-thin-rule) + (make empty-element + gi: "HR" + attributes: (if %stylesheet-name% + '(("class" "thin")) + '(("size" "2"))))) + +(define (index-file-name) + (string-append %output-basename% + "-IND" + %output-suffix%)) + +(define (chap-app-head-label chap-or-app) + (let ((label + (attribute-string "label" (ancestor chap-or-app)))) + (string-append + chap-or-app + " " + (if label + (if (equal? label "auto") + (format-number + (element-number (ancestor chap-or-app)) + (if (equal? chap-or-app "Chapter") "1" "A")) + label) + (format-number + (element-number (ancestor chap-or-app)) + (if (equal? chap-or-app "Chapter") "1" "A"))) + ". "))) + +(define (make-anchor) + (make sequence + (make element + gi: "A" + attributes: (list (list "name" (string-append (gi) + (number->string (all-element-number (current-node)))))) + (literal "")) + (if (id) + (make element + gi: "A" + attributes: (list (list "name" (id))) + (literal "")) + (empty-sosofo)))) + +(define (make-color-para color) + (if %stylesheet-name% + (make element + gi: "DIV" + attributes: (list (list "class" (string-append "{color: " color "}"))) + (make-special-para)) + (make element + gi: "FONT" + attributes: (list (list "color" color)) + (make-special-para)))) + +(define (make-special-para) + (make sequence + (make empty-element + gi: "P") + (make element + gi: "B" + (literal (string-append (gi) ":"))) + (make element + gi: "BLOCKQUOTE" + (process-children)))) + +(define (maybe-bold-children) + (cond ((equal? (attribute-string "role") + "bold") + (make element + gi: "B" + (process-children-trim))) + (#t (process-children-trim)))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; the end + diff --git a/docbkdsl.dif b/docbkdsl.dif new file mode 100644 index 0000000..bc3e485 --- /dev/null +++ b/docbkdsl.dif @@ -0,0 +1,20 @@ +--- index.html Mon Aug 24 19:32:04 1998 ++++ index.html Sun Oct 25 08:32:21 1998 +@@ -0,0 +1,17 @@ ++ ++ ++ ++ Norman Walsh: The Modular DocBook Stylesheets ++ ++ ++ ++ ++ ++ ++ ++ diff --git a/docbook-dsssl-1.79.tar.gz b/docbook-dsssl-1.79.tar.gz new file mode 100644 index 0000000..51e2ebb --- /dev/null +++ b/docbook-dsssl-1.79.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d5a199024a5fe0862bfaff9e3533817cd8d08bddf3cdfb5bfe6088cbb2cd62b3 +size 355586 diff --git a/docbook-dsssl-doc-1.79.tar.gz b/docbook-dsssl-doc-1.79.tar.gz new file mode 100644 index 0000000..4afedf8 --- /dev/null +++ b/docbook-dsssl-doc-1.79.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ea12a8127339c4ed2c34a73571331ffac4dbe07a9524892d28e5514e0efe033a +size 225797 diff --git a/docbook-dsssl-stylesheets-README.SUSE b/docbook-dsssl-stylesheets-README.SUSE new file mode 100644 index 0000000..8e48785 --- /dev/null +++ b/docbook-dsssl-stylesheets-README.SUSE @@ -0,0 +1,14 @@ +README.SUSE (2001-11-29 11:59:08 CET) +===================================== + +You'll find additional files and documentation at + + /usr/share/sgml/docbook/docbook-dsssl-stylesheets-$VERSION + +2001-03-26 15:43:58 CEST -ke- + +-=-=-=-=-=-=-=-=-=-=-=-=-=- cut here -=-=-=-=-=-=-=-=-=-=-=-=-=- + +To make use of these stylesheets most probably you may want to install +a DocBook DTD (version 3 or 4, SGML or XML flavour) and the DSSSL engine +openjade. diff --git a/docbook-dsssl-stylesheets.changes b/docbook-dsssl-stylesheets.changes new file mode 100644 index 0000000..9dcb72c --- /dev/null +++ b/docbook-dsssl-stylesheets.changes @@ -0,0 +1,331 @@ +------------------------------------------------------------------- +Tue Feb 5 14:51:27 UTC 2019 - Jan Engelhardt + +- Replace old $RPM_* shell vars. + +------------------------------------------------------------------- +Thu Jan 31 08:18:22 UTC 2019 - ke@suse.com + +- Do not install in /var/lib; bsc#1093345. + +------------------------------------------------------------------- +Mon Nov 13 14:38:09 UTC 2017 - dimstar@opensuse.org + +- Rename README.SuSE to README.SUSE, adhering to the correct + spelling. +- Add fdupes BuildRequires and eliminate duplictae files. + +------------------------------------------------------------------- +Tue Jul 16 13:48:32 CEST 2013 - mls@suse.de + +- remove two wrong dir modifiers in filelist + +------------------------------------------------------------------- +Mon Jun 25 08:25:11 UTC 2012 - cfarrell@suse.com + +- license update: SUSE-XSL-Lint + Choose a license from http://www.spdx.org/licenses or from the list + linked at http://license.opensuse.org + +------------------------------------------------------------------- +Sun Sep 18 17:17:12 UTC 2011 - jengelh@medozas.de + +- Remove redundant tags/sections from specfile + (cf. packaging guidelines) + +------------------------------------------------------------------- +Sun Aug 30 20:04:53 CEST 2009 - coolo@novell.com + +- provide Patch0 + +------------------------------------------------------------------- +Mon May 29 16:41:22 CEST 2006 - ke@suse.de + +- Use %postun instead of %preun and check for the update case; reported + by Marcus Meissner. + +------------------------------------------------------------------- +Wed Jan 25 21:46:08 CET 2006 - mls@suse.de + +- converted neededforbuild to BuildRequires + +------------------------------------------------------------------- +Wed Dec 21 07:49:46 CET 2005 - aj@suse.de + +- Package symlink. + +------------------------------------------------------------------- +Fri Nov 5 08:13:56 CET 2004 - ke@suse.de + +- Update to version 1.79 which also includes "bs" and "bg" localization + files. +- Drop obsolete CVS ariginated patch. + +------------------------------------------------------------------- +Tue Oct 12 14:59:28 CEST 2004 - ke@suse.de + +- Apply all current changes from CVS, only leave out "bs" and "bg" + localization files because building .ent files failed ATM. + +------------------------------------------------------------------- +Mon Feb 23 11:45:41 CET 2004 - hmacht@suse.de + +- building as non-root + +------------------------------------------------------------------- +Wed Mar 26 14:12:27 CET 2003 - ke@suse.de + +- Update to version 1.78, which comes with all the patches applied on + 2003-01-31; thus drop them here. + +------------------------------------------------------------------- +Fri Jan 31 14:58:51 CET 2003 - ke@suse.de + +- Apply some fixes from the SF CVS: + - bookinfo-legal-product.diff: Fix HTML formatting when + occurs in legalinfo in bookinfo (from CVS 2003/01/21). + - indexterm-seealso.diff: Fix bin/collateindex.pl when indexterm has + two different seealso's (from CVS 2003/01/19). + - navig-level-chunk.diff: Fix PDF bookmark hierarchy (from CVS + 2003/01/15); provided by Susanne Oberhauser. + - dbl1en-case-folding.diff: Fix some case folding of some English standard + phrases (from CVS 2002/12/20). + - db-html-dbgraph-syntax-fix.diff: Fix syntax in html/dbgraph.dsl, + append wants a list (from CVS 2003/01/20). + +------------------------------------------------------------------- +Fri Nov 29 15:46:25 CET 2002 - ke@suse.de + +- Register catalog file using sgml-register-catalog. + +------------------------------------------------------------------- +Fri Jul 12 16:36:48 MEST 2002 - mls@suse.de + +- fixed postinstall script + +------------------------------------------------------------------- +Mon Jul 8 10:16:12 CEST 2002 - ke@suse.de + +- Update to version 1.77: Mostly a bug-fix release, but also includes a + few user-requested feature enhancements: footnote, list, title page + formatting and more. + +------------------------------------------------------------------- +Fri Apr 26 11:20:43 CEST 2002 - ke@suse.de + +- Update to version 1.76 (patches added on 2002-03-16 and 2002-02-20 are + superfluous): + Bug fixes concerning formatting (lists) and index creation. + +------------------------------------------------------------------- +Thu Mar 14 16:07:13 CET 2002 - ke@suse.de + +- Backport images from docbook-dsssl-1.76; or in other words: add PDF + and EPS. + Reported by Pavel Janik [# 14905]. + +------------------------------------------------------------------- +Wed Feb 20 12:16:24 CET 2002 - ke@suse.de + +- Apply docbook-dsssl-1.74b-lfr.diff to fix a quoting problem (for + French texts only); discussed on the DocBook Apps mailinglist by + Norman Walsh and camille [# 13501]. + +------------------------------------------------------------------- +Mon Dec 3 11:30:23 CET 2001 - ke@suse.de + +- Update to version 1.74b (bugfix release). + +------------------------------------------------------------------- +Thu Nov 29 11:34:33 CET 2001 - ke@suse.de + +- Update to version 1.74: + - Better localization support. + - Enhancements (e.g., more line numberings; support glossary and index + in article correctly). + - Bug fixes (e.g., keep-with-next properties, callouts). +- As announced for 8.0 remove convenience links. +- Cleanup spec file. + +------------------------------------------------------------------- +Thu Oct 18 13:22:50 CEST 2001 - ke@suse.de + +- For HTML output process "emphasis" elements correctly; apply + http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/docbook/dsssl/html/dbinline.dsl.diff?r1=1.5&r2=1.6. + Reported by Ulrich Windl [# 11886]. + +------------------------------------------------------------------- +Tue Aug 7 15:57:17 CEST 2001 - ke@suse.de + +- Update to version 1.72. + +------------------------------------------------------------------- +Thu Jul 12 12:39:16 CEST 2001 - ke@suse.de + +- Update to version 1.71 (experimental). +- Adjust .spec file (now we've proper .tar.gz files instead of .zip + files). +- Provide an additional convenience link through %post. + +------------------------------------------------------------------- +Thu Mar 29 01:10:47 CEST 2001 - ro@suse.de + +- tweaked postinstall again. + +------------------------------------------------------------------- +Wed Mar 28 02:22:45 CEST 2001 - ro@suse.de + +- fixed postinstall +- redefining version macro is dangerous. + +------------------------------------------------------------------- +Mon Mar 26 15:42:33 CEST 2001 - ke@suse.de + +- Rename package: docbkdsl -> docbook-dsssl-stylesheets. +- Provide compatibility links. +- Adjust README.SuSE. + +------------------------------------------------------------------- +Mon Mar 19 13:56:59 CET 2001 - ke@suse.de + +- Update to version 1.64 + +------------------------------------------------------------------- +Thu Feb 1 13:57:47 CET 2001 - ke@suse.de + +- Update to version 1.62. + +------------------------------------------------------------------- +Mon Dec 18 13:24:27 CET 2000 - ke@suse.de + +- Update to version 1.60 (to fix a TOC creation bug). + +------------------------------------------------------------------- +Thu Nov 2 18:45:45 CET 2000 - ke@suse.de + +- Update to version 1.59. +- spec file cleanup (more macros); reduce CATALOG file. + +------------------------------------------------------------------- +Fri Sep 22 15:38:04 MEST 2000 - ke@suse.de + +- Update to version 1.57. + +------------------------------------------------------------------- +Wed Aug 16 10:45:11 CEST 2000 - ke@suse.de + +- Update to version 1.56. +- Require docbk30 and docbk_4. + +------------------------------------------------------------------- +Tue May 30 12:01:38 CEST 2000 - ke@suse.de + +- Update to version 1.54. +- Use %{_defaultdocdir} + +------------------------------------------------------------------- +Fri Jan 28 19:20:13 CET 2000 - ke@suse.de + +- Update to version 1.52. +- Add groupt tag. +- User %version macro. +- Apply patch from Norm Walsh to correct a typo. + +------------------------------------------------------------------- +Fri Dec 17 13:19:27 CET 1999 - ke@suse.de + +- Update: 1.49 (bugfix release). + +------------------------------------------------------------------- +Sun Oct 24 16:04:56 CEST 1999 - ke@suse.de + +- Update: 1.46 (bugfix release). +- Mark the package as "noarch". + +------------------------------------------------------------------- +Fri Oct 1 18:29:02 CEST 1999 - ke@suse.de + +- Update: 1.45. +- Fix check marco. + +------------------------------------------------------------------- +Mon Sep 13 17:23:57 CEST 1999 - bs@suse.de + +- ran old prepare_spec on spec file to switch to new prepare_spec. + +------------------------------------------------------------------- +Mon Aug 9 12:00:48 MEST 1999 - ke@suse.de + +- Update: version 1.43. +- Add `Check'. + +------------------------------------------------------------------- +Mon Jul 12 10:41:16 MEST 1999 - ke@suse.de + +- Update: version 1.42 (bugfix release). + +------------------------------------------------------------------- +Tue Jun 29 09:59:46 MEST 1999 - ke@suse.de + +- Update: version 1.41. + +------------------------------------------------------------------- +Wed Apr 21 16:37:10 MEST 1999 - ke@suse.de + +- Update: version 1.40. + +------------------------------------------------------------------- +Thu Apr 8 19:49:42 MEST 1999 - ke@suse.de + +- Update: version 1.38b. + +------------------------------------------------------------------- +Sun Mar 28 16:42:57 MEST 1999 - ke@suse.de + +- Add the stylesheet ld2db.dsl from SGMLtools. + +------------------------------------------------------------------- +Sun Mar 21 11:46:54 MET 1999 - ke@suse.de + +- Update: version 1.37. + +------------------------------------------------------------------- +Fri Mar 12 21:44:05 MET 1999 - ke@suse.de + +- Take care about usr/doc/packages/docbkdsl/* links (%post, &preun). +- Don't install the broken index.html. + +------------------------------------------------------------------- +Tue Dec 8 12:53:17 MET 1998 - ke@suse.de + +- Update: version 1.28. +- Install the collateindex.pl library as a data file under .../share/... + +------------------------------------------------------------------- +Tue Nov 24 19:20:20 MET 1998 - ke@suse.de + +- Update: version 1.24. +- Update: dbtohtml.dsl. +- Fix typo in CATALOG.docbkdsl (refer CATALOG.dokbk30). + +------------------------------------------------------------------- +Fri Nov 13 15:52:19 MET 1998 - bs@suse.de + +- removed trailing blanks (problem with new rpm) + +------------------------------------------------------------------- +Fri Nov 6 09:38:22 MET 1998 - ke@suse.de + +- Update: version 1.23 (bug fix release). + +------------------------------------------------------------------- +Thu Nov 5 18:32:10 MET 1998 - ke@suse.de + +- Update: version 1.22. + +------------------------------------------------------------------- +Mon Oct 26 10:00:31 MET 1998 - ke@suse.de + +- Formerly, this software was part of the package `dokbk30'. + Version 1.19. + diff --git a/docbook-dsssl-stylesheets.spec b/docbook-dsssl-stylesheets.spec new file mode 100644 index 0000000..916cfe1 --- /dev/null +++ b/docbook-dsssl-stylesheets.spec @@ -0,0 +1,161 @@ +# +# spec file for package docbook-dsssl-stylesheets +# +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +Name: docbook-dsssl-stylesheets +BuildRequires: fdupes +BuildRequires: sgml-skel +%define regcat /usr/bin/sgml-register-catalog +PreReq: %{regcat} +BuildArch: noarch +Summary: DSSSL Stylesheets for the DocBook DTD +License: SUSE-XSL-Lint +Group: Productivity/Publishing/DocBook +Version: 1.79 +Release: 0 +Url: http://sourceforge.net/projects/docbook/ +Source0: http://downloads.sourceforge.net/project/docbook/docbook-dsssl/%{version}/docbook-dsssl-%{version}.tar.gz +Source1: http://downloads.sourceforge.net/project/docbook/docbook-dsssl-doc/%{version}/docbook-dsssl-doc-%{version}.tar.gz +%define db2html dbtohtml.dsl +Source2: dbtohtml.dsl +%define ld2db ld2db.dsl +Source3: ld2db.dsl +Source4: %{name}-README.SUSE +# Source5: html-dbqanda.dsl +# Source6: print-dbqanda.dsl +%define pkgdif docbkdsl.dif +Patch0: docbkdsl.dif +Requires: docbook_3 +Requires: docbook_4 +Obsoletes: docbkdsl +Provides: docbkdsl +BuildRoot: %{_tmppath}/%{name}-%{version}-build + +%description +Use these DSSSL stylesheets to convert DocBook documents into other +formats. "Print" (TeX and RTF) and "online" (HTML) output formats are +available. + +The stylesheets are customizable and, within limits, it is possible to +adapt them for your own needs. Numerous native languages are supported. + +The authors of these stylesheets do not inlude any new features, but +only fix bugs. + +%define INSTALL install -m755 -s +%define INSTALL_DIR install -d -m755 +%define INSTALL_DATA install -m644 +%define INSTALL_SCRIPT install -m755 -o root -g root +%define sgml_dir %{_datadir}/sgml + +%prep +%setup -q -n docbook-dsssl-%{version} -b 1 +# cp -p %{S:5} html/dbqanda.dsl +# cp -p %{S:6} print/dbqanda.dsl +cp -p %{_sourcedir}/%{db2html} . +cp -p %{_sourcedir}/%{ld2db} . +cp -p %{S:4} README.SUSE +%patch -P 0 -p 0 +#patch -P 1 -p 1 -b .cvs + +%build + +%install +doc_dir=%{buildroot}/%{_defaultdocdir}/%{name} +sgml_dir=%{buildroot}/%{_datadir}/sgml +sgml_dir_db=%{buildroot}/%{_datadir}/sgml/docbook +sgml_dir_db_sty=%{buildroot}/%{_datadir}/sgml/docbook/dsssl-stylesheets-%{version} +%{INSTALL_DIR} $sgml_dir_db_sty +cp -a [a-z]* $sgml_dir_db_sty +cp -a VERSION $sgml_dir_db_sty +%{INSTALL_DIR} $doc_dir +%{INSTALL_DIR} $sgml_dir/Norman_Walsh/document +%{INSTALL_DIR} $sgml_dir/Norman_Walsh/dtd +%{INSTALL_DIR} $sgml_dir/IDN_nwalsh.com/dtd +sed -e 's:^ \([a-z]\): %{_datadir}/sgml/docbook/dsssl-stylesheets-%{version}/\1:' \ + -e 's:^SGMLDECL ":SGMLDECL "%{_datadir}/sgml/docbook/dsssl-stylesheets-%{version}/:' \ + < catalog > CATALOG.docbkdsl +# echo -e "\ +# CATALOG \"/var/lib/sgml/CATALOG.iso_ent\"\n\ +# CATALOG \"/var/lib/sgml/CATALOG.docbk31\"\n\ +# CATALOG \"/var/lib/sgml/CATALOG.docbk30\"\n\ +# CATALOG \"/var/lib/sgml/CATALOG.docbk41\"\n"\ +# >> docbook/CATALOG.docbkdsl +%{INSTALL_DATA} CATALOG.docbkdsl $sgml_dir/CATALOG.%{name} +pushd $sgml_dir +ln -sf CATALOG.%{name} CATALOG.docbkdsl +popd +# documentation +# pushd docbook + for f in README BUGS TODO WhatsNew; do + [ -f $f ] && %{INSTALL_DATA} $f $doc_dir/$f + done +# popd +# misc +%{INSTALL_DIR} $sgml_dir_db_sty/misc +cp %{db2html} $sgml_dir_db_sty/misc +cp %{ld2db} $sgml_dir_db_sty/misc +# cp index.html $doc_dir +cp -p README.SUSE $doc_dir +pushd $sgml_dir/docbook + rm -f dsssl-stylesheets + ln -sf dsssl-stylesheets-%{version} dsssl-stylesheets + # remove this when docbook-toys is updated + # 2001-11-29 10:56:56 CET -ke- + rm -f %{name} + ln -sf dsssl-stylesheets-%{version} %{name} +popd +%fdupes %{buildroot}%{_datadir} + +%post +# remove empty dirs if present (from ghost; pre 8.0) +# also remove dangling symlinks +D=usr/share/sgml +rmdir $D/docbkdsl >/dev/null 2>&1 || : +test -L $D/docbkdsl -a ! -e $D/docbkdsl && rm -f $D/docbkdsl +D=var/lib/sgml +rmdir $D/docbkdsl >/dev/null 2>&1 || : +test -L $D/docbkdsl -a ! -e $D/docbkdsl && rm -f $D/docbkdsl +D=usr/share/sgml/docbook +rmdir $D/%{name} >/dev/null 2>&1 || : +test -L $D/%{name} -a ! -e $D/%{name} && rm -f $D/%{name} +# register catalog +if [ -x %{regcat} ]; then + for c in %{name}; do + grep -q -e "%{sgml_dir}/CATALOG.$c\"\?$" /etc/sgml/catalog \ + || %{regcat} -a %{sgml_dir}/CATALOG.$c >/dev/null 2>&1 + done +fi +exit 0 + +%postun +if [ "$1" = "0" -a -x %{regcat} ]; then + for c in %{name}; do + %{regcat} -r %{sgml_dir}/CATALOG.$c >/dev/null 2>&1 + done +fi +exit 0 + +%files +%defattr(-, root, root) +%{_datadir}/sgml/CATALOG.* +%{_datadir}/sgml/docbook/dsssl-stylesheets +%{_datadir}/sgml/docbook/%{name} +%{_datadir}/sgml/docbook/dsssl-stylesheets-%{version} +%{_defaultdocdir}/%{name} + +%changelog diff --git a/ld2db.dsl b/ld2db.dsl new file mode 100644 index 0000000..61219ef --- /dev/null +++ b/ld2db.dsl @@ -0,0 +1,860 @@ + + + + + +;; +;; linuxdoc to docbook transformation stylesheet +;; +;; Charles Bozeman +;; +;; $Id: ld2db.dsl,v 1.2 1998/10/05 18:40:46 cg Exp $ +;; +;; This transformation stylesheet attempts to "pretty print" the +;; resulting sgml document. +;; +;; Several of the procedure are copied from other sources such as +;; Norm Walsh's docbook stylesheets, Paul Prescod's transform.dsl, +;; and Mulberry Technologies DSSSL pages. +;; +;; Invocation example: +;; jade -t sgml -d ld2db.dsl#db in.sgm >out.sgm + +;; ============================ PARAMETERS ============================== + +(define %transform-element-BF% "Emphasis") +(define %transform-element-SL% "Emphasis") +(define %transform-element-TT% "Literal") +(define %ids-repl-list% `("0" "i-0" "1" "i-1" "2" "i-2" "3" "i-3" + "4" "i-4" "5" "i-5" "6" "i-6" "7" "i-7" + "8" "i-8" "9" "i-9")) + + + + + + + +(define debug + (external-procedure "UNREGISTERED::James Clark//Procedure::debug")) + +;(declare-characteristic preserve-sdata? +; "UNREGISTERED::James Clark//Characteristic::preserve-sdata?" +; #f) + + +;; ====================== Library Functions ======================== + +(define (node-list-first-element nodelist) + ;; REFENTRY lib-node-list-first-element + ;; PURP Return the first element node in a node list + ;; DESC + ;; This function returns the first node in a node list which is + ;; an element (as opposed to a PI or anything else that might appear + ;; in a node list). + ;; /DESC + ;; /REFENTRY + (let loop ((nl nodelist)) + (if (node-list-empty? nl) + (empty-node-list) + (if (gi (node-list-first nl)) + (node-list-first nl) + (loop (node-list-rest nl)))))) + +(define (ipreced nl) + ;; REFENTRY lib-ipreced + ;; PURP Implements ipreced as per ISO/IEC 10179:1996 + ;; DESC + ;; Implements 'ipreced' as per ISO/IEC 10179:1996 + ;; /DESC + ;; AUTHOR From ISO/IEC 10179:1996 + ;; /REFENTRY + (node-list-map (lambda (snl) + (let loop ((prev (empty-node-list)) + (rest (siblings snl))) + (cond ((node-list-empty? rest) + (empty-node-list)) + ((node-list=? (node-list-first rest) snl) + prev) + (else + (loop (node-list-first rest) + (node-list-rest rest)))))) + nl)) + + +(define (ifollow nl) + ;; REFENTRY + ;; PURP Implements ifollow as per ISO/IEC 10179:1996 + ;; DESC + ;; Implements 'ifollow' as per ISO/IEC 10179:1996 + ;; /DESC + ;; AUTHOR From ISO/IEC 10179:1996 + ;; /REFENTRY + (node-list-map (lambda (snl) + (let loop ((rest (siblings snl))) + (cond ((node-list-empty? rest) + (empty-node-list)) + ((node-list=? (node-list-first rest) snl) + (node-list-first (node-list-rest rest))) + (else + (loop (node-list-rest rest)))))) + nl)) + +(define (siblings snl) + ;; REFENTRY + ;; PURP Implements siblings as per ISO/IEC 10179:1996 + ;; DESC + ;; Implements 'siblings' as per ISO/IEC 10179:1996 + ;; /DESC + ;; AUTHOR From ISO/IEC 10179:1996 + ;; /REFENTRY + (children (parent snl))) + +;; ====================================================================== + +(define (sgml-root-element) + ;; REFENTRY + ;; PURP Returns the node that is the root element of the current document + ;; DESC + ;; Return the root element of the document by walking up from + ;; wherever we are. (Isn't this built-in to DSSSL somehow???) + ;; /DESC + ;; /REFENTRY + (let loop ((root (current-node))) + (if (node-list-empty? (parent root)) + root + (loop (parent root))))) + +;; ====================================================================== + +(define (repl-substring? string target pos) + ;; REFENTRY lib-repl-substring-p + ;; PURP Returns true if the specified substring can be replaced + ;; DESC + ;; Returns '#t' if 'target' occurs at 'pos' in 'string'. + ;; /DESC + ;; /REFENTRY + (let* ((could-match (<= (+ pos (string-length target)) + (string-length string))) + (match (if could-match + (substring string pos (+ pos (string-length target))) ""))) + (and could-match (string=? match target)))) + +(define (repl-substring string target repl pos) + ;; REFENTRY lib-repl-substring + ;; PURP Replace substring in a string + ;; DESC + ;; Replaces 'target' with 'repl' in 'string' at 'pos'. + ;; /DESC + ;; /REFENTRY + (let ((matches (repl-substring? string target pos))) + (if matches + (string-append + (substring string 0 pos) + repl + (substring string + (+ pos (string-length target)) + (string-length string))) + string))) + +(define (repl-substring-list? string replace-list pos) + ;; REFENTRY lib-repl-substring-list-p + ;; PURP Perform repl-substring? with a list of target/replacement pairs + ;; DESC + ;; Returns '#t' if any target in 'replace-list' occurs at 'pos' in 'string'. + ;; ARGS + ;; ARG 'string' + ;; The string in which replacement should be tested. + ;; /ARG + ;; ARG 'replace-list' + ;; A list of target/replacement pairs. This list is just a list of + ;; strings, treated as pairs. For example, '("was" "x" "is" "y")'. + ;; In this example, 'was' may be replaced by 'x' and 'is' may be + ;; replaced by 'y'. + ;; /ARG + ;; ARG 'pos' + ;; The location within 'string' where the test will occur. + ;; /ARG + ;; /ARGS + ;; /DESC + ;; EXAMPLE + ;; '(repl-substring-list? "this is it" ("was" "x" "is" "y") 2)' + ;; returns '#t': "is" could be replaced by "y". + ;; /EXAMPLE + ;; /REFENTRY + (let loop ((list replace-list)) + (let ((target (car list)) + (repl (car (cdr list))) + (rest (cdr (cdr list)))) + (if (repl-substring? string target pos) + #t + (if (null? rest) + #f + (loop rest)))))) + +(define (repl-substring-list-target string replace-list pos) + ;; REFENTRY lib-repl-substring-list-target + ;; PURP Return the target that matches in a string + ;; DESC + ;; Returns the target in 'replace-list' that matches in 'string' at 'pos' + ;; See also 'repl-substring-list?'. + ;; /DESC + ;; /REFENTRY + (let loop ((list replace-list)) + (let ((target (car list)) + (repl (car (cdr list))) + (rest (cdr (cdr list)))) + (if (repl-substring? string target pos) + target + (if (null? rest) + #f + (loop rest)))))) + +(define (repl-substring-list-repl string replace-list pos) + ;; REFENTRY lib-repl-substring-list-repl + ;; PURP Return the replacement that would be used in the string + ;; DESC + ;; Returns the replacement in 'replace-list' that would be used for the + ;; target that matches in 'string' at 'pos' + ;; See also 'repl-substring-list?'. + ;; /DESC + ;; /REFENTRY + (let loop ((list replace-list)) + (let ((target (car list)) + (repl (car (cdr list))) + (rest (cdr (cdr list)))) + (if (repl-substring? string target pos) + repl + (if (null? rest) + #f + (loop rest)))))) + +(define (repl-substring-list string replace-list pos) + ;; REFENTRY lib-repl-substring-list + ;; PURP Replace the first target in the replacement list that matches + ;; DESC + ;; Replaces the first target in 'replace-list' that matches in 'string' + ;; at 'pos' with its replacement. + ;; See also 'repl-substring-list?'. + ;; /DESC + ;; /REFENTRY + (if (repl-substring-list? string replace-list pos) + (let ((target (repl-substring-list-target string replace-list pos)) + (repl (repl-substring-list-repl string replace-list pos))) + (repl-substring string target repl pos)) + string)) + +(define (string-replace string target repl) + ;; REFENTRY lib-string-replace + ;; PURP Replace all occurances of a target substring in a string + ;; DESC + ;; Replaces all occurances of 'target' in 'string' with 'repl'. + ;; /DESC + ;; /REFENTRY + (let loop ((str string) (pos 0)) + (if (>= pos (string-length str)) + str + (loop (repl-substring str target repl pos) + (if (repl-substring? str target pos) + (+ (string-length repl) pos) + (+ 1 pos)))))) + +(define (node-list-first-element-after-match nodelist match-el) + ;; REFENTRY lib-node-list-first-element + ;; PURP Return the first element node in a node list after given element + ;; DESC + ;; This function returns the first node in a node list which appears + ;; after the given match element n element (as opposed to a PI or + ;; aanything else that might appear n a node list). + ;; /DESC + ;; /REFENTRY + (let loop ((nl nodelist)) + (if (node-list-empty? nl) + (empty-node-list) + (if (equal? (gi (node-list-first nl)) match-el) + (let loop-2 ((nl (node-list-rest nl))) + (if (node-list-empty? nl) + (empty-node-list) + (if (gi (node-list-first nl)) + (node-list-first nl) + (loop-2 (node-list-rest nl))))) + (loop (node-list-rest nl)))))) + + + + + + + +;; ============================ TOP LEVEL ============================== + +(declare-flow-object-class formatting-instruction + "UNREGISTERED::James Clark//Flow Object Class::formatting-instruction") +(declare-flow-object-class element + "UNREGISTERED::James Clark//Flow Object Class::element") +(declare-flow-object-class empty-element + "UNREGISTERED::James Clark//Flow Object Class::empty-element") +(declare-flow-object-class document-type + "UNREGISTERED::James Clark//Flow Object Class::document-type") +(declare-flow-object-class processing-instruction + "UNREGISTERED::James Clark//Flow Object Class::processing-instruction") +(declare-flow-object-class entity + "UNREGISTERED::James Clark//Flow Object Class::entity") +(declare-flow-object-class entity-ref + "UNREGISTERED::James Clark//Flow Object Class::entity-ref") + +(declare-characteristic preserve-sdata? + "UNREGISTERED::James Clark//Characteristic::preserve-sdata?" #t) + + +(define (start-tag str) + (string-append "<" str ">" )) + +(define (end-tag str) + (string-append "")) + +(define (comment-tag str) + (string-append "<" "--" str "--" ">")) + +; newline +;(define %RE% "\U-000D") +(define %RE% "&#RE;") + +(define (write-string str) + (make formatting-instruction + data: str)) + +(define (write-string-RE str) + (make formatting-instruction + data: (string-append str %RE%))) + +(define (RE-write-string str) + (make formatting-instruction + data: (string-append %RE% str))) + +(define (RE-write-string-RE str) + (make formatting-instruction + data: (string-append %RE% str %RE%))) + +; procedure for enclosing inline data between pre and aft text +(define ($make-inline$ pre aft) + (sosofo-append + (write-string pre) + (process-children) + (write-string aft))) + +; procedure for enclosing a block of data between pre and aft text +; Note: always terminates with a newline +(define ($make-block$ pre aft) + (sosofo-append + (write-string pre) + (process-children) + (write-string-RE aft))) + +(define ($remap-attr$ el) + (cons (list "REMAP" el) `())) + +(define (attr-name lis) + (car (car lis))) + +(define (attr-value lis) + (car (cdr (car lis)))) + +; given a list of attribute pairs, output them +(define ($out-attributes$ attlist) + (let loop ((rest attlist)) + (if (equal? rest `()) + (write-string ">") + (make sequence + (write-string (string-append " " + (attr-name rest) + "=\"" ; open quote + (attr-value rest) + "\"")) ; close quote + (loop (cdr rest)))))) + + +(define (make-block-element #!optional #!key gind attributes + (sosofo (process-children))) + (let ((gi-nd (if gind gind (gi (current-node))))) + (sosofo-append + (RE-write-string (string-append "<" gi-nd)) + (if attributes + ($out-attributes$ attributes) + (write-string-RE ">")) + sosofo + (RE-write-string-RE (end-tag gi-nd))))) + +(define (make-comment-element #!optional #!key gind attributes + (sosofo (process-children))) + (let ((gi-nd (if gind gind (gi (current-node))))) + (sosofo-append + (RE-write-string (string-append "<" "!--" gi-nd "--" ">")) + (if attributes + ($out-attributes$ attributes) + (write-string-RE ">")) + sosofo + (RE-write-string-RE (string-append "<" "!--" "/" gi-nd "--" ">"))))) + +(define (make-inline-element #!optional #!key gind attributes + (sosofo (process-children))) + (let ((gi-nd (if gind gind (gi (current-node))))) + (sosofo-append + (write-string (string-append "<" gi-nd)) + (if attributes + ($out-attributes$ attributes) + (write-string ">")) + sosofo + (write-string (end-tag gi-nd))))) + +(define (make-empty-inline-element #!optional #!key gind attributes + (sosofo (process-children))) + (let ((gi-nd (if gind gind (gi (current-node))))) + (sosofo-append + (write-string (string-append "<" gi-nd)) + (if attributes + ($out-attributes$ attributes) + (write-string ">")) + sosofo))) + +(define (make-line-element #!optional #!key gind attributes + (sosofo (process-children))) + (let ((gi-nd (if gind gind (gi (current-node))))) + (sosofo-append + (RE-write-string (string-append "<" gi-nd)) + (if attributes + ($out-attributes$ attributes) + (write-string ">")) + sosofo + (write-string-RE (end-tag gi-nd))))) + +(define (make-empty-line-element #!optional #!key gind attributes + (sosofo (process-children))) + (let ((gi-nd (if gind gind (gi (current-node))))) + (sosofo-append + (RE-write-string (string-append "<" gi-nd)) + (if attributes + ($out-attributes$ attributes) + (write-string ">")) + sosofo))) + + + + + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; From the DSSSL Cookbook +;; http://www.mulberrytech.com/dsssl/dsssldoc/cookbook/cookbook.html +;; Default rule + +(default (output-element)) + +(define (output-element #!optional (node (current-node))) + (if (node-property "must-omit-end-tag?" node) + (make empty-element + attributes: (copy-attributes)) + (make element + attributes: (copy-attributes)))) + +(define (copy-attributes #!optional (nd (current-node))) + (let loop ((atts (named-node-list-names (attributes nd)))) + (if (null? atts) + '() + (let* ((name (car atts)) + (value (attribute-string name nd))) + (if value + (cons (list name value) + (loop (cdr atts))) + (loop (cdr atts))))))) + + +(element LINUXDOC (process-children)) + +(element ARTICLE + (make sequence + (make document-type name: "Article" + public-id: "-//Davenport//DTD DocBook V3.0//EN") + (make-block-element gind: "Article"))) + +(element BOOK + (make sequence + (make document-type name: "Book" + public-id: "-//Davenport//DTD DocBook V3.0//EN" ) + (make-block-element gind: "Book"))) + +(element REPORT + (make sequence + (make document-type name: "Book" + public-id: "-//Davenport//DTD DocBook V3.0//EN" ) + (make-block-element gind: "Book" attributes: `(("remap" "report"))))) + +(element TITLEPAG + (if (equal? (gi (parent (current-node))) "ARTICLE") + (make-block-element gind: "ArtHeader") + (make-block-element + gind: "BookInfo" + sosofo: (make-block-element + gind: "BookBiblio")))) + +(element DATE (make-line-element gind: "PubDate")) + +; this may need to be fixed-up manually +(element NAME + (let ((htmlurl-nl (select-elements (children (current-node)) "HTMLURL"))) + (make sequence + (make-line-element gind: "FirstName") + (if (node-list-empty? htmlurl-nl) + (empty-sosofo) + (make-block-element gind: "AuthorBlurb" + sosofo: (make-line-element gind: "Para" + sosofo: (with-mode name-htmlurl + (process-node-list htmlurl-nl)))))))) + +;; does'nt work well, correct by hand +;(element INST (make element gi: "OrgName")) +(element INST (empty-sosofo)) + +(element ABSTRACT + (make-block-element + gind: "Abstract" + sosofo: (make-block-element gind: "Para"))) + +;; Norm's stylesheets build this stuff +(element TOC (empty-sosofo)) +(element LOT (empty-sosofo)) +(element LOF (empty-sosofo)) + +(element TITLE (make-line-element gind: "Title")) + +;; ========================== BLOCK ELEMENTS ============================ + +(element P + (let ((para-empty (if (and (equal? 0 (string-length (data (current-node)))) + (node-list-empty? (children (current-node)))) + #t #f))) + (if para-empty + (empty-sosofo) ; don't leave empty paragraphs lying around! + (make-block-element gind: "Para" )))) + +(element APPENDIX + (let* ((follow-nd (ifollow (current-node))) + (chapt-next (if (equal? (gi follow-nd) "CHAPT") #t #f))) + (if chapt-next + (empty-sosofo) + (make-empty-line-element + sosofo: (make-line-element + gind: "Title" + sosofo: (literal "Appendix")))))) + +(element CHAPT + (let* ((preced-nd (ipreced (current-node))) + (apdx-prev (if (equal? (gi preced-nd) "APPENDIX") #t #f))) + (if apdx-prev + ($make-sect$ "Appendix") + ($make-sect$ "Chapter")))) + +(element SECT ($make-sect$ "Sect1")) +(element SECT1 ($make-sect$ "Sect2")) +(element SECT2 ($make-sect$ "Sect3")) +(element SECT3 ($make-sect$ "Sect4")) +(element SECT4 ($make-sect$ "Sect5")) + +;; build a section (or chapter) +(define ($make-sect$ gi-name) + (let ((attrs ($get-sect-id$ (current-node)))) + (make-block-element gind: gi-name attributes: attrs))) + + +;; look for a label element in a heading element then put the 'id' in +;; the section (or chapter) attribute +(define ($get-sect-id$ nd) + (let* ((heading (node-list-first + (select-elements (children nd) "HEADING"))) + (label (select-elements (children heading) "LABEL")) + (label-id (if (node-list-empty? label) + #f + ($fix-ids$ + (attribute-string "id" (node-list-first label))))) + (attrs (if label-id + (cons (list "id" ($fix-ids$ label-id)) (copy-attributes)) + (copy-attributes)))) + attrs)) + +;; look for a label element in a child elements +(define ($get-child-id$ nd) + (let* ((label (select-elements (children nd) "LABEL"))) + (if (node-list-empty? label) + #f + ($fix-ids$ (attribute-string "id" (node-list-first label)))))) + +(element HEADING (make-line-element gind: "Title" )) + +(element HEADER (empty-sosofo)) +(element LHEAD (empty-sosofo)) +(element RHEAD (empty-sosofo)) + +;; ============================== LISTS ================================= + +(element ITEM + (let ((para-nl (select-elements (children (current-node)) "P")) + (item-empty (if (equal? 0 (string-length (data (current-node)))) + #t #f))) + (make sequence + (write-string-RE (start-tag "ListItem")) + (if (node-list-empty? para-nl) + (make-block-element gind: "Para") + (if item-empty + (process-children) + (make sequence + (write-string-RE (start-tag "Para")) + (process-children)))) + (write-string-RE (end-tag "ListItem"))))) + +(element ENUM (make-block-element gind: "OrderedList" )) +(element ITEMIZE (make-block-element gind: "ItemizedList" )) + +(element DESCRIP + (make sequence + (write-string-RE (start-tag "VariableList")) + (process-children) + (write-string-RE (end-tag "VarListEntry")) + (write-string (end-tag "VariableList")))) + +(element TAG + (let ((END-ENTRY (cond ((> (child-number) 1) + (end-tag "VarListEntry")) + (else "")))) + (make sequence + (write-string END-ENTRY) + (RE-write-string (start-tag "VarListEntry")) + (make-line-element gind: "Term") + (write-string (start-tag "ListItem"))))) + +;; =========================== FONT CHANGES ============================= + +(element EM + (if (equal? (gi (parent)) "TT") + (process-children) + (make-inline-element gind: "Emphasis"))) + +(element TT + (make-inline-element gind: %transform-element-TT% + attributes: `(("remap" "tt")))) + +(element BF + (if (equal? (gi (parent)) "TT") + (process-children) + (make-inline-element gind: %transform-element-BF% + attributes: `(("remap" "bf"))))) + +(element IT + (if (equal? (gi (parent)) "TT") + (process-children) + (make-inline-element gind: "Emphasis" + attributes: `(("remap" "it"))))) + +(element SL + (make-inline-element gind: %transform-element-SL% + attributes: `(("remap" "sl")))) + +(element CODE (make-block-element gind: "ProgramListing")) + +(element TSCREEN (make-block-element gind: "Screen")) +(element VERB (process-children)) + +;============================ Linking ================================== + +;; ID and IDREF cannot begin with a number and cannot have embedded spaces +;; or under bars. +(define ($fix-ids$ string) + (let* ((nw-str (string-replace string " " "-")) + (ub-str (string-replace nw-str "_" "-"))) + (repl-substring-list ub-str %ids-repl-list% 0))) + + +(element REF + (make-empty-inline-element + gind: "XRef" + attributes: `(("LinkEnd" ,($fix-ids$ (attribute-string "id")))))) + +(element HTMLURL + (if (equal? (gi (parent (current-node))) "NAME") + (empty-sosofo) + (make element gi: "ULink" + attributes: `(("URL" ,(attribute-string "URL"))) + (if (attribute-string "NAME") + (literal (attribute-string "NAME")) + (literal (attribute-string "URL")) )))) + +(element URL + (make element gi: "ULink" + attributes: `(("URL" ,(attribute-string "URL"))) + (if (attribute-string "NAME") + (literal (attribute-string "NAME")) + (literal (attribute-string "URL")) ))) + ; FIXME: Name attribute + +(element LABEL + (if (equal? (gi (parent (current-node))) "P") + (make-empty-inline-element + gind: "Anchor" + attributes: `(("id" ,($fix-ids$ (attribute-string "id"))))) + (empty-sosofo))) + +;; for when htmlurl is a child of name +(mode name-htmlurl + (element HTMLURL + (make-block-element + gind: "ULink" + attributes: `(("URL" ,(attribute-string "URL"))) + sosofo: (if (attribute-string "NAME") + (literal (attribute-string "NAME")) + (literal (attribute-string "URL")) )))) + +;; ======================== FIGURES and TABLES ========================== + +(define (make-graphic-el fileref) + (make-line-element gind: "Graphic" attributes: `(("FileRef" ,fileref)))) + +(element FIGURE + (let* ((caption-nl (select-elements (descendants (current-node)) "CAPTION")) + (label-id ($get-child-id$ caption-nl)) + (eps (select-elements (children (current-node)) "EPS")) + (file (attribute-string "file" (node-list-first eps)))) + (make-block-element + gind: "Figure" + attributes: (if label-id `(("id" ,($fix-ids$ label-id))) `()) + sosofo: (if (not (node-list-empty? caption-nl)) + (make sequence + (with-mode caption-to-title + (process-node-list caption-nl)) + (make-graphic-el (if file file "dummy"))) + (make-graphic-el (if file file "dummy")))))) + +(element EPS (empty-sosofo)) +(element PH (empty-sosofo)) + +(element CAPTION (empty-sosofo)) + +(mode caption-to-title + (element CAPTION + (make-line-element gind: "Title"))) + +;; currently the frame attribute must be set manually +(element TABLE + (let* ((caption-nl (select-elements (descendants (current-node)) "CAPTION")) + (label-id ($get-child-id$ caption-nl))) + (if (node-list-empty? caption-nl) + (make-block-element gind: "InformalTable") + (make-block-element gind: "Table" + attributes: (if label-id + `(("id" ,($fix-ids$ label-id))) + `()) + sosofo: (make sequence + (with-mode caption-to-title + (process-node-list caption-nl)) + (process-children)))))) + +(define ($count-cols$ ca-str) + (let loop ((cnt 0) (str ca-str)) + (if (equal? (string-length str) 0) + cnt + (if (equal? (substring str 0 1) "|") + (loop cnt (substring str 1 (string-length str))) + (loop (+ 1 cnt) (substring str 1 (string-length str))))))) + +(define ($make-colspecs$ ca-str) + (if (equal? (string-length ca-str) 0) + (empty-sosofo) + (if (equal? (substring ca-str 0 1) "|") + ($make-colspecs$ (substring ca-str 1 (string-length ca-str))) + (let loop ((str ca-str)) + (if (equal? (string-length str) 0) + (empty-sosofo) + (let* ((col-sep (if (> (string-length str) 1) + (if (equal? (substring str 1 2) "|") + #t + #f) + #f)) + (pos (if col-sep 2 1))) + (make sequence + ($build-colspec$ (substring str 0 1) col-sep) + (loop (substring str pos (string-length str)))))))))) + +(define ($build-colspec$ cell-align col-sep) + (let* ((cellalign (case cell-align + (("l") "Left") + (("c") "Center") + (("r") "Right") + (else "Left"))) + (attrs (cons (list "Align" cellalign) (cons + (if col-sep + (list "Colsep" "1") + (list "Colsep" "0")) + `())))) + (make-empty-line-element + gind: "ColSpec" + attributes: attrs + sosofo: (empty-sosofo)))) + +(element TABULAR + (let* ((col-attr (attribute-string "CA")) + (colcnt ($count-cols$ col-attr))) + (make-block-element + gind: "TGroup" + attributes: `(("Cols" ,(number->string colcnt))) + sosofo: (make sequence + ($make-colspecs$ col-attr) + (RE-write-string-RE (start-tag "TBody")) + (row-check-border (node-list-first (children (current-node)))) + (write-string (start-tag "Entry")) + (process-children) + (write-string-RE (end-tag "Entry")) + (write-string-RE (end-tag "Row")) + (write-string-RE (end-tag "TBody")))))) + +(element COLSEP + (make sequence + (write-string (end-tag "Entry")) + (RE-write-string (start-tag "Entry")))) + +;; find the next "rowsep" then check if a "hline" immediatly follows +(define (row-check-border nd) + (let* ((follow-nl (follow nd)) + (af-nl (node-list-first-element-after-match follow-nl "ROWSEP")) + (hline-next (if (equal? (gi af-nl) "HLINE") #t #f))) + (if hline-next + (make sequence + (write-string (string-append "<" "Row")) + (if attributes + (make sequence + ($out-attributes$ `(("RowSep" "1"))) + (write-string %RE%)) + (write-string-RE ">"))) + (write-string-RE (start-tag "Row"))))) + +(element ROWSEP + (make sequence + (write-string-RE (end-tag "Entry")) + (write-string-RE (end-tag "Row")) + (row-check-border (current-node)) + (write-string-RE (start-tag "Entry")))) + +; for now +(element HLINE (empty-sosofo)) + +; don't do any math +(element DM (empty-sosofo)) + +(element FOOTNOTE + (make-block-element + sosofo: (make-block-element gind: "Para"))) + +(element NEWLINE + (write-string %RE%)) + + + +