Commit 9c763123 authored by Martin Mareš's avatar Martin Mareš

Updated the documentation building tools to work with a recent linuxdoc-tools package.

Note that this is (and always was) a terrible hack and we really should
replace it with something reasonable which wouldn't need changing every
time linuxdoc-tools evolve.

I also needed to include a patched version of LinuxDocTools.pm, because the
original one explicitly refused to work with a non-linuxdoc DTD. The authors
of linuxdoc recommend to use sgmltools-lite in such cases, but it would mean
rewritting our formatting rules to the DSSSL language which I don't dare to
speak about here :)
parent a9aa5887
This diff is collapsed.
......@@ -7,17 +7,17 @@
#
# Copyright 1996, Cees de Groot
#
package SGMLTools::fmt_html;
package LinuxDocTools::fmt_html;
use strict;
use SGMLTools::CharEnts;
use SGMLTools::Vars;
use LinuxDocTools::CharEnts;
use LinuxDocTools::Vars;
use SGMLTools::FixRef;
my $fixref = $SGMLTools::FixRef::fixref;
use LinuxDocTools::FixRef;
my $fixref = $LinuxDocTools::FixRef::fixref;
use SGMLTools::Html2Html;
my $html2html = $SGMLTools::Html2Html::html2html;
use LinuxDocTools::Html2Html;
my $html2html = $LinuxDocTools::Html2Html::html2html;
my $html = {};
$html->{NAME} = "html";
......@@ -25,14 +25,22 @@ $html->{HELP} = "";
$html->{OPTIONS} = [
{ option => "split", type => "l",
'values' => [ "0", "1", "2" ], short => "s" },
{ option => "toc", type => "l",
'values' => [ "0", "1", "2" ], short => "T" },
{ option => "dosnames", type => "f", short => "h" },
{ option => "imagebuttons", type => "f", short => "I"}
{ option => "imagebuttons", type => "f", short => "I"},
{ option => "header", type => "s", short => "H"},
{ option => "footer", type => "s", short => "F"}
];
$html->{'split'} = 1;
$html->{'toc'} = -1;
$html->{dosnames} = 0;
$html->{imagebuttons} = 0;
$html->{header} = "";
$html->{footer} = "";
$html->{preNSGMLS} = sub {
$global->{NsgmlsOpts} .= " -ifmthtml ";
$global->{NsgmlsPrePipe} = "cat $global->{file}";
};
$Formats{$html->{NAME}} = $html;
......@@ -132,11 +140,15 @@ $html->{postASP} = sub
# Run through html2html, preserving stdout
# Also, handle prehtml.sed's tasks
#
my $filter = "";
# $filter = "|$main::progs->{NKF} -e" if ($global->{language} eq "ja");
open SAVEOUT, ">&STDOUT";
open STDOUT, ">$filename.$ext" or die qq(Cannot open "$filename.$ext");
open STDOUT, "$filter>$filename.$ext" or die qq(Cannot open "$filename.$ext");
&{$html2html->{init}}($html->{'split'}, $ext, $img, $filename,
$fixref->{filenum}, $fixref->{lrec});
$fixref->{filenum}, $fixref->{lrec},
$html->{'header'}, $html->{'footer'}, $html->{'toc'},
$global->{tmpbase}, $global->{debug});
LINE: foreach (@file) {
s,<P></P>,,g; # remove empty <P></P> containers
foreach my $pat (keys %{$html2html->{rules}}) {
......
This diff is collapsed.
......@@ -7,24 +7,27 @@
#
# Copyright 1996, Cees de Groot
#
package SGMLTools::fmt_txt;
package LinuxDocTools::fmt_txt;
use strict;
use File::Copy;
use Text::EntityMap;
use SGMLTools::CharEnts;
use SGMLTools::Lang;
use SGMLTools::Vars;
use LinuxDocTools::CharEnts;
use LinuxDocTools::Lang;
use LinuxDocTools::Vars;
use LinuxDocTools::Utils qw(create_temp);
my $txt = {};
$txt->{NAME} = "txt";
$txt->{HELP} = "";
$txt->{OPTIONS} = [
{ option => "manpage", type => "f", short => "m" },
{ option => "filter", type => "f", short => "f" }
{ option => "filter", type => "f", short => "f" },
{ option => "blanks", type => "i", short => "b" }
];
$txt->{manpage} = 0;
$txt->{filter} = 0;
$txt->{blanks} = 3;
$Formats{$txt->{NAME}} = $txt;
......@@ -44,19 +47,26 @@ $txt->{preNSGMLS} = sub
$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...
#
# the language support ja.
# the charset support nippon.
#
$global->{format} = $global->{charset};
$global->{charset} = "nippon" if $global->{language} eq "ja";
$global->{format} = "groff" if $global->{format} eq "ascii";
$global->{format} = "groff" if $global->{format} eq "nippon";
$global->{format} = "groff" if $global->{format} eq "euc-kr";
$ENV{SGML_SEARCH_PATH} =~ s/txt/$global->{format}/;
$Formats{"groff"} = $txt;
$Formats{"latin1"} = $txt;
$Formats{"man"} = $txt;
return 0;
$global->{NsgmlsPrePipe} = "cat $global->{file} " ;
};
......@@ -81,16 +91,48 @@ $txt->{preASP} = sub
{
my ($infile, $outfile) = @_;
my (@toc, @lines);
if ($txt->{manpage})
my $char_maps = load_char_maps ('.2tr', [ Text::EntityMap::sdata_dirs() ]);
if ( $global->{charset} eq "latin1" )
{
$char_maps = load_char_maps ('.2l1tr', [ Text::EntityMap::sdata_dirs() ]);
}
if ($txt->{manpage})
{
copy ($infile, $outfile);
while (<$infile>)
{
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 $_;
}
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
......@@ -103,6 +145,8 @@ $txt->{preASP} = sub
push (@toc, ")P\n");
push (@toc, "(VERB\n");
my (@prevheader, @header);
my $appendix = 0;
my $nonprint = 0;
while (<$infile>)
{
push (@lines, $_);
......@@ -111,16 +155,27 @@ $txt->{preASP} = sub
{
@prevheader = @header;
@header = @header[0..$1];
$header[$1]++;
if ($appendix == 1)
{
$header[$1] = "A";
$appendix = 0;
} else
{
$header[$1]++;
}
}
if (/^\(APPEND(.*)/)
{
$appendix = 1;
}
if (/^\(HEADING/)
{
$_ = <$infile>;
s/\\n/ /g;
push (@lines, $_);
chop;
s/^-//;
$_ = join(".",@header) . " " . $_;
s/\\n/ /g;
s/\(\\[0-9][0-9][0-9]\)/\\\1/g;
if (!$#header)
......@@ -130,15 +185,63 @@ $txt->{preASP} = sub
$_ = "\\n" . $_ unless (!$#prevheader);
# put a . and a space after top level sections
s/ /. /;
$_ = "-" . $_ . "\\n";
##### $_ = "-" . $_ . "\\n";
$_ = "-" . $_;
}
else
{
# subsections get indentation matching hierarchy
$_ = "-" . " " x $#header . $_;
}
push(@toc, parse_data ($_, $char_maps, $txt_escape), "\\n\n");
}
# remove tags from a toc
s/\)TT//g;
s/\(TT//g;
s/\)IT//g;
s/\(IT//g;
s/\)EM//g;
s/\(EM//g;
s/\)BF//g;
s/\(BF//g;
s/AID * CDATA.*$//g;
s/\)LABEL//g;
s/\(LABEL//g;
push(@toc, parse_data ($_, $char_maps, $txt_escape));
$_ = <$infile>;
while (!/^\)HEADING/) {
s/\\n/ /g; ####
push(@lines, $_);
chop;
s/^-//;
# remove tags from a toc
s/\)TT//g;
s/\(TT//g;
s/\)IT//g;
s/\(IT//g;
s/\)EM//g;
s/\(EM//g;
s/\)BF//g;
s/\(BF//g;
s/AID * CDATA.*$//g;
s/\)LABEL//g;
s/\(LABEL//g;
# remove NIDX, NCDX from a toc entry
if (/^\(NIDX$/ || /^\(NCDX$/) { $nonprint = 1; }
if (/^\)NIDX$/ || /^\)NCDX$/) { $nonprint = 1; }
# $_ = "-" . $_ . "\\n";
push(@toc, parse_data ($_, $char_maps, $txt_escape))
if (! $nonprint);
$_ = <$infile>;
}
s/\\n/ /g; ###
push(@lines, $_);
push(@toc, "\\n\n");
}
}
push (@toc, ")VERB\n");
push (@toc, "(HLINE\n");
......@@ -233,8 +336,9 @@ $txt->{postASP} = sub
}
else
{
create_temp("$global->{tmpbase}.txt.1");
$outfile = new FileHandle
"|$main::progs->{GROFF} -T $global->{pass} $global->{charset} -t $main::progs->{GROFFMACRO} >$global->{tmpbase}.txt.1";
"|$main::progs->{GROFF} $global->{pass} -T $global->{charset} -t $main::progs->{GROFFMACRO} >\"$global->{tmpbase}.txt.1\"";
}
#
......@@ -265,17 +369,36 @@ $txt->{postASP} = sub
{
$outfile->open (">$global->{filename}.txt");
$groffout = new FileHandle "<$global->{tmpbase}.txt.1";
my $count = 0;
if ($txt->{filter})
{
while (<$groffout>)
{
s/[^\cH][^\cH]\cH\cH//g;
s/.//g;
print $outfile $_;
if ($txt->{blanks})
{
$count = &{$txt->{cutblank}}($count, $outfile, $_);
}
else
{
print $outfile $_;
}
}
}
else
{
copy ($groffout, $outfile);
if ($txt->{blanks})
{
while (<$groffout>)
{
$count = &{$txt->{cutblank}}($count, $outfile, $_);
}
}
else
{
copy ($groffout, $outfile);
}
}
}
$groffout->close;
......@@ -284,4 +407,23 @@ $txt->{postASP} = sub
return 0;
};
$txt->{cutblank} = sub
{
my ($num, $out, $in) = @_;
if ( $in =~ /^$/ )
{
$num++;
}
else
{
$num = 0;
}
if ( $num <= $txt->{blanks} )
{
print $out $in;
}
return ($num);
};
1;
......@@ -15,30 +15,32 @@ sub BEGIN
}
use strict;
use vars qw($prefix $LibDir $BinDir $progs);
use vars qw($prefix $DataDir $BinDir $progs);
$prefix = "/usr";
$LibDir = "sbase";
$DataDir = "sbase";
$BinDir = "/usr/bin";
use lib "/usr/lib/sgml-tools";
use lib "/usr/share/linuxdoc-tools";
use lib "/usr/perl5";
use lib "/usr/lib/perl5";
use lib "/usr/share/perl5";
$progs = {
"NSGMLS" => "/usr/bin/nsgmls",
"SGMLSASP" => "/usr/bin/sgmlsasp",
"GROFF" => "/usr/bin/groff",
"GROFFMACRO" => "-mgs"
"GROFFMACRO" => "-ms",
"AWK" => "/usr/share/linuxdoc-tools/awkwhich"
};
$ENV{"SGML_CATALOG_FILES"} = "sbase/dtd/catalog";
require SGMLTools;
&SGMLTools::init;
require "./LinuxDocTools.pm";
&LinuxDocTools::init;
my @FileList = SGMLTools::process_options ($0, @ARGV);
my @FileList = LinuxDocTools::process_options ("html", @ARGV);
for my $curfile (@FileList)
{
SGMLTools::process_file ($curfile);
LinuxDocTools::process_file ($curfile);
}
exit 0;
......@@ -15,30 +15,32 @@ sub BEGIN
}
use strict;
use vars qw($prefix $LibDir $BinDir $progs);
use vars qw($prefix $DataDir $BinDir $progs);
$prefix = "/usr";
$LibDir = "sbase";
$DataDir = "sbase";
$BinDir = "/usr/bin";
use lib "/usr/lib/sgml-tools";
use lib "/usr/share/linuxdoc-tools";
use lib "/usr/perl5";
use lib "/usr/lib/perl5";
use lib "/usr/share/perl5";
$progs = {
"NSGMLS" => "/usr/bin/nsgmls",
"SGMLSASP" => "/usr/bin/sgmlsasp",
"GROFF" => "/usr/bin/groff",
"GROFFMACRO" => "-mgs"
"GROFFMACRO" => "-ms",
"AWK" => "/usr/share/linuxdoc-tools/awkwhich"
};
$ENV{"SGML_CATALOG_FILES"} = "sbase/dtd/catalog";
require SGMLTools;
&SGMLTools::init;
require "./LinuxDocTools.pm";
&LinuxDocTools::init;
my @FileList = SGMLTools::process_options ($0, @ARGV);
my @FileList = LinuxDocTools::process_options ("latex", @ARGV);
for my $curfile (@FileList)
{
SGMLTools::process_file ($curfile);
LinuxDocTools::process_file ($curfile);
}
exit 0;
......@@ -15,30 +15,32 @@ sub BEGIN
}
use strict;
use vars qw($prefix $LibDir $BinDir $progs);
use vars qw($prefix $DataDir $BinDir $progs);
$prefix = "/usr";
$LibDir = "sbase";
$DataDir = "sbase";
$BinDir = "/usr/bin";
use lib "/usr/lib/sgml-tools";
use lib "/usr/share/linuxdoc-tools";
use lib "/usr/perl5";
use lib "/usr/lib/perl5";
use lib "/usr/share/perl5";
$progs = {
"NSGMLS" => "/usr/bin/nsgmls",
"SGMLSASP" => "/usr/bin/sgmlsasp",
"GROFF" => "/usr/bin/groff",
"GROFFMACRO" => "-mgs"
"GROFFMACRO" => "-ms",
"AWK" => "/usr/share/linuxdoc-tools/awkwhich"
};
$ENV{"SGML_CATALOG_FILES"} = "sbase/dtd/catalog";
require SGMLTools;
&SGMLTools::init;
require "./LinuxDocTools.pm";
&LinuxDocTools::init;
my @FileList = SGMLTools::process_options ($0, @ARGV);
my @FileList = LinuxDocTools::process_options ("txt", @ARGV);
for my $curfile (@FileList)
{
SGMLTools::process_file ($curfile);
LinuxDocTools::process_file ($curfile);
}
exit 0;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment