mirror of https://github.com/tLDP/LDP
Ability to choose either SGML or XML DOCTYPE declaration
This commit is contained in:
parent
53ef43c772
commit
bb3da7f5b8
|
@ -10,3 +10,6 @@
|
|||
Lampadas and still get a complete DocBook file.
|
||||
|
||||
CVS Switched -V and -v, now -v is version, -V is verbose.
|
||||
Changed -a, --article to -x, --xml and -s, --sgml to
|
||||
let you pick your own doctype.
|
||||
|
||||
|
|
|
@ -25,7 +25,9 @@ specified as a command-line option.
|
|||
|
||||
=head1 OPTIONS
|
||||
|
||||
B<-a>, B<--article> wrap results in article tags and add DOCTYPE.
|
||||
B<-x>, B<--xml> add XML DOCTYPE and article tags.
|
||||
|
||||
B<-s>, B<--sgml> add SGML DOCTYPE and article tags.
|
||||
|
||||
B<-o>, B<--output-to> I<filename> write to the specified file.
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ sub new {
|
|||
}
|
||||
|
||||
sub ProcessFile {
|
||||
($self, $txtfile, $dbfile, $verbose, $article) = @_;
|
||||
($self, $txtfile, $dbfile, $verbose, $doctype) = @_;
|
||||
|
||||
# Read from STDIN if no input file given
|
||||
#
|
||||
|
@ -87,12 +87,18 @@ sub ProcessFile {
|
|||
|
||||
# wrap article if requested
|
||||
#
|
||||
if ($article) {
|
||||
$buf = '<?xml version="1.0" standalone="no"?>';
|
||||
$buf .= '<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.1//EN"' . "\n";
|
||||
$buf .= ' "http://docbook.org/xml/4.1.2/docbookx.dtd"[]>';
|
||||
if ($doctype eq 'XML') {
|
||||
print "Adding XML DOCTYPE and article tags." if ($verbose);
|
||||
$buf = '<?xml version="1.0" standalone="no"?>' . "\n";
|
||||
$buf .= '<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"' . "\n";
|
||||
$buf .= ' "http://docbook.org/xml/4.1.2/docbookx.dtd"';
|
||||
$buf .= "\[\]\>\n";
|
||||
$buf .= "\n";
|
||||
$buf .= '<article>' . "\n";
|
||||
} elsif ($doctype eq 'SGML') {
|
||||
print "Adding SGML DOCTYPE and article tags." if ($verbose);
|
||||
$buf = '<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook V4.1//EN">' . "\n";
|
||||
$buf .= '<article>' . "\n";
|
||||
}
|
||||
|
||||
# read in the text file
|
||||
|
@ -107,7 +113,7 @@ sub ProcessFile {
|
|||
|
||||
# wrap article if requested
|
||||
#
|
||||
if ($article) {
|
||||
if ($doctype) {
|
||||
$buf .= '</article>' . "\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -9,14 +9,18 @@ $WT2DB = new Wt2Db;
|
|||
|
||||
my $txtfile = '';
|
||||
my $dbfile = '';
|
||||
my $doctype = '';
|
||||
my $verbose = 0;
|
||||
my $error = 0;
|
||||
|
||||
# read in cmd-line arguments
|
||||
#
|
||||
while (1) {
|
||||
if($ARGV[0] eq "-a" or $ARGV[0] eq "--article") {
|
||||
$article = 1;
|
||||
if($ARGV[0] eq "-s" or $ARGV[0] eq "--sgml") {
|
||||
$doctype = 'SGML';
|
||||
shift(@ARGV);
|
||||
} elsif($ARGV[0] eq "-x" or $ARGV[0] eq "--xml") {
|
||||
$doctype = 'XML';
|
||||
shift(@ARGV);
|
||||
} elsif($ARGV[0] eq "-o" or $ARGV[0] eq "--output-to") {
|
||||
shift(@ARGV);
|
||||
|
@ -40,7 +44,7 @@ while (1) {
|
|||
}
|
||||
}
|
||||
|
||||
$WT2DB->ProcessFile($txtfile, $dbfile, $verbose, $article);
|
||||
$WT2DB->ProcessFile($txtfile, $dbfile, $verbose, $doctype);
|
||||
|
||||
sub version {
|
||||
print "wt2db version $VERSION\n";
|
||||
|
@ -58,7 +62,8 @@ sub usage {
|
|||
print "Usage: wt2db [OPTIONS] [FILE]\n";
|
||||
print "\n";
|
||||
print "Options:\n";
|
||||
print "-a, --article add DOCTYPE and article tags.\n";
|
||||
print "-s, --SGML add XML DOCTYPE and article tags.\n";
|
||||
print "-x, --XML add SGML DOCTYPE and article tags.\n";
|
||||
print "-o, --output-to write to the specified file.\n";
|
||||
print "-v, --verbose show diagnostic output.\n";
|
||||
print "-V, --version show program version.\n";
|
||||
|
|
Loading…
Reference in New Issue