summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--usr.bin/sgmlfmt/sgmlfmt.174
-rwxr-xr-xusr.bin/sgmlfmt/sgmlfmt.pl141
2 files changed, 89 insertions, 126 deletions
diff --git a/usr.bin/sgmlfmt/sgmlfmt.1 b/usr.bin/sgmlfmt/sgmlfmt.1
index cd5ef28..9b9016e 100644
--- a/usr.bin/sgmlfmt/sgmlfmt.1
+++ b/usr.bin/sgmlfmt/sgmlfmt.1
@@ -1,24 +1,28 @@
-.Dd September 9, 1995
-.Os FreeBSD 2.1
+.Dd May 9, 1997
+.Os FreeBSD 2.2
.Dt SGMLFMT 1
.Sh NAME
.Nm sgmlfmt
-.Nd Formats SGML files tagged according to the linuxdoc DTD.
+.Nd Formats linuxdoc and DocBook SGML documents.
.Sh SYNOPSIS
.Nm
+.Op Fl d Ar doctype
.Fl f Ar format
-.Op Fl links
-.Op Fl ssi
.Op Fl i Ar name ...
+.Op Fl links
+.Op Fl e Ar encoding
+.Op Fl hdr Ar file
+.Op Fl ftr Ar file
.Ar file
.Sh DESCRIPTION
The
.Nm
-command reads SGML files tagged according to the linuxdoc DTD,
+command reads SGML files tagged according to the linuxdoc or
+DocBook DTD,
validates them using the
.Xr sgmls 1
parser and then converts them to the specified output format.
-The input file must include the following document type
+Linuxdoc input files must include the following document type
declaration before any uncommented text:
.Bd -literal -offset indent
<!DOCTYPE linuxdoc PUBLIC "-//FreeBSD//DTD linuxdoc//EN">
@@ -28,6 +32,16 @@ Options for
.Nm
include the following:
.Bl -tag -width Ds
+.It Fl d Ar doctype
+Specifies the SGML document type of the source file. Currently
+supported document types are
+.Ar linuxdoc
+and
+.Ar docbook .
+If no
+.Fl d
+option is specified, the default is
+.Ar linuxdoc .
.It Fl f Ar format
Determines the output format which can be one of the following:
.Bl -tag -width Ds
@@ -52,13 +66,6 @@ Generates a single output file with the extension
.Pa .koi8-r
suitable for viewing on an terminal supporting the KOI8-R
character encoding.
-.It Ar latex
-Generates a single output file with the extension
-.Pa .latex
-suitable for processing with LaTeX. Note that the LaTeX style
-file
-.Pa /usr/share/sgml/FreeBSD/linuxdoc.sty
-must be accessible to LaTeX for correct processing.
.It Ar latin1
Generates a single output file with the extension
.Pa .latin1
@@ -121,43 +128,30 @@ links becoming invalid when the target document is modified.
When creating a symbolic link, any occurrence of a slash (/) in label
is replaced with percent (%), while any occurrence of a space is replaced
with an underscore (_).
-.It Fl ssi
+.It Fl e Ar encoding
When used with the
.Fl f Ar html
-option, hooks will be placed to have an http server include a
-custom header and footer on the document using the server side
-include mechanism. This mechanism is supported by the Apache and
-NCSA http servers and possibly others. Included files are named
-.Pa file.hdr
-and
-.Pa file.ftr
-for the header and footer of the
-.Pa file.html .
-Other pages include file are named
-.Pa file.ftr1 ,
-.Pa file.ftr2 ...
-.Pa file.ftrn
-where the number corresponds to the depth of the file from
-.Pa file.html .
+option, specifies document encoding to use for the generated
+HTML files. If this option is not specified, iso-8859-1 is used.
+.It Fl hdr Ar file
+When used with the
+.Fl f Ar html
+option, the specified file will be inserted at the beginning of the
+body element of each generated HTML file.
+.It Fl ftr Ar file
+When used with the
+.Fl f Ar html
+option, the specified file will be inserted at the end of the
+body element of each generated HTML file.
.El
.Pp
-If the input file name ends with
-.Pa .sgml ,
-the extension may be omitted on the command line.
In all cases, the output files are created in the current working
directory.
.Sh FILES
-.Pa /usr/share/sgml/FreeBSD/linuxdoc.dtd
-- the linuxdoc DTD.
-.Pp
.Pa /usr/share/sgml/transpec
- directory containing translation specification files for
.Xr instant 1 .
.Pp
-.Pa /usr/share/sgml/FreeBSD/linuxdoc.sty
-- the LaTeX style used in documents produced with the
-.Fl f Ar latex
-format option.
.Sh SEE ALSO
.Xr groff 1 ,
.Xr instant 1 ,
diff --git a/usr.bin/sgmlfmt/sgmlfmt.pl b/usr.bin/sgmlfmt/sgmlfmt.pl
index ed3b757..2c5503d 100755
--- a/usr.bin/sgmlfmt/sgmlfmt.pl
+++ b/usr.bin/sgmlfmt/sgmlfmt.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id$
+# $Id: sgmlfmt.pl,v 1.17.2.2 1997/02/07 02:47:27 jfieber Exp $
# Copyright (C) 1996
# John R. Fieber. All rights reserved.
@@ -67,8 +67,10 @@ $SIG{'QUIT'} = 'sighandler';
sub usage {
print "Usage:\n";
- print "sgmlfmt -f <format> [-i <namea> ...] [-links] [-ssi] file\n";
- print "where <format> is one of: ascii, html, koi8-r, latex, latin1, ps, roff\n";
+ print "sgmlfmt [-d <doctype>] -f <format> [-i <namea> ...] [-links]\n";
+ print " [-e encoding] [-hdr file] [-ftr file] file\n";
+ print "where <doctype> is one of: linuxdoc (default), docbook.\n";
+ print "and <format> is one of: ascii, html, koi8-r, latin1, ps, roff\n";
}
#
@@ -158,22 +160,6 @@ sub do_groff {
}
#
-# Generate LaTeX output
-#
-
-sub gen_latex {
- @cleanfiles = (@cleanfiles, "${fileroot}.latex");
- open(outfile, ">$fileroot.latex");
- &sgmlparse(infile, "latex");
- while (<infile>) {
- print outfile;
- }
- close(infile);
- close(outfile);
-}
-
-
-#
# Generate HTML output.
#
# HTML is generated in two passes.
@@ -352,25 +338,18 @@ sub html2html {
$st_parent[0] = -1;
$t = $st_header[0];
$t =~ s|<[a-zA-Z/][^>]*>||g;
- print tocfile "<HEAD>\n<TITLE>$t</TITLE>\n</HEAD>\n";
+ print tocfile "<HEAD>\n<TITLE>$t</TITLE>\n" .
+ $html_encoding . "</HEAD>\n";
print tocfile "<H1>$st_header[0]</H1>\n";
$header[$st_ol[$sc]] =
"$doctype\n<HTML>\n<HEAD>\n<TITLE>$t</TITLE>\n" .
- "</HEAD>\n$BODY\n";
+ $html_encoding . "</HEAD>\n$BODY\n";
$header[$st_ol[$sc]] .= $html_header;
- if ($opt_ssi) { # Server Side Include hook
- $header[$st_ol[$sc]] .=
- "<!--#include virtual=\"./$fileroot.hdr\" -->";
- }
$header[$st_ol[$sc]] .= "\n<H1>$st_header[0]</H1>\n";
$footer[$st_ol[$sc]] = "\n";
$footer[$st_ol[$sc]] .= $html_footer;
- if ($opt_ssi) { # Server Side Include hook
- $footer[$st_ol[$sc]] .=
- "<!--#include virtual=\"./$fileroot.ftr\" -->";
- }
$footer[$st_ol[$sc]] .= "\n</BODY>\n</HTML>\n";
last tagsw;
}
@@ -393,19 +372,12 @@ sub html2html {
$t = $_;
$t =~ s|<[a-zA-Z/][^>]*>||g;
$header[$st_ol[$sc]] =
- "$doctype\n<HTML>\n<HEAD>\n<TITLE>$t</TITLE>\n</HEAD>\n$BODY\n";
+ "$doctype\n<HTML>\n<HEAD>\n<TITLE>$t</TITLE>\n" .
+ $html_encoding . "</HEAD>\n$BODY\n";
$header[$st_ol[$sc]] .= $html_header;
- if ($opt_ssi) { # Server Side Include hook
- $header[$st_ol[$sc]] .=
- "<!--#include virtual=\"./$fileroot.hdr$st_ol[$sc]\" -->";
- }
$header[$st_ol[$sc]] .= "\n$navbar[$st_ol[$sc]]\n<HR NOSHADE>\n";
$footer[$st_ol[$sc]] = "<HR NOSHADE>\n$navbar[$st_ol[$sc]]\n";
$footer[$st_ol[$sc]] .= $html_footer;
- if ($opt_ssi) { # Server Side Include hook
- $footer[$st_ol[$sc]] .=
- "<!--#include virtual=\"./$fileroot.ftr$st_ol[$sc]\" -->";
- }
$footer[$st_ol[$sc]] .= "\n</BODY>\n</HTML>\n";
}
@@ -635,7 +607,6 @@ sub navbar {
#
sub docbook_html {
- $decl = "/usr/share/sgml/docbook/docbook.dcl";
@cleanfiles = (@cleanfiles, "${fileroot}.html");
open (outfile, ">$fileroot.html");
&sgmlparse(infile, "html");
@@ -676,7 +647,7 @@ sub extlink {
sub main {
# Check arguments
- if (!&NGetOpt('d=s', 'f=s', 'links', 'ssi', 'i:s@', 'hdr=s', 'ftr=s')) {
+ if (!&NGetOpt('d=s', 'f=s', 'links', 'i:s@', 'hdr=s', 'ftr=s', 'e=s')) {
&usage;
exit 1;
}
@@ -691,63 +662,61 @@ sub main {
exit 1;
}
- # Generate output
- if ($opt_d eq 'docbook') {
+ # Figure out which DTD we are using
+ if ($opt_d eq "docbook") {
$dtd = "docbook";
$decl = "/usr/share/sgml/docbook/docbook.dcl";
- if ($opt_f eq 'html') {
- if ($opt_hdr) {$instantopts .= " -D \"inchdr=${opt_hdr}\"";}
- if ($opt_ftr) {$instantopts .= " -D \"incftr=${opt_ftr}\"";}
- &docbook_html();
- }
- else {
- if ($opt_f eq "") {
- print "An output format must be specified with the -f
- option.\n";
- }
- else {
- print "\"$opt_f\" is an unknown output format.\n";
- }
- &usage;
- exit 1;
- }
}
else {
$dtd = "linuxdoc";
$decl = "/usr/share/sgml/FreeBSD/linuxdoc.dcl";
- if ($opt_f eq 'html') {
+ }
+
+ # Generate the output
+ if ($opt_f eq 'html') {
+ # Set the character encoding
+ if (! $opt_e) {
+ $opt_e = "iso-8859-1";
+ }
+ $html_encoding = "<META HTTP-EQUIV=\"Content-Type\" " .
+ "CONTENT=\"text/html; charset=" . $opt_e . "\">\n";
+
+ if ($dtd eq "docbook") {
+ if ($opt_hdr) {$instantopts .= " -D \"inchdr=${opt_hdr}\"";}
+ if ($opt_ftr) {$instantopts .= " -D \"incftr=${opt_ftr}\"";}
+ &docbook_html();
+ }
+ else {
if ($opt_hdr) {$html_header = &gethf($opt_hdr);}
if ($opt_ftr) {$html_footer = &gethf($opt_ftr);}
- &gen_html();
- }
- elsif ($opt_f eq 'latex' || $opt_f eq 'latex') {
- &gen_latex();
- }
- elsif ($opt_f eq 'roff') {
- &gen_roff();
- }
- elsif ($opt_f eq 'ascii') {
- &do_groff("ascii", "| col");
- }
- elsif ($opt_f eq 'latin1') {
- &do_groff("latin1", "| col");
- }
- elsif ($opt_f eq 'koi8-r') {
- &do_groff("koi8-r", "| col");
- }
- elsif ($opt_f eq 'ps') {
- &do_groff("ps", "");
+ &gen_html();
+ }
+ }
+ elsif ($opt_f eq 'roff') {
+ &gen_roff();
+ }
+ elsif ($opt_f eq 'ascii') {
+ &do_groff("ascii", "| col");
+ }
+ elsif ($opt_f eq 'latin1') {
+ &do_groff("latin1", "| col");
+ }
+ elsif ($opt_f eq 'koi8-r') {
+ &do_groff("koi8-r", "| col");
+ }
+ elsif ($opt_f eq 'ps') {
+ &do_groff("ps", "");
+ }
+ else {
+ if ($opt_f eq "") {
+ print "An output format must be specified with the -f
+ option.\n";
}
else {
- if ($opt_f eq "") {
- print "An output format must be specified with the -f option.\n";
- }
- else {
- print "\"$opt_f\" is an unknown output format.\n";
- }
- &usage;
- exit 1;
+ print "\"$opt_f\" is an unknown output format.\n";
}
+ &usage;
+ exit 1;
}
}
OpenPOWER on IntegriCloud