From 1c1f1b6c0a9012aaf0d3b94275895cb87b5ff695 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 31 May 2000 14:27:49 +0000 Subject: This should be enough from the SGMLtools distribution to make the SGMLtools happy. The only symlink you need now is dist/birddoc -> dist/sgmltool. I'm convinced it could be avoided by renaming the directory instead, but I'd rather avoid it due to CVS pecularities. --- doc/sbase/VERSION | 1 + doc/sbase/dist/fmt_html.pl | 159 +++++++++++++++++++++++ doc/sbase/dist/fmt_latex2e.pl | 244 +++++++++++++++++++++++++++++++++++ doc/sbase/dist/fmt_txt.pl | 287 ++++++++++++++++++++++++++++++++++++++++++ doc/sbase/dtd/common | 98 +++++++++++++++ doc/sbase/dtd/isoent | 63 ++++++++++ 6 files changed, 852 insertions(+) create mode 100644 doc/sbase/VERSION create mode 100644 doc/sbase/dist/fmt_html.pl create mode 100644 doc/sbase/dist/fmt_latex2e.pl create mode 100644 doc/sbase/dist/fmt_txt.pl create mode 100644 doc/sbase/dtd/common create mode 100644 doc/sbase/dtd/isoent (limited to 'doc/sbase') diff --git a/doc/sbase/VERSION b/doc/sbase/VERSION new file mode 100644 index 0000000..66c4c22 --- /dev/null +++ b/doc/sbase/VERSION @@ -0,0 +1 @@ +1.0.9 diff --git a/doc/sbase/dist/fmt_html.pl b/doc/sbase/dist/fmt_html.pl new file mode 100644 index 0000000..f42e631 --- /dev/null +++ b/doc/sbase/dist/fmt_html.pl @@ -0,0 +1,159 @@ +# +# fmt_html.pl +# +# $Id$ +# +# HTML-specific driver stuff +# +# © Copyright 1996, Cees de Groot +# +package SGMLTools::fmt_html; +use strict; + +use SGMLTools::CharEnts; +use SGMLTools::Vars; + +use SGMLTools::FixRef; +my $fixref = $SGMLTools::FixRef::fixref; + +use SGMLTools::Html2Html; +my $html2html = $SGMLTools::Html2Html::html2html; + +my $html = {}; +$html->{NAME} = "html"; +$html->{HELP} = ""; +$html->{OPTIONS} = [ + { option => "split", type => "l", + 'values' => [ "0", "1", "2" ], short => "s" }, + { option => "dosnames", type => "f", short => "h" }, + { option => "imagebuttons", type => "f", short => "I"} +]; +$html->{'split'} = 1; +$html->{dosnames} = 0; +$html->{imagebuttons} = 0; +$html->{preNSGMLS} = sub { + $global->{NsgmlsOpts} .= " -ifmthtml "; +}; + +$Formats{$html->{NAME}} = $html; + +# HTML escape sub. this is called-back by `parse_data' below in +# `html_preASP' to properly escape `<' and `&' characters coming from +# the SGML source. +my %html_escapes; +$html_escapes{'&'} = '&'; +$html_escapes{'<'} = '<'; + +my $html_escape = sub { + my ($data) = @_; + + # replace the char with it's HTML equivalent + $data =~ s|([&<])|$html_escapes{$1}|ge; + + return ($data); +}; + +# +# Translate character entities and escape HTML special chars. +# +$html->{preASP} = sub +{ + my ($infile, $outfile) = @_; + # note the conversion of `sdata_dirs' list to an anonymous array to + # make a single argument + my $char_maps = load_char_maps ('.2html', [ Text::EntityMap::sdata_dirs() ]); + + while (<$infile>) + { + if (/^-/) + { + my ($str) = $'; + chop ($str); + print $outfile "-" . parse_data ($str, $char_maps, $html_escape) . "\n"; + } + elsif (/^A/) + { + /^A(\S+) (IMPLIED|CDATA|NOTATION|ENTITY|TOKEN)( (.*))?$/ + || die "bad attribute data: $_\n"; + my ($name,$type,$value) = ($1,$2,$4); + if ($type eq "CDATA") + { + # CDATA attributes get translated also + $value = parse_data ($value, $char_maps, $html_escape); + } + print $outfile "A$name $type $value\n"; + } + else + { + print $outfile $_; + } + } + return 0; +}; + +# +# Take the sgmlsasp output, and make something +# useful from it. +# +$html->{postASP} = sub +{ + my $infile = shift; + my $filename = $global->{filename}; + + # + # Set various stuff as a result of option processing. + # + my $ext = "html"; + $ext = "htm" if $html->{dosnames}; + my $img = 0; + $img = 1 if $html->{imagebuttons}; + + # + # Bring in file + # + my @file = <$infile>; + + # + # Find references + # + &{$fixref->{init}}($html->{'split'}); + LINE: foreach (@file) { + foreach my $pat (keys %{$fixref->{rules}}) { + if (/$pat/) { + # Call rule function then skip to next line + &{$fixref->{rules}->{$pat}}; next LINE; + } + } + &{$fixref->{defaultrule}}; + } + &{$fixref->{finish}}; + + # + # Run through html2html, preserving stdout + # Also, handle prehtml.sed's tasks + # + open SAVEOUT, ">&STDOUT"; + open STDOUT, ">$filename.$ext" or die qq(Cannot open "$filename.$ext"); + + &{$html2html->{init}}($html->{'split'}, $ext, $img, $filename, + $fixref->{filenum}, $fixref->{lrec}); + LINE: foreach (@file) { + s,

,,g; # remove empty

containers + foreach my $pat (keys %{$html2html->{rules}}) { + if (/$pat/) { + # Call rule function then skip to next line + &{$html2html->{rules}->{$pat}}; next LINE; + } + } + &{$html2html->{defaultrule}}; + } + &{$html2html->{finish}}; + + close STDOUT; + open STDOUT, ">&SAVEOUT"; + + return 0; +}; + +1; + diff --git a/doc/sbase/dist/fmt_latex2e.pl b/doc/sbase/dist/fmt_latex2e.pl new file mode 100644 index 0000000..03b07f5 --- /dev/null +++ b/doc/sbase/dist/fmt_latex2e.pl @@ -0,0 +1,244 @@ +# +# fmt_latex2e.pl +# +# $Id$ +# +# LaTeX-specific driver stuff +# +# © Copyright 1996, Cees de Groot +# +package SGMLTools::fmt_latex2e; +use strict; + +use SGMLTools::CharEnts; +use SGMLTools::Vars; +use SGMLTools::Lang; + +use File::Copy; + +my $latex2e = {}; +$latex2e->{NAME} = "latex2e"; +$latex2e->{HELP} = <{OPTIONS} = [ + { option => "output", type => "l", + 'values' => [ "dvi", "tex", "ps" ], short => "o" }, + { option => "bibtex", type => "f", short => "b" }, + { option => "makeindex", type => "f", short => "m" }, + { option => "pagenumber", type => "i", short => "n" }, + { option => "quick", type => "f", short => "q" } +]; +$latex2e->{output} = "dvi"; +$latex2e->{pagenumber} = 1; +$latex2e->{quick} = 0; +$latex2e->{bibtex} = 0; +$latex2e->{makeindex} = 0; +$latex2e->{preNSGMLS} = sub { + $global->{NsgmlsOpts} .= " -ifmttex "; +}; + +$Formats{$latex2e->{NAME}} = $latex2e; + + +# extra `\\' here for standard `nsgmls' output +my %latex2e_escapes; +$latex2e_escapes{'#'} = '\\\\#'; +$latex2e_escapes{'$'} = '\\\\$'; +$latex2e_escapes{'%'} = '\\\\%'; +$latex2e_escapes{'&'} = '\\\\&'; +$latex2e_escapes{'~'} = '\\\\~{}'; +$latex2e_escapes{'_'} = '\\\\_'; +$latex2e_escapes{'^'} = '\\\\^{}'; +$latex2e_escapes{'\\'} = '\\verb+\\+'; +$latex2e_escapes{'{'} = '\\\\{'; +$latex2e_escapes{'}'} = '\\\\}'; +$latex2e_escapes{'>'} = '{$>$}'; +$latex2e_escapes{'<'} = '{$<$}'; # wouldn't happen, but that's what'd be +$latex2e_escapes{'|'} = '{$|$}'; + +my $in_verb; + +# passed to `parse_data' below in latex2e_preASP +my $latex2e_escape = sub { + my ($data) = @_; + + if (!$in_verb) { + # escape special characters + $data =~ s|([#\$%&~_^\\{}<>\|])|$latex2e_escapes{$1}|ge; + } + + return ($data); +}; + +# +# Translate character entities and escape LaTeX special chars. +# +$latex2e->{preASP} = sub +{ + my ($infile, $outfile) = @_; + + # note the conversion of `sdata_dirs' list to an anonymous array to + # make a single argument + my $tex_char_maps = load_char_maps ('.2tex', [ Text::EntityMap::sdata_dirs() ]); + + # ASCII char maps are used in the verbatim environment because TeX + # ignores all the escapes + my $ascii_char_maps = load_char_maps ('.2ab', [ Text::EntityMap::sdata_dirs() ]); + $ascii_char_maps = load_char_maps ('.2l1b', [ Text::EntityMap::sdata_dirs() ]) if $global->{charset} eq "latin"; + + my $char_maps = $tex_char_maps; + + # used in `latex2e_escape' anonymous sub to switch between escaping + # characters from SGML source or not, depending on whether we're in + # a VERB or CODE environment or not + $in_verb = 0; + + while (<$infile>) + { + if (/^-/) + { + my ($str) = $'; + chop ($str); + print $outfile "-" . parse_data ($str, $char_maps, $latex2e_escape) . "\n"; + } + elsif (/^A/) + { + /^A(\S+) (IMPLIED|CDATA|NOTATION|ENTITY|TOKEN)( (.*))?$/ + || die "bad attribute data: $_\n"; + my ($name,$type,$value) = ($1,$2,$4); + if ($type eq "CDATA") + { + # CDATA attributes get translated also + if ($name eq "URL" or $name eq "ID") + { + # URL for url.sty is a kind of verbatim... + my $old_verb = $in_verb; + $in_verb = 1; + $value = parse_data ($value, $ascii_char_maps, + $latex2e_escape); + $in_verb = $old_verb; + } + else + { + $value = parse_data ($value, $char_maps, $latex2e_escape); + } + } + print $outfile "A$name $type $value\n"; + } + elsif (/^\((VERB|CODE)/) + { + print $outfile $_; + # going into VERB/CODE section + $in_verb = 1; + $char_maps = $ascii_char_maps; + } + elsif (/^\)(VERB|CODE)/) + { + print $outfile $_; + # leaving VERB/CODE section + $in_verb = 0; + $char_maps = $tex_char_maps; + } + else + { + print $outfile $_; + } + } +}; + +# +# Take the sgmlsasp output, and make something +# useful from it. +# +$latex2e->{postASP} = sub +{ + my $infile = shift; + my $filename = $global->{filename}; + $ENV{TEXINPUTS} .= ":$main::LibDir"; + + # + # Set the correct \documentclass options. The if statement is just + # a small optimization. + # + if ($global->{language} ne "en" || + $global->{papersize} ne "a4" || + $latex2e->{pagenumber} != 1 || + $global->{pass} ne "" || + $latex2e->{makeindex}) + { + my $langlit = ISO2English ($global->{language}); + $langlit = ($langlit eq 'english') ? "" : ",$langlit"; + my $replace = $global->{papersize} . 'paper' . $langlit; + open OUTFILE, ">$filename.tex"; + while (<$infile>) + { + if (/^\\documentclass/) + { + s/\\documentclass\[.*\]/\\documentclass\[$replace\]/; + $_ = $_ . "\\makeindex\n" if ($latex2e->{makeindex}); + } + if (/%end-preamble/) + { + if ($latex2e->{pagenumber}) + { + $_ = $_ . '\setcounter{page}{'. + $latex2e->{pagenumber} . "}\n"; + } + else + { + $_ = $_ . "\\pagestyle{empty}\n"; + } + $_ = $_ . $global->{pass} . "\n" if ($global->{pass}); + } + print OUTFILE; + } + close OUTFILE; + } + else + { + copy ($infile, "$filename.tex"); + } + + # + # LaTeX, dvips, and assorted cleanups. + # + if ($latex2e->{output} eq "tex") + { + return 0; + } + + # + # Run LaTeX in nonstop mode so it won't prompt & hang on errors. + # Suppress the output of LaTeX on all but the last pass, after + # references have been resolved. This avoids large numbers of + # spurious warnings. + # + my ($latexcommand) = "latex '\\nonstopmode\\input{$filename.tex}'"; + my ($suppress) = $latex2e->{quick} ? "" : ' >/dev/null'; + + system $latexcommand . $suppress || die "LaTeX problem\n"; + $latex2e->{bibtex} && system "bibtex $filename.tex"; + $latex2e->{quick} || system $latexcommand . ' >/dev/null'; + $latex2e->{quick} || system $latexcommand; + if ($global->{debug} == 0) + { + my @suffixes = qw(log blg aux toc lof lot dlog bbl); + for my $suf (@suffixes) + { + unlink "$filename.$suf"; + } + } + if ($latex2e->{output} eq "dvi") + { + $global->{debug} || unlink "$filename.tex"; + return 0; + } + `dvips -q -t $global->{papersize} -o $filename.ps $filename.dvi`; + $global->{debug} || unlink ("$filename.dvi", "$filename.tex"); + + return 0; +}; + +1; diff --git a/doc/sbase/dist/fmt_txt.pl b/doc/sbase/dist/fmt_txt.pl new file mode 100644 index 0000000..81c2b15 --- /dev/null +++ b/doc/sbase/dist/fmt_txt.pl @@ -0,0 +1,287 @@ +# +# fmt_txt.pl +# +# $Id$ +# +# TXT-specific driver stuff +# +# © Copyright 1996, Cees de Groot +# +package SGMLTools::fmt_txt; +use strict; + +use File::Copy; +use Text::EntityMap; +use SGMLTools::CharEnts; +use SGMLTools::Lang; +use SGMLTools::Vars; + +my $txt = {}; +$txt->{NAME} = "txt"; +$txt->{HELP} = ""; +$txt->{OPTIONS} = [ + { option => "manpage", type => "f", short => "m" }, + { option => "filter", type => "f", short => "f" } +]; +$txt->{manpage} = 0; +$txt->{filter} = 0; + +$Formats{$txt->{NAME}} = $txt; + +# +# Set correct NsgmlsOpts +# +$txt->{preNSGMLS} = sub +{ + if ($txt->{manpage}) + { + $global->{NsgmlsOpts} .= " -iman "; + $global->{charset} = "man"; + } + else + { + $global->{NsgmlsOpts} .= " -ifmttxt "; + $global->{charset} = "latin1" if $global->{charset} eq "latin"; + } + + # + # Is there a cleaner solution than this? Can't do it earlier, + # would show up in the help messages... + # + $global->{format} = $global->{charset}; + $global->{format} = "groff" if $global->{format} eq "ascii"; + $ENV{SGML_SEARCH_PATH} =~ s/txt/$global->{format}/; + + $Formats{"groff"} = $txt; + $Formats{"latin1"} = $txt; + $Formats{"man"} = $txt; + + return 0; +}; + + +# Ascii escape sub. this is called-back by `parse_data' below in +# `txt_preASP' to properly escape `\' characters coming from the SGML +# source. +my $txt_escape = sub { + my ($data) = @_; + + $data =~ s|"|\\\&\"|g; # Insert zero-width space in front of " + $data =~ s|^\.|\\&.|; # ditto in front of . at start of line + $data =~ s|\\|\\\\|g; # Escape backslashes + + return ($data); +}; + +# +# Run the file through the genertoc utility before sgmlsasp. Not necessary +# when producing a manpage. A lot of code from FJM, untested by me. +# +$txt->{preASP} = sub +{ + my ($infile, $outfile) = @_; + my (@toc, @lines); + if ($txt->{manpage}) + { + copy ($infile, $outfile); + return; + } + + # note the conversion of `sdata_dirs' list to an anonymous array to + # make a single argument + my $char_maps = load_char_maps ('.2tr', [ Text::EntityMap::sdata_dirs() ]); + $char_maps = load_char_maps ('.2l1tr', [ Text::EntityMap::sdata_dirs() ]) if $global->{charset} eq "latin1"; + + # + # Build TOC. The file is read into @lines in the meantime, we need to + # traverse it twice. + # + push (@toc, "(HLINE\n"); + push (@toc, ")HLINE\n"); + push (@toc, "(P\n"); + push (@toc, "-" . Xlat ("Table of Contents") . "\n"); + push (@toc, ")P\n"); + push (@toc, "(VERB\n"); + my (@prevheader, @header); + while (<$infile>) + { + push (@lines, $_); + + if (/^\(SECT(.*)/) + { + @prevheader = @header; + @header = @header[0..$1]; + $header[$1]++; + } + if (/^\(HEADING/) + { + $_ = <$infile>; + push (@lines, $_); + chop; + s/^-//; + $_ = join(".",@header) . " " . $_; + s/\\n/ /g; + s/\(\\[0-9][0-9][0-9]\)/\\\1/g; + + if (!$#header) + { + # put a newline before top-level sections unless previous was also + # a top level section + $_ = "\\n" . $_ unless (!$#prevheader); + # put a . and a space after top level sections + s/ /. /; + $_ = "-" . $_ . "\\n"; + } + else + { + # subsections get indentation matching hierarchy + $_ = "-" . " " x $#header . $_; + } + push(@toc, parse_data ($_, $char_maps, $txt_escape), "\\n\n"); + } + } + push (@toc, ")VERB\n"); + push (@toc, "(HLINE\n"); + push (@toc, ")HLINE\n"); + + my $inheading = 0; + my $tipo = ''; + for (@lines) + { + if ($inheading) + { + next if (/^\)TT/ || /^\(TT/ || /^\)IT/ || /^\(IT/ || + /^\)EM/ || /^\(EM/ || /^\)BF/ || /^\(BF/); + if (/^-/) + { + $tipo .= $' ; + chop ($tipo); + $tipo .= " " unless $tipo =~ / $/; + } + else + { + $tipo =~ s/ $//; + if ($tipo) + { + print $outfile "-" + . parse_data ($tipo, $char_maps, $txt_escape) + . "\n"; + } + print $outfile $_; + $tipo = ''; + } + if (/^\)HEADING/) + { + $inheading = 0; + } + next; + } + if (/^\(HEADING/) + { + # + # Go into heading processing mode. + # + $tipo = ''; + $inheading = 1; + } + if (/^\(TOC/) + { + print $outfile @toc; + next; + } + if (/^-/) + { + my ($str) = $'; + chop ($str); + print $outfile "-" . parse_data ($str, $char_maps, $txt_escape) . "\n"; + next; + } + elsif (/^A/) + { + /^A(\S+) (IMPLIED|CDATA|NOTATION|ENTITY|TOKEN)( (.*))?$/ + || die "bad attribute data: $_\n"; + my ($name,$type,$value) = ($1,$2,$4); + if ($type eq "CDATA") + { + # CDATA attributes get translated also + $value = parse_data ($value, $char_maps, $txt_escape); + } + print $outfile "A$name $type $value\n"; + next; + } + + # + # Default action if not skipped over with next: copy in to out. + # + print $outfile $_; + } +}; + + +# +# Take the sgmlsasp output, and make something +# useful from it. +# +$txt->{postASP} = sub +{ + my $infile = shift; + my ($outfile, $groffout); + + if ($txt->{manpage}) + { + $outfile = new FileHandle ">$global->{filename}.man"; + } + else + { + $outfile = new FileHandle + "|$main::progs->{GROFF} -T $global->{pass} $global->{charset} -t $main::progs->{GROFFMACRO} >$global->{tmpbase}.txt.1"; + } + + # + # Feed $outfile with roff input. + # + while (<$infile>) + { + unless (/^\.DS/.../^\.DE/) + { + s/^[ \t]{1,}(.*)/$1/g; + } + s/^\.[ \t].*/\\\&$&/g; + s/\\fC/\\fR/g; + s/^.ft C/.ft R/g; + print $outfile $_; + } + $outfile->close; + + # + # If we were making a manpage, we're done. Otherwise, a little bit + # of work is left. + # + if ($txt->{manpage}) + { + return 0; + } + else + { + $outfile->open (">$global->{filename}.txt"); + $groffout = new FileHandle "<$global->{tmpbase}.txt.1"; + if ($txt->{filter}) + { + while (<$groffout>) + { + s/.//g; + print $outfile $_; + } + } + else + { + copy ($groffout, $outfile); + } + } + $groffout->close; + $outfile->close; + + return 0; +}; + +1; diff --git a/doc/sbase/dtd/common b/doc/sbase/dtd/common new file mode 100644 index 0000000..4476d84 --- /dev/null +++ b/doc/sbase/dtd/common @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/doc/sbase/dtd/isoent b/doc/sbase/dtd/isoent new file mode 100644 index 0000000..acec982 --- /dev/null +++ b/doc/sbase/dtd/isoent @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + +%ISOdia; + + +%ISOgrk3; + + +%ISOlat1; + + +%ISOnum; + + +%ISOpub; + + + + + + + \ No newline at end of file -- cgit v1.2.3