2
# db2html.in - Docbook to HTML rendering (wk 2000-02-15)
4
# Copyright (C) 2000 Free Software Foundation
6
# This is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
11
# This is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
22
stylesheet=@DSL_FOR_HTML@
26
echo 'usage: db2html [--nosplit] [--copyfiles] filename' >&2
31
while test "`echo $1 | head -c1`" = "-"; do
36
Copyright (C) 2000 Free Software Foundation, Inc.
37
This is free software; see the source for copying conditions. There is NO
38
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
40
stylesteet: $stylesheet
58
echo "invalid option $1" >&2
71
# grep the document type
72
doctype=`grep -i '\<doctype' $input|awk 'NR==1 {print $2}'| tr '[A-Z]' '[a-z]'`
73
if test -z $doctype; then
75
echo "no DOCTYPE found - assuming '$doctype'" >&2
77
echo "DOCTYPE is '$doctype'" >&2
80
output="`basename $input| sed 's/\.sgml$//'`.html"
83
if test $nosplit = yes; then
84
echo "running jade on '$input' ..." >&2
85
$JADE -d $stylesheet -t sgml -i html -V nochunks $input > $output
86
echo "$output created"
90
if test -d html ; then
94
echo "'html' directory created" >&2
96
echo "failed to create 'html' directory" >&2
101
outputdir="html/`basename $input| sed 's/\.sgml$//'`"
103
if test -d $outputdir ; then
106
if mkdir $outputdir; then
107
echo "'$outputdir' created" >&2
109
echo "failed to create '$outputdir'" >&2
113
echo "creating html pages in '$outputdir' ..." >&2
114
if test "$input" = "`basename $input`"; then
119
echo "running jade on '$inp' ..." >&2
120
(cd $outputdir && $JADE -t sgml -i html -d $stylesheet $inp )
121
echo "html version in '$outputdir' created" >&2
123
# break out all filerefs and copy them to the outputdirectory
124
# fixme: handling of path components is wrong
125
if test $copyfiles = yes; then
126
echo "looking for filerefs ..." >&2
127
for file in `nsgmls -i html $input \
128
| awk '/^AFILEREF[ \t]+CDATA/ {print $3}'`; do
129
d=$outputdir/`basename $file`
130
if cat $file > $outputdir/`basename $file` ; then
131
echo " $file -> $d" >&2
136
mainfile=`ls $outputdir/${doctype}* | head -1`
139
<html><title>$output</title>
142
<a href="$mainfile">$mainfile</a>
148
echo "$output created with link to '$mainfile'" >&2