mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-01 00:18:15 +01:00
Command line arguments are now gathered by NewGetOpt. Command line
syntax is slightly changed: -format is now -f format. New option: -i name This is a switch to control marked sections in SGML documents. Useful for multi-lingual documents.
This commit is contained in:
parent
b247e376cd
commit
d8c5d59031
@ -1,4 +1,4 @@
|
||||
.Dd August 28, 1995
|
||||
.Dd August 30, 1995
|
||||
.Os FreeBSD 2.0.5
|
||||
.Dt SGMLFMT 1
|
||||
.Sh NAME
|
||||
@ -6,9 +6,10 @@
|
||||
.Nd Formats SGML files tagged according to the linuxdoc DTD.
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Fl Ar format Op Fl Ar format...
|
||||
.Op Fl Ar links
|
||||
.Ar
|
||||
.Fl f Ar format
|
||||
.Op Fl links
|
||||
.Op Fl i Ar name ...
|
||||
.Ar file
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
@ -21,12 +22,14 @@ declaration before any uncommented text:
|
||||
.Bd -literal -offset indent
|
||||
<!DOCTYPE linuxdoc PUBLIC "-//FreeBSD//DTD linuxdoc//EN">
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
.Fl Ar format
|
||||
options for output include the following:
|
||||
.Pp Options for
|
||||
.Nm
|
||||
include the following:
|
||||
.Bl -tag -width Ds
|
||||
.It Fl html
|
||||
.It Fl f Ar format
|
||||
Determines the output format which can be one of the following:
|
||||
.Bl -tag -width Ds
|
||||
.It Ar html
|
||||
Generates a set of linked HTML files suitable for use with an
|
||||
HTML browser. A top level file,
|
||||
.Pa file.html ,
|
||||
@ -38,18 +41,18 @@ contains a complete table of contents. A series of files named
|
||||
.Pa file2.html ...
|
||||
.Pa filen.html
|
||||
contain the actual text of the document.
|
||||
.It Fl latex
|
||||
.It Ar latex
|
||||
Generates a single output file with the extension
|
||||
.Pa .tex
|
||||
suitable for processing with LaTeX. Note that the LaTeX style
|
||||
file
|
||||
.Pa /usr/share/sgml/FreeBSD/lib/linuxdoc.sty
|
||||
must be accessible to LaTeX for correct processing.
|
||||
.It Fl ascii
|
||||
.It Ar ascii
|
||||
Generates a single output file with the extension
|
||||
.Pa .ascii
|
||||
suitable for viewing on an ASCII terminal.
|
||||
.It Fl nroff
|
||||
.It Ar nroff
|
||||
Generates a single output file with the extension
|
||||
.Pa .nroff
|
||||
suitable processing with
|
||||
@ -57,12 +60,15 @@ suitable processing with
|
||||
or
|
||||
.Xr groff 1 .
|
||||
This is actually an intermediate conversion used by the
|
||||
.Fl ascii
|
||||
.Fl f Ar ascii
|
||||
format option.
|
||||
.El
|
||||
.It Fl links
|
||||
When used with the
|
||||
.Fl html
|
||||
option, for each <label id="foo"> in the document source
|
||||
.Fl f Ar html
|
||||
option, for each
|
||||
.Li <label id="foo">
|
||||
in the document source
|
||||
.Nm
|
||||
generates a symbolic link
|
||||
.Pa foo.html
|
||||
@ -76,6 +82,25 @@ 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">
|
||||
occurs at the start of the document type declaration subset in
|
||||
the document entity. Since repeated definitions of an entity are
|
||||
ignored, this definition will take precedence over any other
|
||||
definitions of this entity in the document type declaration.
|
||||
Multiple
|
||||
.Fl i
|
||||
options are allowed. If the declaration replaces the reserved
|
||||
name INCLUDE then the new reserved name will be the replacement
|
||||
text of the entity. Typically the document type declaration will
|
||||
contain
|
||||
.Dl <!ENTITY % name "IGNORE">
|
||||
and will use
|
||||
.Li %name;
|
||||
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.
|
||||
.El
|
||||
.Pp
|
||||
If the input file name ends with
|
||||
@ -126,6 +151,14 @@ The divison of the sources file into separate HTML files is
|
||||
currently fixed.
|
||||
.Pp
|
||||
Although legal according to the DTD, it the ascii formatting gets botched if
|
||||
the <heading>...</heading> tags are omitted following a
|
||||
sectioning tag such as <sect>. Furthermore, all text between
|
||||
<heading> and </heading> must be on one line.
|
||||
the
|
||||
.Li <heading>
|
||||
.No ...
|
||||
.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.
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/perl
|
||||
# $Id: sgmlfmt.pl,v 1.4 1995/08/25 23:26:49 jfieber Exp $
|
||||
# $Id: sgmlfmt.pl,v 1.5 1995/08/29 01:02:12 jfieber Exp $
|
||||
|
||||
# Format an sgml document tagged according to the linuxdoc DTD.
|
||||
# by John Fieber <jfieber@freebsd.org> for the FreeBSD documentation
|
||||
@ -36,6 +36,8 @@
|
||||
# Look in a couple places for the SGML DTD and replacement files
|
||||
#
|
||||
|
||||
require 'newgetopt.pl';
|
||||
|
||||
if (-d "$ENV{'HOME'}/lib/sgml/FreeBSD") {
|
||||
$sgmldir = "$ENV{'HOME'}/lib/sgml";
|
||||
}
|
||||
@ -67,6 +69,11 @@ if (! $ENV{"SGML_PATH"}) {
|
||||
$ENV{"SGML_PATH"} = "$sgmldir/%O/%C/%T";
|
||||
}
|
||||
|
||||
sub usage {
|
||||
print "Usage:\n";
|
||||
print "sgmlfmt -f <format> [-i <namea> [-i <nameb> ...]] [-links] filename[.sgml]\n";
|
||||
print "where <format> is one of: html, latex, ascii, nroff\n";
|
||||
}
|
||||
#
|
||||
# Look for the file specified on the command line
|
||||
#
|
||||
@ -106,8 +113,12 @@ sub getfile {
|
||||
|
||||
sub sgmlparse {
|
||||
local($fhandle, $replacement) = @_;
|
||||
$defines = join(" -i ", @opt_i);
|
||||
if ($defines ne "") {
|
||||
$defines = "-i $defines";
|
||||
}
|
||||
$ENV{'SGML_PATH'} = "$replbase/$replacement.%N:$ENV{'SGML_PATH'}";
|
||||
open($fhandle, "sgmls $decl $file | sgmlsasp $replbase/$replacement.mapping |");
|
||||
open($fhandle, "sgmls $defines $decl $file | sgmlsasp $replbase/$replacement.mapping |");
|
||||
}
|
||||
|
||||
#
|
||||
@ -295,7 +306,7 @@ sub gen_html {
|
||||
s/^<@@label>//;
|
||||
if ($references{$_} eq "") {
|
||||
$references{$_} = "$filecount";
|
||||
if ($genlinks) {
|
||||
if ($opt_links) {
|
||||
&extlink($_, "${fileroot}${filecount}.html");
|
||||
}
|
||||
}
|
||||
@ -644,43 +655,57 @@ sub extlink {
|
||||
|
||||
# Now, read the command line and take appropriate action
|
||||
|
||||
$fcount = 0;
|
||||
for (@ARGV) {
|
||||
if (/^-.*/) {
|
||||
s/^-//;
|
||||
$gen{$_} = 1;
|
||||
sub main {
|
||||
# Check arguments
|
||||
if (!&NGetOpt('f=s', 'links', 'i:s@')) {
|
||||
&usage;
|
||||
exit 1;
|
||||
}
|
||||
if (@ARGV == 0) {
|
||||
print "An input file must be specified.\n";
|
||||
&usage;
|
||||
exit 1;
|
||||
}
|
||||
if (&getfile($ARGV[0]) == 0) {
|
||||
print "Cannot locate specified file: $ARGV[0]\n";
|
||||
&usage;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Generate output
|
||||
if ($opt_f eq 'html') {
|
||||
print "generating $fileroot.html";
|
||||
if ($opt_links == 1) {
|
||||
print " with external links";
|
||||
}
|
||||
print "...\n"; &gen_html();
|
||||
}
|
||||
elsif ($opt_f eq 'tex' || $opt_f eq 'latex') {
|
||||
print "generating $fileroot.tex...\n"; &gen_latex();
|
||||
}
|
||||
elsif ($opt_f eq 'nroff') {
|
||||
print "generating $fileroot.nroff...\n"; &gen_nroff();
|
||||
}
|
||||
elsif ($opt_f eq 'ascii') {
|
||||
print "generating $fileroot.ascii...\n"; &gen_ascii();
|
||||
}
|
||||
elsif ($opt_f eq 'ps') {
|
||||
print "generating $fileroot.ps...\n"; &gen_ps();
|
||||
}
|
||||
else {
|
||||
@infiles[$fcount] = $_;
|
||||
$fcount++;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $fcount; $i++) {
|
||||
if (&getfile($infiles[$i])) {
|
||||
if ($gen{'html'}) {
|
||||
print "generating $fileroot.html";
|
||||
if ($gen{'links'}) {
|
||||
$genlinks = 1;
|
||||
print " with external links";
|
||||
}
|
||||
else {
|
||||
$genlinks = 0;
|
||||
}
|
||||
print "...\n"; &gen_html(); }
|
||||
if ($gen{'tex'} || $gen{'latex'}) {
|
||||
print "generating $fileroot.tex...\n"; &gen_latex(); }
|
||||
if ($gen{'nroff'}) {
|
||||
print "generating $fileroot.nroff...\n"; &gen_nroff(); }
|
||||
if ($gen{'txt'} || $gen{'ascii'}) {
|
||||
print "generating $fileroot.ascii...\n"; &gen_ascii(); }
|
||||
if ($gen{'ps'}) {
|
||||
print "generating $fileroot.ps...\n"; &gen_ps(); }
|
||||
}
|
||||
else {
|
||||
print "Input file $infiles[$i] not found\n";
|
||||
}
|
||||
}
|
||||
&main;
|
||||
|
||||
exit 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user