From 0e224fbc119d216e53aa70c1d2c63a224d7c83d1 Mon Sep 17 00:00:00 2001 From: John Fieber Date: Fri, 17 Jan 1997 23:38:40 +0000 Subject: [PATCH] Add rudimentary docbook support: sgmlfmt -d docbook -f html myfile.docb Depreciate undocumented -white option (now default). --- usr.bin/sgmlfmt/sgmlfmt.pl | 110 +++++++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 41 deletions(-) diff --git a/usr.bin/sgmlfmt/sgmlfmt.pl b/usr.bin/sgmlfmt/sgmlfmt.pl index a38d118529b1..29500ce06bf2 100755 --- a/usr.bin/sgmlfmt/sgmlfmt.pl +++ b/usr.bin/sgmlfmt/sgmlfmt.pl @@ -41,15 +41,6 @@ require 'newgetopt.pl'; $sgmls = "sgmls"; $instant = "instant"; -# -# Locate the DTD, an SGML declaration, and the replacement files -# - -$doctype = ""; -$dtdbase = "/usr/share/sgml/FreeBSD"; -$dtd = "$dtdbase/linuxdoc.dtd"; -$decl = "$dtdbase/linuxdoc.dcl"; - # # Things to clean up if we exit abnormally # @@ -121,7 +112,7 @@ sub sgmlparse { $defines = "-i $defines"; } open($ifhandle, "$sgmls $defines $decl $file | " . - "$instant -Dfilename=$fileroot -t linuxdoc-${replacement}.ts |"); + "$instant -Dfilename=$fileroot -t ${dtd}-${replacement}.ts |"); } # @@ -209,6 +200,9 @@ $m_depth = 2; # depth of menus $sc = 0; # section counter $filecount = 0; # file counter +$doctype = ""; +$BODY = ""; + # Other variables: # # st_xxxx - Section Table. Arrays containing information about a @@ -636,6 +630,21 @@ sub navbar { } +# +# Generate html output from docbook input +# + +sub docbook_html { + $decl = "/usr/share/sgml/docbook/docbook.dcl"; + @cleanfiles = (@cleanfiles, "${fileroot}.html"); + open (outfile, ">$fileroot.html"); + &sgmlparse(infile, "html"); + while () { + print outfile; + } + close(infile); + close(outfile); +} # extlink # @@ -667,7 +676,7 @@ sub extlink { sub main { # Check arguments - if (!&NGetOpt('f=s', 'links', 'ssi', 'i:s@', 'hdr=s', 'ftr=s', 'white')) { + if (!&NGetOpt('d=s', 'f=s', 'links', 'ssi', 'i:s@', 'hdr=s', 'ftr=s')) { &usage; exit 1; } @@ -683,42 +692,61 @@ sub main { } # Generate output - if ($opt_f eq 'html') { - if ($opt_hdr) {$html_header = &gethf($opt_hdr);} - if ($opt_ftr) {$html_footer = &gethf($opt_ftr);} - if ($opt_white) {$BODY = "";} - else {$BODY = ""} - &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", ""); + if ($opt_d eq 'docbook') { + $dtd = "docbook"; + $decl = "/usr/share/sgml/docbook/docbook.dcl"; + if ($opt_f eq 'html') { + &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 { - if ($opt_f eq "") { - print "An output format must be specified with the -f option.\n"; + $dtd = "linuxdoc"; + $decl = "/usr/share/sgml/FreeBSD/linuxdoc.dcl"; + if ($opt_f eq 'html') { + 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", ""); } else { - print "\"$opt_f\" is an unknown output format.\n"; + 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; } - &usage; - exit 1; } - } &main;