2002-02-02 04:47:19 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
#
|
2002-05-05 21:56:12 +00:00
|
|
|
#Converts txt files into DocBook XML/SGML.
|
2002-02-02 04:47:19 +00:00
|
|
|
#
|
2002-05-25 16:14:15 +00:00
|
|
|
$VERSION = '0.4-cvs';
|
2002-05-01 17:59:52 +00:00
|
|
|
|
2002-04-06 13:13:21 +00:00
|
|
|
use Wt2Db;
|
|
|
|
$WT2DB = new Wt2Db;
|
2002-02-02 04:47:19 +00:00
|
|
|
|
2002-04-06 13:13:21 +00:00
|
|
|
my $txtfile = '';
|
|
|
|
my $dbfile = '';
|
|
|
|
my $verbose = 0;
|
|
|
|
my $error = 0;
|
2002-02-02 04:47:19 +00:00
|
|
|
|
|
|
|
# read in cmd-line arguments
|
|
|
|
#
|
|
|
|
while (1) {
|
2002-05-24 17:58:24 +00:00
|
|
|
if($ARGV[0] eq "-a" or $ARGV[0] eq "--article") {
|
|
|
|
$article = 1;
|
|
|
|
shift(@ARGV);
|
|
|
|
} elsif($ARGV[0] eq "-o" or $ARGV[0] eq "--output-to") {
|
2002-02-02 04:47:19 +00:00
|
|
|
shift(@ARGV);
|
|
|
|
$dbfile = $ARGV[0];
|
|
|
|
shift(@ARGV);
|
2002-05-25 22:45:48 +00:00
|
|
|
} elsif($ARGV[0] eq "-V" or $ARGV[0] eq "--verbose") {
|
2002-02-02 04:47:19 +00:00
|
|
|
$verbose++;
|
|
|
|
shift(@ARGV);
|
2002-05-25 22:45:48 +00:00
|
|
|
} elsif($ARGV[0] eq "-v" or $ARGV[0] eq "--version") {
|
2002-05-01 21:21:43 +00:00
|
|
|
&version();
|
|
|
|
exit(0);
|
|
|
|
} elsif($ARGV[0] eq "-h" or $ARGV[0] eq "--help") {
|
|
|
|
&usage();
|
2002-02-02 04:47:19 +00:00
|
|
|
} else {
|
|
|
|
$txtfile = $ARGV[0];
|
|
|
|
shift(@ARGV);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($ARGV[0] eq '') {
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-05-24 17:58:24 +00:00
|
|
|
$WT2DB->ProcessFile($txtfile, $dbfile, $verbose, $article);
|
2002-05-01 21:21:43 +00:00
|
|
|
|
|
|
|
sub version {
|
|
|
|
print "wt2db version $VERSION\n";
|
|
|
|
print "Copyright (c) 2001, 2002 David Merrill \<david\@lupercalia.net\>.\n";
|
|
|
|
print "\n";
|
2002-05-05 21:56:12 +00:00
|
|
|
print "Converts a WikiText file into DocBook XML/SGML.\n";
|
2002-05-01 21:21:43 +00:00
|
|
|
print "\n";
|
|
|
|
print "This is free software; see the source for copying conditions. There is no\n";
|
|
|
|
print "warranty; not even for merchantability or fitness for a particular purpose.\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub usage {
|
|
|
|
my $error = shift;
|
|
|
|
&version;
|
|
|
|
print "Usage: wt2db [OPTIONS] [FILE]\n";
|
|
|
|
print "\n";
|
|
|
|
print "Options:\n";
|
2002-05-24 17:58:24 +00:00
|
|
|
print "-a, --article add DOCTYPE and article tags.\n";
|
2002-05-01 21:21:43 +00:00
|
|
|
print "-o, --output-to write to the specified file.\n";
|
|
|
|
print "-v, --verbose show diagnostic output.\n";
|
|
|
|
print "-V, --version show program version.\n";
|
|
|
|
print "-h, --help show this usage message.\n";
|
|
|
|
exit($error);
|
|
|
|
}
|
|
|
|
|