Sync from SUSE:SLFO:Main docbook-dsssl-stylesheets revision 026d6e8cf02357d44c3ad32e466d0e8e

This commit is contained in:
Adrian Schröter 2024-05-03 12:07:10 +02:00
commit 31a924b7a6
9 changed files with 3662 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -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

2247
dbtohtml.dsl Normal file

File diff suppressed because it is too large Load Diff

20
docbkdsl.dif Normal file
View File

@ -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 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+ <head>
+ <title>Norman Walsh: The Modular DocBook Stylesheets</title>
+ </head>
+
+ <body>
+
+<ul>
+
+<li><a href="html/index.html">The Modular DocBook Stylesheets</a> by
+Norman Walsh.</li>
+
+</ul>
+
+</body>
+</html>

BIN
docbook-dsssl-1.79.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

BIN
docbook-dsssl-doc-1.79.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -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.

View File

@ -0,0 +1,331 @@
-------------------------------------------------------------------
Tue Feb 5 14:51:27 UTC 2019 - Jan Engelhardt <jengelh@inai.de>
- 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 <productname>
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.

View File

@ -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

860
ld2db.dsl Normal file
View File

@ -0,0 +1,860 @@
<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" >
<style-sheet>
<style-specification id="params">
<style-specification-body>
;;
;; 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"))
</style-specification-body>
</style-specification>
<style-specification id="library" >
<style-specification-body>
(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))))))
</style-specification-body>
</style-specification>
<style-specification id="common" >
<style-specification-body>
;; ============================ 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 "</" str ">"))
(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)))
</style-specification-body>
</style-specification>
<style-specification id="db" use="common library params">
<style-specification-body>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 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%))
</style-specification-body>
</style-specification>
</style-sheet>