diff options
author | jfieber <jfieber@FreeBSD.org> | 1995-10-07 22:28:34 +0000 |
---|---|---|
committer | jfieber <jfieber@FreeBSD.org> | 1995-10-07 22:28:34 +0000 |
commit | 0c3cb055b39aeb7a0a820da80ca811aa663a3cf6 (patch) | |
tree | d34e1160a7d256520e12a989bd38c783795ff769 /usr.bin/sgmlfmt | |
parent | 31dfaff8254e9ea72dd7fd16d012f4d5db655d18 (diff) | |
download | FreeBSD-src-0c3cb055b39aeb7a0a820da80ca811aa663a3cf6.zip FreeBSD-src-0c3cb055b39aeb7a0a820da80ca811aa663a3cf6.tar.gz |
This is now perl5 friendly.
Make server side include hooks for headers and footers controlled
by a command line switch and document the feature.
Diffstat (limited to 'usr.bin/sgmlfmt')
-rw-r--r-- | usr.bin/sgmlfmt/sgmlfmt.1 | 79 | ||||
-rwxr-xr-x | usr.bin/sgmlfmt/sgmlfmt.pl | 101 |
2 files changed, 101 insertions, 79 deletions
diff --git a/usr.bin/sgmlfmt/sgmlfmt.1 b/usr.bin/sgmlfmt/sgmlfmt.1 index 4c55eac..1b18008 100644 --- a/usr.bin/sgmlfmt/sgmlfmt.1 +++ b/usr.bin/sgmlfmt/sgmlfmt.1 @@ -1,5 +1,5 @@ -.Dd August 30, 1995 -.Os FreeBSD 2.0.5 +.Dd October 7, 1995 +.Os FreeBSD 2.1 .Dt SGMLFMT 1 .Sh NAME .Nm sgmlfmt @@ -8,6 +8,7 @@ .Nm .Fl f Ar format .Op Fl links +.Op Fl ssi .Op Fl i Ar name ... .Ar file .Sh DESCRIPTION @@ -63,25 +64,6 @@ This is actually an intermediate conversion used by the .Fl f Ar ascii format option. .El -.It Fl links -When used with the -.Fl f Ar html -option, for each -.Li <label id="foo"> -in the document source -.Nm -generates a symbolic link -.Pa foo.html -pointing to the numbered -.Pa .html -file containing the reference. Since the number of the file -containing a particular section can change when a document -is modified, this provides a convenient hook by which separate -documents can provide links into another document without the -links becoming invalid when the target document is modified. -When creating a symbolic link, any occurence of a slash (/) in label -is replaced with percent (%), while any occurence of a space is replaced -with an underscore (_). .It Fl i Ar name Pretend that .Dl <!ENTITY % name "INCLUDE"> @@ -101,6 +83,43 @@ and will use in the status keyword specification of a marked section declaration. In this case the effect of the option will be to cause the marked section not to be ignored. +.It Fl links +When used with the +.Fl f Ar html +option, for each +.Li <label id="foo"> +in the document source +.Nm +generates a symbolic link +.Pa foo.html +pointing to the numbered +.Pa .html +file containing the reference. Since the number of the file +containing a particular section can change when a document +is modified, this provides a convenient hook by which separate +documents can provide links into another document without the +links becoming invalid when the target document is modified. +When creating a symbolic link, any occurence of a slash (/) in label +is replaced with percent (%), while any occurence of a space is replaced +with an underscore (_). +.It Fl ssi +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 . .El .Pp If the input file name ends with @@ -138,9 +157,8 @@ The linuxdoc DTD was written by Matt Welsh and based on the Qwertz DTD written by Tom Gordon .Aq thomas.gordon@gmd.de . .Sh BUGS -The ASCII output has many, many bugs including no table of -contents, no meaningful cross references, and numerous formatting -errors. +The ASCII output has many, many bugs including no meaningful +cross references, and numerous formatting problems. .Pp A line in the SGML source file beginning with a period (.) will confuse @@ -157,8 +175,11 @@ the .Li </heading> tags are omitted following a sectioning tag such as -.Li <sect> . Furthermore, all text between -.Li <heading> -and -.Li </heading> -must be on one line. +.Li <sect> . +.Pp +Beginning and ending tags for the +.Li <tag> +element must occur on the same line for correct formatting with +the +.Fl ascii +option. diff --git a/usr.bin/sgmlfmt/sgmlfmt.pl b/usr.bin/sgmlfmt/sgmlfmt.pl index 36d3245..30db8a6 100755 --- a/usr.bin/sgmlfmt/sgmlfmt.pl +++ b/usr.bin/sgmlfmt/sgmlfmt.pl @@ -1,23 +1,10 @@ #!/usr/bin/perl -# $Id: sgmlfmt.pl,v 1.6 1995/08/31 00:14:02 jfieber Exp $ +# $Id: sgmlfmt.pl,v 1.7 1995/09/22 18:24:32 jfieber Exp $ # Format an sgml document tagged according to the linuxdoc DTD. # by John Fieber <jfieber@freebsd.org> for the FreeBSD documentation # project. # -# Usage: sgmlformat -format [-format ...] [-links] inputfile [inputfile ...] -# -# -format outputfile format -# ------------------------------------------------------------- -# -html inputfile.html HTML -# -txt | -ascii inputfile.ascii ascii text -# -tex | -latex inputfile.tex LaTeX -# -nroff inputfile.nroff groff for ms macros -# -ps inputfile.ps postscript -# -# -links For each <label id="foo">, make a symbolic -# link foo.html -> inputfile-n.html. -# # Bugs: # # Text lines that start with a period (.) confuse the conversions that @@ -27,6 +14,8 @@ # Although legal by the DTD, it the ascii formatting gets botched if # the <heading></heading> tags are omitted following a <sect?>. # +# Beginning and end tags for the <tag> element must occur on the same line. +# # The whole approach of using sgmlsasp and passing a few things # through for processing by this script is doomed. This whole thing # needs to be re-thought and a better DTD should be used anyway. @@ -71,7 +60,7 @@ if (! $ENV{"SGML_PATH"}) { sub usage { print "Usage:\n"; - print "sgmlfmt -f <format> [-i <namea> [-i <nameb> ...]] [-links] filename[.sgml]\n"; + print "sgmlfmt -f <format> [-i <namea> ...] [-links] [-ssi] file\n"; print "where <format> is one of: html, latex, ascii, nroff\n"; } # @@ -247,7 +236,7 @@ sub gen_html { print bar; # count up the number of files to be generated # and gather assorted info about the document structure - if (/^<@@sect>/) { + if (/^<\@\@sect>/) { $sl++; # current section level $sc++; # current section number $st_sl[$sc] = $sl; @@ -289,21 +278,21 @@ sub gen_html { $st_pl[$sc] = $maxlevel; } } - if (/^<@@endsect>/) { + if (/^<\@\@endsect>/) { $sl--; } # record section titles - if (/^<@@head>/) { + if (/^<\@\@head>/) { chop; - s/^<@@head>//; + s/^<\@\@head>//; $st_header[$sc] = $_; } # record the section number that a label occurs in - if (/^<@@label>/) { + if (/^<\@\@label>/) { chop; - s/^<@@label>//; + s/^<\@\@label>//; if ($references{$_} eq "") { $references{$_} = "$filecount"; if ($opt_links) { @@ -353,27 +342,35 @@ sub html2html { tagsw: { # titles and headings - if (s/^<@@title>//) { + if (s/^<\@\@title>//) { chop; $st_header[0] = $_; $st_parent[0] = -1; print tocfile "<HEAD>\n<TITLE>$st_header[0]</TITLE>\n</HEAD>\n"; print tocfile "<H1>$st_header[0]</H1>\n"; + $header[$st_ol[$sc]] = "<HTML>\n<HEAD>\n<TITLE>$st_header[0]</TITLE>\n" . - "</HEAD>\n<BODY>\n" . - "<!--#include virtual=\"./$fileroot.hdr\" -->" . - "\n<H1>$st_header[0]</H1>\n"; - $footer[$st_ol[$sc]] = - "\n<!--#include virtual=\"./$fileroot.ftr\" -->" . - "\n</BODY>\n</HTML>\n"; + "</HEAD>\n<BODY>\n"; + 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"; + 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; } # # HEADER begin # - if (s/^<@@head>//) { + if (s/^<\@\@head>//) { chop; if ($part == 1) { @@ -386,14 +383,18 @@ sub html2html { # set up headers and footers if ($st_sl[$sc] > 0 && $st_sl[$sc] <= $maxlevel) { $header[$st_ol[$sc]] = - "<HTML>\n<HEAD>\n<TITLE>$_</TITLE>\n</HEAD>\n" . - "<BODY>\n" . - "<!--#include virtual=\"./$fileroot.hdr$st_ol[$sc]\" -->" . - "\n$navbar[$st_ol[$sc]]\n<HR>\n"; - $footer[$st_ol[$sc]] = - "<HR>\n$navbar[$st_ol[$sc]]\n" . - "<!--#include virtual=\"./$fileroot.ftr$st_ol[$sc]\" -->" . - "\n</BODY>\n</HTML>"; + "<HTML>\n<HEAD>\n<TITLE>$_</TITLE>\n</HEAD>\n<BODY>\n"; + 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>\n"; + $footer[$st_ol[$sc]] = "<HR>\n$navbar[$st_ol[$sc]]\n"; + 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>"; } # Add this to the master table of contents @@ -429,7 +430,7 @@ sub html2html { # # HEADER end # - if (s/^<@@endhead>//) { + if (s/^<\@\@endhead>//) { if ($part == 1) { $text[0] .= "</H1>\n"; $part = 0; @@ -457,7 +458,7 @@ sub html2html { } # sectioning - if (s/^<@@part>//) { + if (s/^<\@\@part>//) { $part = 1; $partnum++; last tagsw; @@ -466,7 +467,7 @@ sub html2html { # # BEGINNING of a section # - if (s/^<@@sect>//) { + if (s/^<\@\@sect>//) { # Increment the section counter and save it on a stack # for future reference. $sc++; @@ -492,7 +493,7 @@ sub html2html { # # END of a section # - if (s/^<@@endsect>//) { + if (s/^<\@\@endsect>//) { # Remember the section number! Subsections may have # altered the global $sc variable. @@ -520,12 +521,12 @@ sub html2html { } # cross references - if (s/^<@@label>//) { + if (s/^<\@\@label>//) { chop; $text[$st_ol[$sc]] .= "<A NAME=\"$_\"></A>"; last tagsw; } - if (s/^<@@ref>//) { + if (s/^<\@\@ref>//) { chop; $refname = $_; if ($references{$_} eq "") { @@ -537,26 +538,26 @@ sub html2html { } last tagsw; } - if (s/^<@@endref>//) { + if (s/^<\@\@endref>//) { # $text[$st_ol[$sc]] .= "</A>"; last tagsw; } - if (s/^<@@refnam>//) { + if (s/^<\@\@refnam>//) { $text[$st_ol[$sc]] .= "$refname</A>"; last tagsw; } # URLs - if (s/^<@@url>//) { + if (s/^<\@\@url>//) { chop; $urlname = $_; $text[$st_ol[$sc]] .= "<A HREF=\"$urlname\">"; last tagsw; } - if (s/^<@@urlnam>//) { + if (s/^<\@\@urlnam>//) { $text[$st_ol[$sc]] .= "$urlname</A>"; last tagsw; } - if (s/^<@@endurl>//) { + if (s/^<\@\@endurl>//) { # $text[$st_ol[$sc]] .= "</A>"; last tagsw; } @@ -590,7 +591,7 @@ sub navbar { "<A HREF=\"${fileroot}.html\"><EM>$st_header[0]</EM></A>\n"; $i = $st_parent[$sc]; while ($i > 0) { - $itext = " : <A HREF=\"${fileroot}$st_file[$i].html\"><EM>$st_header[$i]</EM></A>\n$itext"; + $itext = " $colon <A HREF=\"${fileroot}$st_file[$i].html\"><EM>$st_header[$i]</EM></A>\n$itext"; $i = $st_parent[$i]; } $navbar[$st_ol[$sc]] .= "$itext $colon <EM>$st_header[$sc]</EM><BR>\n"; @@ -667,7 +668,7 @@ sub extlink { sub main { # Check arguments - if (!&NGetOpt('f=s', 'links', 'i:s@')) { + if (!&NGetOpt('f=s', 'links', 'ssi', 'i:s@')) { &usage; exit 1; } |