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 :)
This commit is contained in:
parent
a9aa5887f3
commit
9c7631235a
7 changed files with 1210 additions and 92 deletions
634
doc/LinuxDocTools.pm
Normal file
634
doc/LinuxDocTools.pm
Normal file
|
@ -0,0 +1,634 @@
|
||||||
|
#! /usr/bin/perl
|
||||||
|
#
|
||||||
|
# LinuxDocTools.pm
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
# LinuxDoc-Tools driver core. This contains all the basic functionality
|
||||||
|
# we need to control all other components.
|
||||||
|
#
|
||||||
|
# © Copyright 1996, Cees de Groot.
|
||||||
|
# © Copyright 2000, Taketoshi Sano
|
||||||
|
#
|
||||||
|
# THIS VERSION HAS BEEN HACKED FOR BIRD BY MARTIN MARES
|
||||||
|
#
|
||||||
|
package LinuxDocTools;
|
||||||
|
|
||||||
|
require 5.004;
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
LinuxDocTools - SGML conversion utilities for LinuxDoc DTD.
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
use LinuxDocTools;
|
||||||
|
LinuxDocTools::init;
|
||||||
|
@files = LinuxDocTools::process_options ($0, @ARGV);
|
||||||
|
for $curfile (@files) {
|
||||||
|
LinuxDocTools::process_file ($curfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
The LinuxDocTools package encapsulates all the functionality offered by
|
||||||
|
LinuxDoc-Tools. It is used, of course, by LinuxDoc-Tools;
|
||||||
|
but the encapsulation should provide for a simple interface for other users as well.
|
||||||
|
|
||||||
|
=head1 FUNCTIONS
|
||||||
|
|
||||||
|
=over 4
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
use DirHandle;
|
||||||
|
use File::Basename;
|
||||||
|
use File::Find;
|
||||||
|
use File::Copy;
|
||||||
|
use FileHandle;
|
||||||
|
use IPC::Open2;
|
||||||
|
use Cwd;
|
||||||
|
use LinuxDocTools::Lang;
|
||||||
|
use LinuxDocTools::Utils qw(process_options usage cleanup trap_signals remove_tmpfiles create_temp);
|
||||||
|
use LinuxDocTools::Vars;
|
||||||
|
|
||||||
|
sub BEGIN
|
||||||
|
{
|
||||||
|
#
|
||||||
|
# Make sure we're always looking here. Note that "use lib" adds
|
||||||
|
# on the front of the search path, so we first push dist, then
|
||||||
|
# site, so that site is searched first.
|
||||||
|
#
|
||||||
|
use lib "$main::DataDir/dist";
|
||||||
|
use lib "$main::DataDir/site";
|
||||||
|
}
|
||||||
|
|
||||||
|
=item LinuxDocTools::init
|
||||||
|
|
||||||
|
Takes care of initialization of package-global variables (which are actually
|
||||||
|
defined in L<LinuxDocTools::Vars>). The package-global variables are I<$global>,
|
||||||
|
a reference to a hash containing numerous settings, I<%Formats>, a hash
|
||||||
|
containing all the formats, and I<%FmtList>, a hash containing the currently
|
||||||
|
active formats for help texts.
|
||||||
|
|
||||||
|
Apart from this, C<LinuxDocTools::init> also finds all distributed and site-local
|
||||||
|
formatting backends and C<require>s them.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub init
|
||||||
|
{
|
||||||
|
trap_signals;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Register the ``global'' pseudoformat. Apart from the global settings,
|
||||||
|
# we also use $global to keep the global variable name space clean;
|
||||||
|
# everything that we need to provide to other modules is stuffed
|
||||||
|
# into $global.
|
||||||
|
#
|
||||||
|
$global = {};
|
||||||
|
$global->{NAME} = "global";
|
||||||
|
$global->{HELP} = "";
|
||||||
|
$global->{OPTIONS} = [
|
||||||
|
{ option => "backend", type => "l",
|
||||||
|
'values' => [ "html", "info", "latex",
|
||||||
|
"lyx", "rtf", "txt", "check" ],
|
||||||
|
short => "B" },
|
||||||
|
{ option => "papersize", type => "l",
|
||||||
|
'values' => [ "a4", "letter" ], short => "p" },
|
||||||
|
{ option => "language", type => "l",
|
||||||
|
'values' => [ @LinuxDocTools::Lang::Languages ], short => "l" },
|
||||||
|
{ option => "charset", type => "l",
|
||||||
|
'values' => [ "latin", "ascii", "nippon", "euc-kr" ], short => "c" },
|
||||||
|
{ option => "style", type => "s", short => "S" },
|
||||||
|
{ option => "tabsize", type => "i", short => "t" },
|
||||||
|
# { option => "verbose", type => "f", short => "v" },
|
||||||
|
{ option => "debug", type => "f", short => "d" },
|
||||||
|
{ option => "define", type => "s", short => "D" },
|
||||||
|
{ option => "include", type => "s", short => "i" },
|
||||||
|
{ option => "pass", type => "s", short => "P" }
|
||||||
|
];
|
||||||
|
$global->{backend} = "linuxdoc";
|
||||||
|
$global->{papersize} = "a4";
|
||||||
|
$global->{language} = "en";
|
||||||
|
$global->{charset} = "ascii";
|
||||||
|
$global->{style} = "";
|
||||||
|
$global->{tabsize} = 8;
|
||||||
|
$global->{verbose} = 0;
|
||||||
|
$global->{define} = "";
|
||||||
|
$global->{debug} = 0;
|
||||||
|
$global->{include} = "";
|
||||||
|
$global->{pass} = "";
|
||||||
|
$global->{InFiles} = [];
|
||||||
|
$Formats{$global->{NAME}} = $global; # All formats we know.
|
||||||
|
$FmtList{$global->{NAME}} = $global; # List of formats for help msgs.
|
||||||
|
|
||||||
|
# automatic language detection: disabled by default
|
||||||
|
# {
|
||||||
|
# my $lang;
|
||||||
|
# foreach $lang (@LinuxDocTools::Lang::Languages)
|
||||||
|
# {
|
||||||
|
# if (($ENV{"LC_ALL"} =~ /^$lang/i) ||
|
||||||
|
# ($ENV{"LC_CTYPE"} =~ /^$lang/i) ||
|
||||||
|
# ($ENV{"LANG"} =~ /^$lang/i)) {
|
||||||
|
# $global->{language} = Any2ISO($lang);
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
|
||||||
|
#
|
||||||
|
# Used when the format is "global" (from sgmlcheck).
|
||||||
|
#
|
||||||
|
$global->{preNSGMLS} = sub {
|
||||||
|
$global->{NsgmlsOpts} .= " -s ";
|
||||||
|
$global->{NsgmlsPrePipe} = "cat $global->{file}";
|
||||||
|
};
|
||||||
|
|
||||||
|
#
|
||||||
|
# Build up the list of formatters.
|
||||||
|
#
|
||||||
|
my $savdir = cwd;
|
||||||
|
my %Locs;
|
||||||
|
chdir "$main::DataDir/dist";
|
||||||
|
my $dir = new DirHandle(".");
|
||||||
|
die "Unable to read directory $main::DataDir/dist: $!" unless defined($dir);
|
||||||
|
foreach my $fmt (grep(/^fmt_.*\.pl$/, $dir->read()))
|
||||||
|
{
|
||||||
|
$Locs{$fmt} = "dist";
|
||||||
|
}
|
||||||
|
$dir->close();
|
||||||
|
chdir "$main::DataDir/site";
|
||||||
|
$dir = new DirHandle(".");
|
||||||
|
die "Unable to read directory $main::DataDir/site: $!" unless defined($dir);
|
||||||
|
foreach my $fmt (grep(/^fmt_.*\.pl$/, $dir->read()))
|
||||||
|
{
|
||||||
|
$Locs{$fmt} = "site";
|
||||||
|
}
|
||||||
|
$dir->close();
|
||||||
|
foreach my $fmt (keys %Locs)
|
||||||
|
{
|
||||||
|
require $fmt;
|
||||||
|
}
|
||||||
|
chdir $savdir;
|
||||||
|
}
|
||||||
|
|
||||||
|
=item LinuxDocTools::process_options ($0, @ARGV)
|
||||||
|
|
||||||
|
This function contains all initialization that is bound to the current
|
||||||
|
invocation of LinuxDocTools. It looks in C<$0> to deduce the backend that
|
||||||
|
should be used (ld2txt activates the I<txt> backend) and parses the
|
||||||
|
options array. It returns an array of filenames it encountered during
|
||||||
|
option processing.
|
||||||
|
|
||||||
|
As a side effect, the environment variables I<SGMLDECL> and
|
||||||
|
I<SGML_CATALOG_FILES> are modified.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub process_options
|
||||||
|
{
|
||||||
|
my $progname = shift;
|
||||||
|
my @args = @_;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Deduce the format from the caller's file name
|
||||||
|
#
|
||||||
|
my ($format, $dummy1, $dummy2) = fileparse ($progname, "");
|
||||||
|
$global->{myname} = $format;
|
||||||
|
$format =~ s/sgml2*(.*)/$1/;
|
||||||
|
|
||||||
|
#
|
||||||
|
# check the option "--backend / -B"
|
||||||
|
#
|
||||||
|
if ($format eq "linuxdoc") {
|
||||||
|
my @backends = @args;
|
||||||
|
my $arg;
|
||||||
|
while (@backends) {
|
||||||
|
$arg = shift @backends;
|
||||||
|
if ($arg eq "-B") {
|
||||||
|
$arg = shift @backends;
|
||||||
|
$format = $arg;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
if ( $arg =~ s/--backend=(.*)/$1/ ) {
|
||||||
|
$format = $arg;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$format = "global" if $format eq "check";
|
||||||
|
usage ("") if $format eq "linuxdoc";
|
||||||
|
$format = "latex2e" if $format eq "latex";
|
||||||
|
$FmtList{$format} = $Formats{$format} or
|
||||||
|
usage ("$global->{myname}: unknown format");
|
||||||
|
$global->{format} = $format;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Parse all the options.
|
||||||
|
#
|
||||||
|
my @files = LinuxDocTools::Utils::process_options (@args);
|
||||||
|
$global->{language} = Any2ISO ($global->{language});
|
||||||
|
#
|
||||||
|
# check the number of given files
|
||||||
|
$#files > -1 || usage ("no filenames given");
|
||||||
|
|
||||||
|
#
|
||||||
|
# Setup the SGML environment.
|
||||||
|
# (Note that Debian package rewrite path to catalog of
|
||||||
|
# iso-entities using debian/rules so that it can use
|
||||||
|
# entities from sgml-data pacakge. debian/rules also
|
||||||
|
# removes iso-entites sub directory after doing make install.)
|
||||||
|
#
|
||||||
|
$ENV{SGML_CATALOG_FILES} .= (defined $ENV{SGML_CATALOG_FILES} ? ":" : "") .
|
||||||
|
"$main::prefix/share/sgml/entities/sgml-iso-entities-8879.1986/catalog";
|
||||||
|
$ENV{SGML_CATALOG_FILES} .= ":$main::DataDir/linuxdoc-tools.catalog";
|
||||||
|
$ENV{SGML_CATALOG_FILES} .= ":$main::/etc/sgml.catalog";
|
||||||
|
if (-f "$main::DataDir/dtd/$format.dcl")
|
||||||
|
{
|
||||||
|
$ENV{SGMLDECL} = "$main::DataDir/dtd/$format.dcl";
|
||||||
|
}
|
||||||
|
elsif (-f "$main::DataDir/dtd/$global->{style}.dcl")
|
||||||
|
{
|
||||||
|
$ENV{SGMLDECL} = "$main::DataDir/dtd/$global->{style}.dcl";
|
||||||
|
}
|
||||||
|
elsif (-f "$main::DataDir/dtd/sgml.dcl")
|
||||||
|
{
|
||||||
|
$ENV{SGMLDECL} = "$main::DataDir/dtd/sgml.dcl";
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# OK. Give the list of files we distilled from the options
|
||||||
|
# back to the caller.
|
||||||
|
#
|
||||||
|
return @files;
|
||||||
|
}
|
||||||
|
|
||||||
|
=item LinuxDocTools::process_file
|
||||||
|
|
||||||
|
With all the configuration done, this routine will take a single filename
|
||||||
|
and convert it to the currently active backend format. The conversion is
|
||||||
|
done in a number of steps in tight interaction with the currently active
|
||||||
|
backend (see also L<LinuxDocTools::BackEnd>):
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
=item 1. Backend: set NSGMLS options and optionally create a pre-NSGMLS pipe.
|
||||||
|
|
||||||
|
=item 2. Here: Run the preprocessor to handle conditionals.
|
||||||
|
|
||||||
|
=item 3. Here: Run NSGMLS.
|
||||||
|
|
||||||
|
=item 4. Backend: run pre-ASP conversion.
|
||||||
|
|
||||||
|
=item 5. Here: Run SGMLSASP.
|
||||||
|
|
||||||
|
=item 6. Backend: run post-ASP conversion, generating the output.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
All stages are influenced by command-line settings, currently active format,
|
||||||
|
etcetera. See the code for details.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub process_file
|
||||||
|
{
|
||||||
|
my $file = shift (@_);
|
||||||
|
my $saved_umask = umask;
|
||||||
|
|
||||||
|
print "Processing file $file\n";
|
||||||
|
umask 0077;
|
||||||
|
|
||||||
|
my ($filename, $filepath, $filesuffix) = fileparse ($file, "\.sgml");
|
||||||
|
my $tmpnam = $filepath . '/' . $filename;
|
||||||
|
$file = $tmpnam . $filesuffix;
|
||||||
|
-f $file || $file =~ /.*.sgml$/ || ($file .= '.sgml');
|
||||||
|
-f $file || ($file = $tmpnam . '.SGML');
|
||||||
|
-f $file || die "Cannot find $file\n";
|
||||||
|
$global->{filename} = $filename;
|
||||||
|
$global->{file} = $file;
|
||||||
|
$global->{filepath} = $filepath;
|
||||||
|
|
||||||
|
my $tmp = new FileHandle "<$file";
|
||||||
|
my $dtd;
|
||||||
|
while ( <$tmp> )
|
||||||
|
{
|
||||||
|
tr/A-Z/a-z/;
|
||||||
|
# check for [<!doctype ... system] type definition
|
||||||
|
if ( /<!doctype\s*(\w*)\s*system/ )
|
||||||
|
{
|
||||||
|
$dtd = $1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
# check for <!doctype ... PUBLIC ... DTD ...
|
||||||
|
if ( /<!doctype\s*\w*\s*public\s*.*\/\/dtd\s*(\w*)/mi )
|
||||||
|
{
|
||||||
|
$dtd = $1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
# check for <!doctype ...
|
||||||
|
# PUBLIC ... DTD ...
|
||||||
|
# (multi-line version)
|
||||||
|
if ( /<!doctype\s*(\w*)/ )
|
||||||
|
{
|
||||||
|
$dtd = "precheck";
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
if ( /\s*public\s*.*\/\/dtd\s*(\w*)/ && $dtd eq "precheck" )
|
||||||
|
{
|
||||||
|
$dtd = $1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$tmp->close;
|
||||||
|
if ( $global->{debug} )
|
||||||
|
{
|
||||||
|
print "DTD: " . $dtd . "\n";
|
||||||
|
}
|
||||||
|
$global->{dtd} = $dtd;
|
||||||
|
|
||||||
|
# prepare temporary directory
|
||||||
|
my $tmpdir = $ENV{'TMPDIR'} || '/tmp';
|
||||||
|
$tmpdir = $tmpdir . '/' . 'linuxdoc-dir-' . $$;
|
||||||
|
mkdir ($tmpdir, 0700) ||
|
||||||
|
die " - temporary files can not be created, aborted - \n";
|
||||||
|
|
||||||
|
my $tmpbase = $global->{tmpbase} = $tmpdir . '/sgmltmp.' . $filename;
|
||||||
|
$ENV{"SGML_SEARCH_PATH"} .= ":$filepath";
|
||||||
|
|
||||||
|
#
|
||||||
|
# Set up the preprocessing command. Conditionals have to be
|
||||||
|
# handled here until they can be moved into the DTD, otherwise
|
||||||
|
# a validating SGML parser will choke on them.
|
||||||
|
#
|
||||||
|
# check if output option for latex is pdf or not
|
||||||
|
if ($global->{format} eq "latex2e")
|
||||||
|
{
|
||||||
|
if ($Formats{$global->{format}}{output} eq "pdf")
|
||||||
|
{
|
||||||
|
$global->{define} .= " pdflatex=yes";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#
|
||||||
|
my($precmd) = "|sgmlpre output=$global->{format} $global->{define}";
|
||||||
|
|
||||||
|
#
|
||||||
|
# You can hack $NsgmlsOpts here, etcetera.
|
||||||
|
#
|
||||||
|
$global->{NsgmlsOpts} .= "-D $main::prefix/share/sgml -D $main::DataDir";
|
||||||
|
$global->{NsgmlsOpts} .= "-i$global->{include}" if ($global->{include});
|
||||||
|
$global->{NsgmlsPrePipe} = "NOTHING";
|
||||||
|
if ( defined $Formats{$global->{format}}{preNSGMLS} )
|
||||||
|
{
|
||||||
|
$global->{NsgmlsPrePipe} = &{$Formats{$global->{format}}{preNSGMLS}};
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Run the prepocessor and nsgmls.
|
||||||
|
#
|
||||||
|
my ($ifile, $writensgmls);
|
||||||
|
|
||||||
|
if ($global->{NsgmlsPrePipe} eq "NOTHING")
|
||||||
|
{
|
||||||
|
$ifile = new FileHandle $file;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$ifile = new FileHandle "$global->{NsgmlsPrePipe}|";
|
||||||
|
}
|
||||||
|
|
||||||
|
create_temp("$tmpbase.1");
|
||||||
|
$writensgmls = new FileHandle
|
||||||
|
"$precmd|$main::progs->{NSGMLS} $global->{NsgmlsOpts} $ENV{SGMLDECL} >\"$tmpbase.1\"";
|
||||||
|
if ($global->{charset} eq "latin")
|
||||||
|
{
|
||||||
|
while (<$ifile>)
|
||||||
|
{
|
||||||
|
# Outline these commands later on - CdG
|
||||||
|
#change latin1 characters to SGML
|
||||||
|
#by Farzad Farid, adapted by Greg Hankins
|
||||||
|
s/À/\À/g;
|
||||||
|
s/Á/\Á/g;
|
||||||
|
s/Â/\Â/g;
|
||||||
|
s/Ã/\Ã/g;
|
||||||
|
s/Ä/\Ä/g;
|
||||||
|
s/Å/\Å/g;
|
||||||
|
s/Æ/\Æ/g;
|
||||||
|
s/Ç/\Ç/g;
|
||||||
|
s/È/\È/g;
|
||||||
|
s/É/\É/g;
|
||||||
|
s/Ê/\Ê/g;
|
||||||
|
s/Ë/\Ë/g;
|
||||||
|
s/Ì/\Ì/g;
|
||||||
|
s/Í/\Í/g;
|
||||||
|
s/Î/\Î/g;
|
||||||
|
s/Ï/\Ï/g;
|
||||||
|
s/Ñ/\Ñ/g;
|
||||||
|
s/Ò/\Ò/g;
|
||||||
|
s/Ó/\Ó/g;
|
||||||
|
s/Ô/\Ô/g;
|
||||||
|
s/Õ/\Õ/g;
|
||||||
|
s/Ö/\Ö/g;
|
||||||
|
s/Ø/\Ø/g;
|
||||||
|
s/Ù/\Ù/g;
|
||||||
|
s/Ú/\Ú/g;
|
||||||
|
s/Û/\Û/g;
|
||||||
|
s/Ü/\Ü/g;
|
||||||
|
s/Ý/\Ý/g;
|
||||||
|
s/Þ/\Þ/g;
|
||||||
|
s/ß/\ß/g;
|
||||||
|
s/à/\à/g;
|
||||||
|
s/á/\á/g;
|
||||||
|
s/â/\â/g;
|
||||||
|
s/ã/\ã/g;
|
||||||
|
s/ä/\ä/g;
|
||||||
|
s/å/\å/g;
|
||||||
|
s/æ/\æ/g;
|
||||||
|
s/ç/\ç/g;
|
||||||
|
s/è/\è/g;
|
||||||
|
s/é/\é/g;
|
||||||
|
s/ê/\ê/g;
|
||||||
|
s/ë/\ë/g;
|
||||||
|
s/ì/\ì/g;
|
||||||
|
s/í/\í/g;
|
||||||
|
s/î/\î/g;
|
||||||
|
s/ï/\ï/g;
|
||||||
|
s/µ/\μ/g;
|
||||||
|
s/ð/\ð/g;
|
||||||
|
s/ñ/\ñ/g;
|
||||||
|
s/ò/\ò/g;
|
||||||
|
s/ó/\ó/g;
|
||||||
|
s/ô/\ô/g;
|
||||||
|
s/õ/\õ/g;
|
||||||
|
s/ö/\ö/g;
|
||||||
|
s/ø/\ø/g;
|
||||||
|
s/ù/\ù/g;
|
||||||
|
s/ú/\ú/g;
|
||||||
|
s/û/\û/g;
|
||||||
|
s/ü/\ü/g;
|
||||||
|
s/ý/\ý/g;
|
||||||
|
s/þ/\þ/g;
|
||||||
|
s/ÿ/\ÿ/g;
|
||||||
|
print $writensgmls $_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (<$ifile>)
|
||||||
|
{
|
||||||
|
print $writensgmls $_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$ifile->close;
|
||||||
|
$writensgmls->close;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Special case: if format is global, we're just checking.
|
||||||
|
#
|
||||||
|
$global->{format} eq "global" && cleanup;
|
||||||
|
|
||||||
|
#
|
||||||
|
# If the output file is empty, something went wrong.
|
||||||
|
#
|
||||||
|
! -e "$tmpbase.1" and die "can't create file - exiting";
|
||||||
|
-z "$tmpbase.1" and die "SGML parsing error - exiting";
|
||||||
|
if ( $global->{debug} )
|
||||||
|
{
|
||||||
|
print "Nsgmls stage finished.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# If a preASP stage is defined, let the format handle it.
|
||||||
|
#
|
||||||
|
# preASP ($inhandle, $outhandle);
|
||||||
|
#
|
||||||
|
my $inpreasp = new FileHandle "<$tmpbase.1";
|
||||||
|
my $outpreasp = new FileHandle "$tmpbase.2",O_WRONLY|O_CREAT|O_EXCL,0600;
|
||||||
|
if (defined $Formats{$global->{format}}{preASP})
|
||||||
|
{
|
||||||
|
&{$Formats{$global->{format}}{preASP}}($inpreasp, $outpreasp) == 0 or
|
||||||
|
die "error pre-processing $global->{format}.\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
copy ($inpreasp, $outpreasp);
|
||||||
|
}
|
||||||
|
$inpreasp->close;
|
||||||
|
$outpreasp->close;
|
||||||
|
! -e "$tmpbase.2" and die "can't create file - exiting";
|
||||||
|
|
||||||
|
if ( $global->{debug} )
|
||||||
|
{
|
||||||
|
print "PreASP stage finished.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Run sgmlsasp, with an optional style if specified.
|
||||||
|
#
|
||||||
|
# Search order:
|
||||||
|
# - datadir/site/<dtd>/<format>
|
||||||
|
# - datadir/dist/<dtd>/<format>
|
||||||
|
# So we need to fetch the doctype from the intermediate.
|
||||||
|
#
|
||||||
|
# Note: this is a very simplistic check - but as far as I know,
|
||||||
|
# it is correct. Am I right?
|
||||||
|
#
|
||||||
|
my $tmp = new FileHandle "<$tmpbase.2";
|
||||||
|
my $dtd;
|
||||||
|
while ( ($dtd = <$tmp>) && ! ( $dtd =~ /^\(/) ) { };
|
||||||
|
$tmp->close;
|
||||||
|
$dtd =~ s/^\(//;
|
||||||
|
$dtd =~ tr/A-Z/a-z/;
|
||||||
|
chop $dtd;
|
||||||
|
$global->{dtd} = $dtd;
|
||||||
|
|
||||||
|
my $style = "";
|
||||||
|
if ($global->{style})
|
||||||
|
{
|
||||||
|
$style = "$main::DataDir/site/$dtd/$global->{format}/$global->{style}mapping";
|
||||||
|
-r $style or
|
||||||
|
$style = "$main::DataDir/dist/$dtd/$global->{format}/$global->{style}mapping";
|
||||||
|
}
|
||||||
|
my $mapping = "$main::DataDir/site/$dtd/$global->{format}/mapping";
|
||||||
|
-r $mapping or $mapping = "$main::DataDir/dist/$dtd/$global->{format}/mapping";
|
||||||
|
|
||||||
|
$global->{charset} = "nippon" if ($global->{language} eq "ja");
|
||||||
|
#
|
||||||
|
# we don't have Korean groff so charset should be latin1.
|
||||||
|
#
|
||||||
|
if ($global->{language} eq "ko")
|
||||||
|
{
|
||||||
|
if ($global->{format} eq "groff")
|
||||||
|
{
|
||||||
|
$global->{charset} = "latin1";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$global->{charset} = "euc-kr";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($global->{format} eq "groff" or $global->{format} eq "latex2e")
|
||||||
|
{
|
||||||
|
if ($dtd eq "linuxdoctr")
|
||||||
|
{
|
||||||
|
$mapping = "$main::DataDir/dist/$dtd/$global->{format}/tr-mapping";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
create_temp("$tmpbase.3");
|
||||||
|
system ("$main::progs->{SGMLSASP} $style $mapping <\"$tmpbase.2\" |
|
||||||
|
expand -$global->{tabsize} >\"$tmpbase.3\"");
|
||||||
|
! -e "$tmpbase.3" and die "can't create file - exiting";
|
||||||
|
|
||||||
|
|
||||||
|
if ( $global->{debug} )
|
||||||
|
{
|
||||||
|
print "ASP stage finished.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# If a postASP stage is defined, let the format handle it.
|
||||||
|
# It should leave whatever it thinks is right based on $file.
|
||||||
|
#
|
||||||
|
# postASP ($inhandle)
|
||||||
|
#
|
||||||
|
umask $saved_umask;
|
||||||
|
my $inpostasp = new FileHandle "<$tmpbase.3";
|
||||||
|
if (defined $Formats{$global->{format}}{postASP})
|
||||||
|
{
|
||||||
|
&{$Formats{$global->{format}}{postASP}}($inpostasp) == 0 or
|
||||||
|
die "error post-processing $global->{format}.\n";
|
||||||
|
}
|
||||||
|
$inpostasp->close;
|
||||||
|
|
||||||
|
if ( $global->{debug} )
|
||||||
|
{
|
||||||
|
print "postASP stage finished.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# All done, remove the temporaries.
|
||||||
|
#
|
||||||
|
if( !$global->{debug} ) {
|
||||||
|
remove_tmpfiles($tmpbase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
=pod
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=head1 SEE ALSO
|
||||||
|
|
||||||
|
Documentation for various sub-packages of LinuxDocTools.
|
||||||
|
|
||||||
|
=head1 AUTHOR
|
||||||
|
SGMLTools are written by Cees de Groot, C<E<lt>cg@cdegroot.comE<gt>>,
|
||||||
|
and various SGML-Tools contributors as listed in C<CONTRIBUTORS>.
|
||||||
|
Taketoshi Sano C<E<lt>sano@debian.org<gt>> rename to LinuxDocTools.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
1;
|
32
doc/sbase/dist/fmt_html.pl
vendored
32
doc/sbase/dist/fmt_html.pl
vendored
|
@ -7,17 +7,17 @@
|
||||||
#
|
#
|
||||||
# © Copyright 1996, Cees de Groot
|
# © Copyright 1996, Cees de Groot
|
||||||
#
|
#
|
||||||
package SGMLTools::fmt_html;
|
package LinuxDocTools::fmt_html;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
use SGMLTools::CharEnts;
|
use LinuxDocTools::CharEnts;
|
||||||
use SGMLTools::Vars;
|
use LinuxDocTools::Vars;
|
||||||
|
|
||||||
use SGMLTools::FixRef;
|
use LinuxDocTools::FixRef;
|
||||||
my $fixref = $SGMLTools::FixRef::fixref;
|
my $fixref = $LinuxDocTools::FixRef::fixref;
|
||||||
|
|
||||||
use SGMLTools::Html2Html;
|
use LinuxDocTools::Html2Html;
|
||||||
my $html2html = $SGMLTools::Html2Html::html2html;
|
my $html2html = $LinuxDocTools::Html2Html::html2html;
|
||||||
|
|
||||||
my $html = {};
|
my $html = {};
|
||||||
$html->{NAME} = "html";
|
$html->{NAME} = "html";
|
||||||
|
@ -25,14 +25,22 @@ $html->{HELP} = "";
|
||||||
$html->{OPTIONS} = [
|
$html->{OPTIONS} = [
|
||||||
{ option => "split", type => "l",
|
{ option => "split", type => "l",
|
||||||
'values' => [ "0", "1", "2" ], short => "s" },
|
'values' => [ "0", "1", "2" ], short => "s" },
|
||||||
|
{ option => "toc", type => "l",
|
||||||
|
'values' => [ "0", "1", "2" ], short => "T" },
|
||||||
{ option => "dosnames", type => "f", short => "h" },
|
{ 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->{'split'} = 1;
|
||||||
|
$html->{'toc'} = -1;
|
||||||
$html->{dosnames} = 0;
|
$html->{dosnames} = 0;
|
||||||
$html->{imagebuttons} = 0;
|
$html->{imagebuttons} = 0;
|
||||||
|
$html->{header} = "";
|
||||||
|
$html->{footer} = "";
|
||||||
$html->{preNSGMLS} = sub {
|
$html->{preNSGMLS} = sub {
|
||||||
$global->{NsgmlsOpts} .= " -ifmthtml ";
|
$global->{NsgmlsOpts} .= " -ifmthtml ";
|
||||||
|
$global->{NsgmlsPrePipe} = "cat $global->{file}";
|
||||||
};
|
};
|
||||||
|
|
||||||
$Formats{$html->{NAME}} = $html;
|
$Formats{$html->{NAME}} = $html;
|
||||||
|
@ -132,11 +140,15 @@ $html->{postASP} = sub
|
||||||
# Run through html2html, preserving stdout
|
# Run through html2html, preserving stdout
|
||||||
# Also, handle prehtml.sed's tasks
|
# Also, handle prehtml.sed's tasks
|
||||||
#
|
#
|
||||||
|
my $filter = "";
|
||||||
|
# $filter = "|$main::progs->{NKF} -e" if ($global->{language} eq "ja");
|
||||||
open SAVEOUT, ">&STDOUT";
|
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,
|
&{$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) {
|
LINE: foreach (@file) {
|
||||||
s,<P></P>,,g; # remove empty <P></P> containers
|
s,<P></P>,,g; # remove empty <P></P> containers
|
||||||
foreach my $pat (keys %{$html2html->{rules}}) {
|
foreach my $pat (keys %{$html2html->{rules}}) {
|
||||||
|
|
396
doc/sbase/dist/fmt_latex2e.pl
vendored
396
doc/sbase/dist/fmt_latex2e.pl
vendored
|
@ -7,12 +7,15 @@
|
||||||
#
|
#
|
||||||
# © Copyright 1996, Cees de Groot
|
# © Copyright 1996, Cees de Groot
|
||||||
#
|
#
|
||||||
package SGMLTools::fmt_latex2e;
|
# Support for PDF files: added by Juan Jose Amor, January 2000
|
||||||
|
# © Copyright 2000, Juan Jose Amor
|
||||||
|
#
|
||||||
|
package LinuxDocTools::fmt_latex2e;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
use SGMLTools::CharEnts;
|
use LinuxDocTools::CharEnts;
|
||||||
use SGMLTools::Vars;
|
use LinuxDocTools::Vars;
|
||||||
use SGMLTools::Lang;
|
use LinuxDocTools::Lang;
|
||||||
|
|
||||||
use File::Copy;
|
use File::Copy;
|
||||||
|
|
||||||
|
@ -24,23 +27,48 @@ $latex2e->{HELP} = <<EOF;
|
||||||
EOF
|
EOF
|
||||||
$latex2e->{OPTIONS} = [
|
$latex2e->{OPTIONS} = [
|
||||||
{ option => "output", type => "l",
|
{ option => "output", type => "l",
|
||||||
'values' => [ "dvi", "tex", "ps" ], short => "o" },
|
'values' => [ "dvi", "tex", "ps", "pdf" ], short => "o" },
|
||||||
{ option => "bibtex", type => "f", short => "b" },
|
{ option => "bibtex", type => "f", short => "b" },
|
||||||
{ option => "makeindex", type => "f", short => "m" },
|
{ option => "makeindex", type => "f", short => "m" },
|
||||||
{ option => "pagenumber", type => "i", short => "n" },
|
{ option => "pagenumber", type => "i", short => "n" },
|
||||||
{ option => "quick", type => "f", short => "q" }
|
{ option => "quick", type => "f", short => "q" },
|
||||||
|
{ option => "dvips", type => "l",
|
||||||
|
'values' => [ "dvips", "dvi2ps", "jdvi2kps" ], short => "s" },
|
||||||
|
{ option => "latex", type => "l",
|
||||||
|
'values' => [ "latex", "hlatexp", "platex", "jlatex" ], short => "x" }
|
||||||
];
|
];
|
||||||
$latex2e->{output} = "dvi";
|
$latex2e->{output} = "tex";
|
||||||
$latex2e->{pagenumber} = 1;
|
$latex2e->{pagenumber} = 1;
|
||||||
$latex2e->{quick} = 0;
|
$latex2e->{quick} = 0;
|
||||||
$latex2e->{bibtex} = 0;
|
$latex2e->{bibtex} = 0;
|
||||||
$latex2e->{makeindex} = 0;
|
$latex2e->{makeindex} = 0;
|
||||||
$latex2e->{preNSGMLS} = sub {
|
$latex2e->{latex} = "unknown";
|
||||||
$global->{NsgmlsOpts} .= " -ifmttex ";
|
$latex2e->{dvips} = "unknown";
|
||||||
};
|
|
||||||
|
|
||||||
$Formats{$latex2e->{NAME}} = $latex2e;
|
$Formats{$latex2e->{NAME}} = $latex2e;
|
||||||
|
|
||||||
|
$latex2e->{preNSGMLS} = sub {
|
||||||
|
$global->{NsgmlsOpts} .= " -ifmttex ";
|
||||||
|
|
||||||
|
# for Japanese jlatex users
|
||||||
|
if ($global->{language} eq "ja" && $latex2e->{latex} eq "unknown") {
|
||||||
|
$latex2e->{latex} = "jlatex";
|
||||||
|
$latex2e->{dvips} = "dvi2ps";
|
||||||
|
# for Japanese platex users
|
||||||
|
# $latex2e->{latex} = "platex";
|
||||||
|
# $latex2e->{dvips} = "dvips";
|
||||||
|
}
|
||||||
|
|
||||||
|
# for Korean users
|
||||||
|
if ($global->{language} eq "ko" && $latex2e->{latex} eq "unknown") {
|
||||||
|
$latex2e->{latex} = "hlatexp";
|
||||||
|
}
|
||||||
|
|
||||||
|
# default process command
|
||||||
|
$latex2e->{latex} = "latex" if ($latex2e->{latex} eq "unknown");
|
||||||
|
$latex2e->{dvips} = "dvips" if ($latex2e->{dvips} eq "unknown");
|
||||||
|
|
||||||
|
$global->{NsgmlsPrePipe} = "cat $global->{file} ";
|
||||||
|
};
|
||||||
|
|
||||||
# extra `\\' here for standard `nsgmls' output
|
# extra `\\' here for standard `nsgmls' output
|
||||||
my %latex2e_escapes;
|
my %latex2e_escapes;
|
||||||
|
@ -59,6 +87,7 @@ $latex2e_escapes{'<'} = '{$<$}'; # wouldn't happen, but that's what'd be
|
||||||
$latex2e_escapes{'|'} = '{$|$}';
|
$latex2e_escapes{'|'} = '{$|$}';
|
||||||
|
|
||||||
my $in_verb;
|
my $in_verb;
|
||||||
|
my $remove_comment; # added 2000 Jan 25 by t.sano
|
||||||
|
|
||||||
# passed to `parse_data' below in latex2e_preASP
|
# passed to `parse_data' below in latex2e_preASP
|
||||||
my $latex2e_escape = sub {
|
my $latex2e_escape = sub {
|
||||||
|
@ -95,13 +124,22 @@ $latex2e->{preASP} = sub
|
||||||
# a VERB or CODE environment or not
|
# a VERB or CODE environment or not
|
||||||
$in_verb = 0;
|
$in_verb = 0;
|
||||||
|
|
||||||
|
# switch to remove empty line from TeX source or not, depending
|
||||||
|
# on whether we're in a HEADING or ABSTRACT environment or not
|
||||||
|
$remove_comment = 0;
|
||||||
|
|
||||||
while (<$infile>)
|
while (<$infile>)
|
||||||
{
|
{
|
||||||
if (/^-/)
|
if (/^-/)
|
||||||
{
|
{
|
||||||
my ($str) = $';
|
my ($str) = $';
|
||||||
chop ($str);
|
chop ($str);
|
||||||
print $outfile "-" . parse_data ($str, $char_maps, $latex2e_escape) . "\n";
|
$_ = parse_data ($str, $char_maps, $latex2e_escape);
|
||||||
|
if ($remove_comment)
|
||||||
|
{
|
||||||
|
s/(\s+\\n)+//;
|
||||||
|
}
|
||||||
|
print $outfile "-" . $_ . "\n";
|
||||||
}
|
}
|
||||||
elsif (/^A/)
|
elsif (/^A/)
|
||||||
{
|
{
|
||||||
|
@ -111,9 +149,12 @@ $latex2e->{preASP} = sub
|
||||||
if ($type eq "CDATA")
|
if ($type eq "CDATA")
|
||||||
{
|
{
|
||||||
# CDATA attributes get translated also
|
# CDATA attributes get translated also
|
||||||
if ($name eq "URL" or $name eq "ID")
|
if ($name eq "URL" or $name eq "ID" or $name eq "CA")
|
||||||
{
|
{
|
||||||
# URL for url.sty is a kind of verbatim...
|
# URL for url.sty is a kind of verbatim...
|
||||||
|
# CA is used in "tabular" element.
|
||||||
|
# Thanks to Evgeny Stambulchik, he posted this fix
|
||||||
|
# on sgml-tools list. 2000 May 17, t.sano
|
||||||
my $old_verb = $in_verb;
|
my $old_verb = $in_verb;
|
||||||
$in_verb = 1;
|
$in_verb = 1;
|
||||||
$value = parse_data ($value, $ascii_char_maps,
|
$value = parse_data ($value, $ascii_char_maps,
|
||||||
|
@ -141,6 +182,19 @@ $latex2e->{preASP} = sub
|
||||||
$in_verb = 0;
|
$in_verb = 0;
|
||||||
$char_maps = $tex_char_maps;
|
$char_maps = $tex_char_maps;
|
||||||
}
|
}
|
||||||
|
elsif (/^\((HEADING|ABSTRACT)/)
|
||||||
|
{
|
||||||
|
print $outfile $_;
|
||||||
|
# empty lines (comment in sgml source) do harm
|
||||||
|
# in HEADING or ABSTRACT
|
||||||
|
$remove_comment = 1;
|
||||||
|
}
|
||||||
|
elsif (/^\)(HEADING|ABSTRACT)/)
|
||||||
|
{
|
||||||
|
print $outfile $_;
|
||||||
|
# leaving HEADING or ABSTRACT section
|
||||||
|
$remove_comment = 0;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $outfile $_;
|
print $outfile $_;
|
||||||
|
@ -148,6 +202,24 @@ $latex2e->{preASP} = sub
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# return the string of the name of the macro for urldef
|
||||||
|
sub latex2e_defnam($)
|
||||||
|
{
|
||||||
|
my ($num) = @_;
|
||||||
|
|
||||||
|
if ($num > 26*26*26) {
|
||||||
|
die "Too many URLs!\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $anum = ord("a");
|
||||||
|
|
||||||
|
my $defnam = chr ($anum + ($num / 26 / 26)) .
|
||||||
|
chr ($anum + ($num / 26 % 26)) .
|
||||||
|
chr ($anum + ($num % 26));
|
||||||
|
|
||||||
|
return ($defnam);
|
||||||
|
};
|
||||||
|
|
||||||
#
|
#
|
||||||
# Take the sgmlsasp output, and make something
|
# Take the sgmlsasp output, and make something
|
||||||
# useful from it.
|
# useful from it.
|
||||||
|
@ -156,29 +228,117 @@ $latex2e->{postASP} = sub
|
||||||
{
|
{
|
||||||
my $infile = shift;
|
my $infile = shift;
|
||||||
my $filename = $global->{filename};
|
my $filename = $global->{filename};
|
||||||
$ENV{TEXINPUTS} .= ":$main::LibDir";
|
my $tmplatexdir = $global->{tmpbase} . "-latex-" . $$ . ".dir";
|
||||||
|
my $tmplatexnam = $tmplatexdir . "/" . $filename;
|
||||||
|
my @epsfiles = ();
|
||||||
|
my @texlines = ();
|
||||||
|
my @urldefines = ();
|
||||||
|
my @urlnames = ();
|
||||||
|
my $urlnum = 0;
|
||||||
|
my $tmpepsf;
|
||||||
|
my $saved_umask = umask;
|
||||||
|
$ENV{TEXINPUTS} .= ":$main::DataDir";
|
||||||
|
|
||||||
|
umask 0077;
|
||||||
|
mkdir ($tmplatexdir, 0700) || return -1;
|
||||||
|
|
||||||
#
|
#
|
||||||
# Set the correct \documentclass options. The if statement is just
|
# check epsfile is specified in source file
|
||||||
# a small optimization.
|
# check nameurl specified in source file
|
||||||
|
#
|
||||||
|
{
|
||||||
|
my $epsf;
|
||||||
|
open SGMLFILE, "<$filename.sgml";
|
||||||
|
while (<SGMLFILE>)
|
||||||
|
{
|
||||||
|
# for epsfile
|
||||||
|
if ( s/^\s*<eps\s+file=(.*)>/$1/ )
|
||||||
|
{
|
||||||
|
s/\s+angle=.*//;
|
||||||
|
s/\s+height=.*//;
|
||||||
|
s/\"//g;
|
||||||
|
$epsf = $_;
|
||||||
|
chop ( $epsf );
|
||||||
|
push @epsfiles, $epsf;
|
||||||
|
}
|
||||||
|
if ($latex2e->{output} eq "pdf")
|
||||||
|
{
|
||||||
|
if ( s/^\s*<img\s+src=(.*)>/$1/ )
|
||||||
|
{
|
||||||
|
s/\"//g;
|
||||||
|
$epsf = $_;
|
||||||
|
chop ( $epsf );
|
||||||
|
push @epsfiles, $epsf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close SGMLFILE;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
my $urlid;
|
||||||
|
my $urlnam;
|
||||||
|
my $urldef;
|
||||||
|
while (<$infile>)
|
||||||
|
{
|
||||||
|
push @texlines, $_;
|
||||||
|
# for nameurl
|
||||||
|
if ( /\\nameurl/ )
|
||||||
|
{
|
||||||
|
($urlid, $urlnam) = ($_ =~ /\\nameurl{(.*)}{(.*)}/);
|
||||||
|
print $urlnum . ": " . $urlid . "\n" if ( $global->{debug} );
|
||||||
|
|
||||||
|
$urldef = latex2e_defnam($urlnum) . "url";
|
||||||
|
s/\\nameurl{.*}{.*}/{\\em $urlnam} {\\tt \\$urldef}/;
|
||||||
|
push @urlnames, $_;
|
||||||
|
push @urldefines, "\\urldef{\\$urldef} \\url{$urlid}\n";
|
||||||
|
$urlnum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close $infile;
|
||||||
|
}
|
||||||
|
|
||||||
|
open OUTFILE, ">$tmplatexnam.tex";
|
||||||
|
#
|
||||||
|
# Set the correct \documentclass options.
|
||||||
#
|
#
|
||||||
if ($global->{language} ne "en" ||
|
|
||||||
$global->{papersize} ne "a4" ||
|
|
||||||
$latex2e->{pagenumber} != 1 ||
|
|
||||||
$global->{pass} ne "" ||
|
|
||||||
$latex2e->{makeindex})
|
|
||||||
{
|
{
|
||||||
my $langlit = ISO2English ($global->{language});
|
my $langlit = ISO2English ($global->{language});
|
||||||
$langlit = ($langlit eq 'english') ? "" : ",$langlit";
|
$langlit = ($langlit eq 'english') ? "" : ",$langlit";
|
||||||
my $replace = $global->{papersize} . 'paper' . $langlit;
|
my $replace = $global->{papersize} . 'paper' . $langlit;
|
||||||
open OUTFILE, ">$filename.tex";
|
my $hlatexopt = "";
|
||||||
while (<$infile>)
|
$global->{charset} = "nippon" if ($global->{language} eq "ja");
|
||||||
|
$global->{charset} = "euc-kr" if ($global->{language} eq "ko");
|
||||||
|
$replace = $global->{papersize} . 'paper' if ($global->{charset} eq "nippon") || ($global->{charset} eq "euc-kr");
|
||||||
|
while (defined($texlines[0]))
|
||||||
{
|
{
|
||||||
|
$_ = shift @texlines;
|
||||||
if (/^\\documentclass/)
|
if (/^\\documentclass/)
|
||||||
{
|
{
|
||||||
s/\\documentclass\[.*\]/\\documentclass\[$replace\]/;
|
if ($global->{language} ne "en" ||
|
||||||
|
$global->{papersize} ne "a4")
|
||||||
|
{
|
||||||
|
s/\\documentclass\[.*\]/\\documentclass\[$replace\]/;
|
||||||
|
}
|
||||||
|
if ($global->{charset} eq "nippon") {
|
||||||
|
if ($latex2e->{latex} eq "platex") {
|
||||||
|
s/{article}/{jarticle}/;
|
||||||
|
} elsif ($latex2e->{latex} eq "jlatex") {
|
||||||
|
s/{article}/{j-article}/;
|
||||||
|
}
|
||||||
|
}
|
||||||
$_ = $_ . "\\makeindex\n" if ($latex2e->{makeindex});
|
$_ = $_ . "\\makeindex\n" if ($latex2e->{makeindex});
|
||||||
}
|
}
|
||||||
|
if (/^\\usepackage.epsfig/ && ($global->{charset} eq "euc-kr"))
|
||||||
|
{
|
||||||
|
$hlatexopt = "[noautojosa]" if ($latex2e->{latex} eq "hlatexp");
|
||||||
|
$_ = $_ . "\\usepackage" . "$hlatexopt" . "{hangul}\n"
|
||||||
|
}
|
||||||
|
if ((/\\usepackage.t1enc/) &&
|
||||||
|
(($global->{charset} eq "nippon") ||
|
||||||
|
($global->{charset} eq "euc-kr")))
|
||||||
|
{
|
||||||
|
s/^/%%/;
|
||||||
|
}
|
||||||
if (/%end-preamble/)
|
if (/%end-preamble/)
|
||||||
{
|
{
|
||||||
if ($latex2e->{pagenumber})
|
if ($latex2e->{pagenumber})
|
||||||
|
@ -192,20 +352,45 @@ $latex2e->{postASP} = sub
|
||||||
}
|
}
|
||||||
$_ = $_ . $global->{pass} . "\n" if ($global->{pass});
|
$_ = $_ . $global->{pass} . "\n" if ($global->{pass});
|
||||||
}
|
}
|
||||||
|
if (/\\nameurl/ && $latex2e->{output} ne "pdf")
|
||||||
|
{
|
||||||
|
$_ = shift @urlnames;
|
||||||
|
}
|
||||||
print OUTFILE;
|
print OUTFILE;
|
||||||
|
if (/%end-preamble/)
|
||||||
|
{
|
||||||
|
if ($urlnum && $latex2e->{output} ne "pdf")
|
||||||
|
{
|
||||||
|
while (defined($urldefines[0]))
|
||||||
|
{
|
||||||
|
$_ = shift @urldefines;
|
||||||
|
print OUTFILE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
close OUTFILE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
copy ($infile, "$filename.tex");
|
|
||||||
}
|
}
|
||||||
|
close OUTFILE;
|
||||||
|
|
||||||
#
|
#
|
||||||
# LaTeX, dvips, and assorted cleanups.
|
# LaTeX, dvips, and assorted cleanups.
|
||||||
#
|
#
|
||||||
if ($latex2e->{output} eq "tex")
|
if ($latex2e->{output} eq "tex")
|
||||||
{
|
{
|
||||||
|
# comment out, because this backup action is not documented yet.
|
||||||
|
#
|
||||||
|
# if ( -e "$filename.tex" ) {
|
||||||
|
# rename ("$filename.tex", "$filename.tex.back");
|
||||||
|
# }
|
||||||
|
|
||||||
|
umask $saved_umask;
|
||||||
|
copy ("$tmplatexnam.tex", "$filename.tex");
|
||||||
|
if ( ! $global->{debug} )
|
||||||
|
{
|
||||||
|
unlink ("$tmplatexnam.tex");
|
||||||
|
rmdir ($tmplatexdir) || return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,30 +400,169 @@ $latex2e->{postASP} = sub
|
||||||
# references have been resolved. This avoids large numbers of
|
# references have been resolved. This avoids large numbers of
|
||||||
# spurious warnings.
|
# spurious warnings.
|
||||||
#
|
#
|
||||||
my ($latexcommand) = "latex '\\nonstopmode\\input{$filename.tex}'";
|
my $current_dir;
|
||||||
|
chop ($current_dir = `pwd`);
|
||||||
|
print $current_dir . "\n" if ( $global->{debug} );
|
||||||
|
|
||||||
|
#
|
||||||
|
# copy epsfiles specified in tex file
|
||||||
|
#
|
||||||
|
for my $epsf ( @epsfiles )
|
||||||
|
{
|
||||||
|
$tmpepsf = $tmplatexdir . "/" . $epsf;
|
||||||
|
print $epsf . " " . $tmpepsf . "\n" if ( $global->{debug} );
|
||||||
|
copy ("$epsf", "$tmpepsf") or die "can not copy graphics\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# go to the temporary directory
|
||||||
|
chdir ($tmplatexdir);
|
||||||
|
|
||||||
|
my ($latexcommand) = "$latex2e->{latex} '\\nonstopmode\\input{$filename.tex}'";
|
||||||
|
|
||||||
|
#
|
||||||
|
# We run pdflatex instead of latex if user selected pdf output
|
||||||
|
#
|
||||||
|
if ($latex2e->{output} eq "pdf")
|
||||||
|
{
|
||||||
|
$latexcommand = "pdflatex '\\nonstopmode\\input{$filename.tex}'";
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# run hlatex if hlatexp is used
|
||||||
|
# for pdf: how about status?(for hlatex and hlatexp)
|
||||||
|
#
|
||||||
|
if ($latex2e->{latex} eq "hlatexp")
|
||||||
|
{
|
||||||
|
#$latex2e->{output} = "ps" if ($latex2e->{output} eq "pdf");
|
||||||
|
$latexcommand = "hlatex '\\nonstopmode\\input{$filename.tex}'";
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# We use jlatex for Japanese encoded (euc-jp) characters.
|
||||||
|
# pdf support for Japanese are not yet. use ps for the time being.
|
||||||
|
#
|
||||||
|
if ($global->{charset} eq "nippon")
|
||||||
|
{
|
||||||
|
$latex2e->{output} = "ps" if ($latex2e->{output} eq "pdf");
|
||||||
|
$latexcommand = "$latex2e->{latex} '\\nonstopmode\\input{$filename.tex}'"
|
||||||
|
}
|
||||||
my ($suppress) = $latex2e->{quick} ? "" : ' >/dev/null';
|
my ($suppress) = $latex2e->{quick} ? "" : ' >/dev/null';
|
||||||
|
|
||||||
system $latexcommand . $suppress || die "LaTeX problem\n";
|
system $latexcommand . $suppress || die "LaTeX problem\n";
|
||||||
$latex2e->{bibtex} && system "bibtex $filename.tex";
|
$latex2e->{bibtex} && system "bibtex $filename.tex";
|
||||||
$latex2e->{quick} || system $latexcommand . ' >/dev/null';
|
$latex2e->{quick} || system $latexcommand . ' >/dev/null';
|
||||||
$latex2e->{quick} || system $latexcommand;
|
$latex2e->{quick} || system $latexcommand;
|
||||||
if ($global->{debug} == 0)
|
if ( ! $global->{debug} )
|
||||||
{
|
{
|
||||||
my @suffixes = qw(log blg aux toc lof lot dlog bbl);
|
my @suffixes = qw(log blg aux toc lof lot dlog bbl out);
|
||||||
for my $suf (@suffixes)
|
for my $suf (@suffixes)
|
||||||
{
|
{
|
||||||
unlink "$filename.$suf";
|
unlink "$tmplatexnam.$suf";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#
|
||||||
|
# go back to the working directory
|
||||||
|
chdir ($current_dir);
|
||||||
|
#
|
||||||
|
# output dvi file
|
||||||
if ($latex2e->{output} eq "dvi")
|
if ($latex2e->{output} eq "dvi")
|
||||||
{
|
{
|
||||||
$global->{debug} || unlink "$filename.tex";
|
# comment out, because this backup action is not documented yet.
|
||||||
|
#
|
||||||
|
# if ( -e "$filename.dvi" )
|
||||||
|
# {
|
||||||
|
# rename ("$filename.dvi", "$filename.dvi.back");
|
||||||
|
# }
|
||||||
|
umask $saved_umask;
|
||||||
|
copy ("$tmplatexnam.dvi", "$filename.dvi");
|
||||||
|
if ( $global->{debug} )
|
||||||
|
{
|
||||||
|
print "Temporary files are in $tmplatexdir\n";
|
||||||
|
print "Please check there and remove them manually.\n";
|
||||||
|
} else {
|
||||||
|
unlink ("$tmplatexnam.tex", "$tmplatexnam.dvi");
|
||||||
|
for my $epsf ( @epsfiles )
|
||||||
|
{
|
||||||
|
$tmpepsf = $tmplatexdir . "/" . $epsf;
|
||||||
|
print $tmpepsf . "\n" if ( $global->{debug} );
|
||||||
|
unlink ("$tmpepsf");
|
||||||
|
}
|
||||||
|
rmdir ($tmplatexdir) || return -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
`dvips -q -t $global->{papersize} -o $filename.ps $filename.dvi`;
|
#
|
||||||
$global->{debug} || unlink ("$filename.dvi", "$filename.tex");
|
# output pdf file
|
||||||
|
if ($latex2e->{output} eq "pdf")
|
||||||
|
{
|
||||||
|
# comment out, because this backup action is not documented yet.
|
||||||
|
#
|
||||||
|
# if ( -e "$filename.pdf" )
|
||||||
|
# {
|
||||||
|
# rename ("$filename.pdf", "$filename.pdf.back");
|
||||||
|
# }
|
||||||
|
umask $saved_umask;
|
||||||
|
copy ("$tmplatexnam.pdf", "$filename.pdf");
|
||||||
|
if ( $global->{debug} )
|
||||||
|
{
|
||||||
|
print "Temporary files are in $tmplatexdir\n";
|
||||||
|
print "Please check there and remove them manually.\n";
|
||||||
|
} else {
|
||||||
|
unlink ("$tmplatexnam.tex", "$tmplatexnam.pdf");
|
||||||
|
for my $epsf ( @epsfiles )
|
||||||
|
{
|
||||||
|
$tmpepsf = $tmplatexdir . "/" . $epsf;
|
||||||
|
print $tmpepsf . "\n" if ( $global->{debug} );
|
||||||
|
unlink ("$tmpepsf");
|
||||||
|
}
|
||||||
|
rmdir ($tmplatexdir) || return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#
|
||||||
|
# convert dvi into ps using dvips command
|
||||||
|
chdir ($tmplatexdir);
|
||||||
|
if ($latex2e->{dvips} eq "dvi2ps")
|
||||||
|
{
|
||||||
|
`dvi2ps -q -o $global->{papersize} -c $tmplatexnam.ps $filename.dvi`;
|
||||||
|
}
|
||||||
|
elsif ($latex2e->{dvips} eq "jdvi2kps")
|
||||||
|
{
|
||||||
|
`jdvi2kps -q -pa $global->{papersize} -o $tmplatexnam.ps $filename.dvi`;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
`dvips -R -q -t $global->{papersize} -o $tmplatexnam.ps $filename.dvi`;
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir ($current_dir);
|
||||||
|
|
||||||
|
# comment out, because this backup action is not documented yet.
|
||||||
|
#
|
||||||
|
# if ( -e "$filename.ps" )
|
||||||
|
# {
|
||||||
|
# rename ("$filename.ps", "$filename.ps.back");
|
||||||
|
# }
|
||||||
|
umask $saved_umask;
|
||||||
|
copy ("$tmplatexnam.ps", "$filename.ps");
|
||||||
|
unlink ("$tmplatexnam.ps");
|
||||||
|
if ( $global->{debug} )
|
||||||
|
{
|
||||||
|
print "Temporary files are in $tmplatexdir\n";
|
||||||
|
print "Please check there and remove them manually.\n";
|
||||||
|
} else {
|
||||||
|
unlink ("$tmplatexnam.tex", "$tmplatexnam.dvi", "$tmplatexnam.ps");
|
||||||
|
for my $epsf ( @epsfiles )
|
||||||
|
{
|
||||||
|
$tmpepsf = $tmplatexdir . "/" . $epsf;
|
||||||
|
print $tmpepsf . "\n" if ( $global->{debug} );
|
||||||
|
unlink ("$tmpepsf");
|
||||||
|
}
|
||||||
|
rmdir ($tmplatexdir) || return -1;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
176
doc/sbase/dist/fmt_txt.pl
vendored
176
doc/sbase/dist/fmt_txt.pl
vendored
|
@ -7,24 +7,27 @@
|
||||||
#
|
#
|
||||||
# © Copyright 1996, Cees de Groot
|
# © Copyright 1996, Cees de Groot
|
||||||
#
|
#
|
||||||
package SGMLTools::fmt_txt;
|
package LinuxDocTools::fmt_txt;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
use File::Copy;
|
use File::Copy;
|
||||||
use Text::EntityMap;
|
use Text::EntityMap;
|
||||||
use SGMLTools::CharEnts;
|
use LinuxDocTools::CharEnts;
|
||||||
use SGMLTools::Lang;
|
use LinuxDocTools::Lang;
|
||||||
use SGMLTools::Vars;
|
use LinuxDocTools::Vars;
|
||||||
|
use LinuxDocTools::Utils qw(create_temp);
|
||||||
|
|
||||||
my $txt = {};
|
my $txt = {};
|
||||||
$txt->{NAME} = "txt";
|
$txt->{NAME} = "txt";
|
||||||
$txt->{HELP} = "";
|
$txt->{HELP} = "";
|
||||||
$txt->{OPTIONS} = [
|
$txt->{OPTIONS} = [
|
||||||
{ option => "manpage", type => "f", short => "m" },
|
{ 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->{manpage} = 0;
|
||||||
$txt->{filter} = 0;
|
$txt->{filter} = 0;
|
||||||
|
$txt->{blanks} = 3;
|
||||||
|
|
||||||
$Formats{$txt->{NAME}} = $txt;
|
$Formats{$txt->{NAME}} = $txt;
|
||||||
|
|
||||||
|
@ -44,19 +47,26 @@ $txt->{preNSGMLS} = sub
|
||||||
$global->{charset} = "latin1" if $global->{charset} eq "latin";
|
$global->{charset} = "latin1" if $global->{charset} eq "latin";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Is there a cleaner solution than this? Can't do it earlier,
|
# Is there a cleaner solution than this? Can't do it earlier,
|
||||||
# would show up in the help messages...
|
# would show up in the help messages...
|
||||||
#
|
#
|
||||||
|
# the language support ja.
|
||||||
|
# the charset support nippon.
|
||||||
|
#
|
||||||
$global->{format} = $global->{charset};
|
$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 "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}/;
|
$ENV{SGML_SEARCH_PATH} =~ s/txt/$global->{format}/;
|
||||||
|
|
||||||
$Formats{"groff"} = $txt;
|
$Formats{"groff"} = $txt;
|
||||||
$Formats{"latin1"} = $txt;
|
$Formats{"latin1"} = $txt;
|
||||||
$Formats{"man"} = $txt;
|
$Formats{"man"} = $txt;
|
||||||
|
|
||||||
return 0;
|
$global->{NsgmlsPrePipe} = "cat $global->{file} " ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,16 +91,48 @@ $txt->{preASP} = sub
|
||||||
{
|
{
|
||||||
my ($infile, $outfile) = @_;
|
my ($infile, $outfile) = @_;
|
||||||
my (@toc, @lines);
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# note the conversion of `sdata_dirs' list to an anonymous array to
|
# note the conversion of `sdata_dirs' list to an anonymous array to
|
||||||
# make a single argument
|
# 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
|
# 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, ")P\n");
|
||||||
push (@toc, "(VERB\n");
|
push (@toc, "(VERB\n");
|
||||||
my (@prevheader, @header);
|
my (@prevheader, @header);
|
||||||
|
my $appendix = 0;
|
||||||
|
my $nonprint = 0;
|
||||||
while (<$infile>)
|
while (<$infile>)
|
||||||
{
|
{
|
||||||
push (@lines, $_);
|
push (@lines, $_);
|
||||||
|
@ -111,16 +155,27 @@ $txt->{preASP} = sub
|
||||||
{
|
{
|
||||||
@prevheader = @header;
|
@prevheader = @header;
|
||||||
@header = @header[0..$1];
|
@header = @header[0..$1];
|
||||||
$header[$1]++;
|
if ($appendix == 1)
|
||||||
|
{
|
||||||
|
$header[$1] = "A";
|
||||||
|
$appendix = 0;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
$header[$1]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (/^\(APPEND(.*)/)
|
||||||
|
{
|
||||||
|
$appendix = 1;
|
||||||
}
|
}
|
||||||
if (/^\(HEADING/)
|
if (/^\(HEADING/)
|
||||||
{
|
{
|
||||||
$_ = <$infile>;
|
$_ = <$infile>;
|
||||||
|
s/\\n/ /g;
|
||||||
push (@lines, $_);
|
push (@lines, $_);
|
||||||
chop;
|
chop;
|
||||||
s/^-//;
|
s/^-//;
|
||||||
$_ = join(".",@header) . " " . $_;
|
$_ = join(".",@header) . " " . $_;
|
||||||
s/\\n/ /g;
|
|
||||||
s/\(\\[0-9][0-9][0-9]\)/\\\1/g;
|
s/\(\\[0-9][0-9][0-9]\)/\\\1/g;
|
||||||
|
|
||||||
if (!$#header)
|
if (!$#header)
|
||||||
|
@ -130,14 +185,62 @@ $txt->{preASP} = sub
|
||||||
$_ = "\\n" . $_ unless (!$#prevheader);
|
$_ = "\\n" . $_ unless (!$#prevheader);
|
||||||
# put a . and a space after top level sections
|
# put a . and a space after top level sections
|
||||||
s/ /. /;
|
s/ /. /;
|
||||||
$_ = "-" . $_ . "\\n";
|
##### $_ = "-" . $_ . "\\n";
|
||||||
|
$_ = "-" . $_;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
# subsections get indentation matching hierarchy
|
# subsections get indentation matching hierarchy
|
||||||
$_ = "-" . " " x $#header . $_;
|
$_ = "-" . " " 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, ")VERB\n");
|
||||||
|
@ -233,8 +336,9 @@ $txt->{postASP} = sub
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
create_temp("$global->{tmpbase}.txt.1");
|
||||||
$outfile = new FileHandle
|
$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");
|
$outfile->open (">$global->{filename}.txt");
|
||||||
$groffout = new FileHandle "<$global->{tmpbase}.txt.1";
|
$groffout = new FileHandle "<$global->{tmpbase}.txt.1";
|
||||||
|
my $count = 0;
|
||||||
if ($txt->{filter})
|
if ($txt->{filter})
|
||||||
{
|
{
|
||||||
while (<$groffout>)
|
while (<$groffout>)
|
||||||
{
|
{
|
||||||
|
s/[^\cH][^\cH]\cH\cH//g;
|
||||||
s/.//g;
|
s/.//g;
|
||||||
print $outfile $_;
|
if ($txt->{blanks})
|
||||||
|
{
|
||||||
|
$count = &{$txt->{cutblank}}($count, $outfile, $_);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $outfile $_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
copy ($groffout, $outfile);
|
if ($txt->{blanks})
|
||||||
|
{
|
||||||
|
while (<$groffout>)
|
||||||
|
{
|
||||||
|
$count = &{$txt->{cutblank}}($count, $outfile, $_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
copy ($groffout, $outfile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$groffout->close;
|
$groffout->close;
|
||||||
|
@ -284,4 +407,23 @@ $txt->{postASP} = sub
|
||||||
return 0;
|
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;
|
1;
|
||||||
|
|
|
@ -15,30 +15,32 @@ sub BEGIN
|
||||||
}
|
}
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
use vars qw($prefix $LibDir $BinDir $progs);
|
use vars qw($prefix $DataDir $BinDir $progs);
|
||||||
|
|
||||||
$prefix = "/usr";
|
$prefix = "/usr";
|
||||||
$LibDir = "sbase";
|
$DataDir = "sbase";
|
||||||
$BinDir = "/usr/bin";
|
$BinDir = "/usr/bin";
|
||||||
|
|
||||||
use lib "/usr/lib/sgml-tools";
|
use lib "/usr/share/linuxdoc-tools";
|
||||||
use lib "/usr/perl5";
|
use lib "/usr/perl5";
|
||||||
use lib "/usr/lib/perl5";
|
use lib "/usr/lib/perl5";
|
||||||
|
use lib "/usr/share/perl5";
|
||||||
$progs = {
|
$progs = {
|
||||||
"NSGMLS" => "/usr/bin/nsgmls",
|
"NSGMLS" => "/usr/bin/nsgmls",
|
||||||
"SGMLSASP" => "/usr/bin/sgmlsasp",
|
"SGMLSASP" => "/usr/bin/sgmlsasp",
|
||||||
"GROFF" => "/usr/bin/groff",
|
"GROFF" => "/usr/bin/groff",
|
||||||
"GROFFMACRO" => "-mgs"
|
"GROFFMACRO" => "-ms",
|
||||||
|
"AWK" => "/usr/share/linuxdoc-tools/awkwhich"
|
||||||
};
|
};
|
||||||
|
$ENV{"SGML_CATALOG_FILES"} = "sbase/dtd/catalog";
|
||||||
|
|
||||||
require SGMLTools;
|
require "./LinuxDocTools.pm";
|
||||||
&SGMLTools::init;
|
&LinuxDocTools::init;
|
||||||
|
|
||||||
my @FileList = SGMLTools::process_options ($0, @ARGV);
|
my @FileList = LinuxDocTools::process_options ("html", @ARGV);
|
||||||
for my $curfile (@FileList)
|
for my $curfile (@FileList)
|
||||||
{
|
{
|
||||||
SGMLTools::process_file ($curfile);
|
LinuxDocTools::process_file ($curfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit 0;
|
exit 0;
|
||||||
|
|
||||||
|
|
|
@ -15,30 +15,32 @@ sub BEGIN
|
||||||
}
|
}
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
use vars qw($prefix $LibDir $BinDir $progs);
|
use vars qw($prefix $DataDir $BinDir $progs);
|
||||||
|
|
||||||
$prefix = "/usr";
|
$prefix = "/usr";
|
||||||
$LibDir = "sbase";
|
$DataDir = "sbase";
|
||||||
$BinDir = "/usr/bin";
|
$BinDir = "/usr/bin";
|
||||||
|
|
||||||
use lib "/usr/lib/sgml-tools";
|
use lib "/usr/share/linuxdoc-tools";
|
||||||
use lib "/usr/perl5";
|
use lib "/usr/perl5";
|
||||||
use lib "/usr/lib/perl5";
|
use lib "/usr/lib/perl5";
|
||||||
|
use lib "/usr/share/perl5";
|
||||||
$progs = {
|
$progs = {
|
||||||
"NSGMLS" => "/usr/bin/nsgmls",
|
"NSGMLS" => "/usr/bin/nsgmls",
|
||||||
"SGMLSASP" => "/usr/bin/sgmlsasp",
|
"SGMLSASP" => "/usr/bin/sgmlsasp",
|
||||||
"GROFF" => "/usr/bin/groff",
|
"GROFF" => "/usr/bin/groff",
|
||||||
"GROFFMACRO" => "-mgs"
|
"GROFFMACRO" => "-ms",
|
||||||
|
"AWK" => "/usr/share/linuxdoc-tools/awkwhich"
|
||||||
};
|
};
|
||||||
|
$ENV{"SGML_CATALOG_FILES"} = "sbase/dtd/catalog";
|
||||||
|
|
||||||
require SGMLTools;
|
require "./LinuxDocTools.pm";
|
||||||
&SGMLTools::init;
|
&LinuxDocTools::init;
|
||||||
|
|
||||||
my @FileList = SGMLTools::process_options ($0, @ARGV);
|
my @FileList = LinuxDocTools::process_options ("latex", @ARGV);
|
||||||
for my $curfile (@FileList)
|
for my $curfile (@FileList)
|
||||||
{
|
{
|
||||||
SGMLTools::process_file ($curfile);
|
LinuxDocTools::process_file ($curfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit 0;
|
exit 0;
|
||||||
|
|
||||||
|
|
20
doc/sgml2txt
20
doc/sgml2txt
|
@ -15,30 +15,32 @@ sub BEGIN
|
||||||
}
|
}
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
use vars qw($prefix $LibDir $BinDir $progs);
|
use vars qw($prefix $DataDir $BinDir $progs);
|
||||||
|
|
||||||
$prefix = "/usr";
|
$prefix = "/usr";
|
||||||
$LibDir = "sbase";
|
$DataDir = "sbase";
|
||||||
$BinDir = "/usr/bin";
|
$BinDir = "/usr/bin";
|
||||||
|
|
||||||
use lib "/usr/lib/sgml-tools";
|
use lib "/usr/share/linuxdoc-tools";
|
||||||
use lib "/usr/perl5";
|
use lib "/usr/perl5";
|
||||||
use lib "/usr/lib/perl5";
|
use lib "/usr/lib/perl5";
|
||||||
|
use lib "/usr/share/perl5";
|
||||||
$progs = {
|
$progs = {
|
||||||
"NSGMLS" => "/usr/bin/nsgmls",
|
"NSGMLS" => "/usr/bin/nsgmls",
|
||||||
"SGMLSASP" => "/usr/bin/sgmlsasp",
|
"SGMLSASP" => "/usr/bin/sgmlsasp",
|
||||||
"GROFF" => "/usr/bin/groff",
|
"GROFF" => "/usr/bin/groff",
|
||||||
"GROFFMACRO" => "-mgs"
|
"GROFFMACRO" => "-ms",
|
||||||
|
"AWK" => "/usr/share/linuxdoc-tools/awkwhich"
|
||||||
};
|
};
|
||||||
|
$ENV{"SGML_CATALOG_FILES"} = "sbase/dtd/catalog";
|
||||||
|
|
||||||
require SGMLTools;
|
require "./LinuxDocTools.pm";
|
||||||
&SGMLTools::init;
|
&LinuxDocTools::init;
|
||||||
|
|
||||||
my @FileList = SGMLTools::process_options ($0, @ARGV);
|
my @FileList = LinuxDocTools::process_options ("txt", @ARGV);
|
||||||
for my $curfile (@FileList)
|
for my $curfile (@FileList)
|
||||||
{
|
{
|
||||||
SGMLTools::process_file ($curfile);
|
LinuxDocTools::process_file ($curfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
exit 0;
|
exit 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue