2001-10-14 19:29:23 -05:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
2002-02-04 14:28:17 +10:00
|
|
|
sub fix_underscore {
|
2001-10-14 19:29:23 -05:00
|
|
|
$str = shift;
|
|
|
|
$str =~ tr/_/-/;
|
|
|
|
return $str;
|
|
|
|
};
|
|
|
|
|
2002-02-04 14:28:17 +10:00
|
|
|
sub strip_emph {
|
|
|
|
$str = shift;
|
|
|
|
$str =~ s{<emphasis>(.+?)</emphasis>}
|
|
|
|
{$1}gs;
|
|
|
|
return $str;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-10-14 19:29:23 -05:00
|
|
|
$data = join "", <STDIN>;
|
|
|
|
|
|
|
|
print STDERR "Changing @@ to @...\n";
|
|
|
|
$data =~ s/@@/@/gs;
|
|
|
|
|
|
|
|
print STDERR "Changing '_' to '-' in references...\n";
|
|
|
|
$data =~ s{id=\"(.+?)\"}
|
2002-02-04 14:28:17 +10:00
|
|
|
{"id=\"".&fix_underscore($1)."\""}gsex;
|
2001-10-14 19:29:23 -05:00
|
|
|
$data =~ s{linkend=\"(.+?)\"}
|
2002-02-04 14:28:17 +10:00
|
|
|
{"linkend=\"".&fix_underscore($1)."\""}gsex;
|
2001-10-14 19:29:23 -05:00
|
|
|
|
|
|
|
print STDERR "Changing ULINK to SYSTEMITEM...\n";
|
|
|
|
$data =~ s{<ulink url=\"(.+?)\"></ulink>}
|
|
|
|
{<systemitem role=\"url\">$1</systemitem>}gs;
|
|
|
|
|
|
|
|
print STDERR "Removing INFORMALFIGURE...\n";
|
|
|
|
$data =~ s{<informalfigure>(.+?)</informalfigure>}
|
|
|
|
{}gs;
|
|
|
|
|
|
|
|
print STDERR "Adding PARA inside ENTRY...\n";
|
2002-02-04 14:28:17 +10:00
|
|
|
$data =~ s{<entry>(.*?)</entry>}
|
2001-10-14 19:29:23 -05:00
|
|
|
{<entry><para>$1</para></entry>}gs;
|
|
|
|
|
2001-11-28 22:11:14 +02:00
|
|
|
print STDERR "Removing mailto: from email addresses...\n";
|
|
|
|
$data =~ s{mailto:}
|
|
|
|
{}gs;
|
|
|
|
|
|
|
|
print STDERR "Fixing spacing problem with titles...\n";
|
2001-11-28 22:16:26 +02:00
|
|
|
$data =~ s{</(\w+)>(\w{2,})}
|
2001-11-28 22:11:14 +02:00
|
|
|
{</$1> $2}gs;
|
|
|
|
|
2002-01-30 17:44:47 +10:00
|
|
|
# 2002-01-30 arjen@mysql.com
|
|
|
|
print STDERR "Removing COLSPEC...\n";
|
|
|
|
$data =~ s{\n *<colspec colwidth=\"[0-9]+\*\">}
|
|
|
|
{}gs;
|
|
|
|
|
2002-02-04 14:28:17 +10:00
|
|
|
# 2002-01-31 arjen@mysql.com
|
|
|
|
print STDERR "Making first row in table THEAD...\n";
|
|
|
|
$data =~ s{([ ]*)<tbody>\n([ ]*<row>(.+?)</row>)}
|
|
|
|
{$1<thead>\n$2\n$1</thead>\n$1<tbody>}gs;
|
|
|
|
|
|
|
|
# 2002-01-31 arjen@mysql.com
|
|
|
|
print STDERR "Removing EMPHASIS inside THEAD...\n";
|
|
|
|
$data =~ s{<thead>(.+?)</thead>}
|
|
|
|
{"<thead>".&strip_emph($1)."</thead>"}gsex;
|
|
|
|
|
|
|
|
# 2002-01-31 arjen@mysql.com
|
|
|
|
print STDERR "Removing lf before /PARA in ENTRY...\n";
|
|
|
|
$data =~ s{(<entry><para>(.+?))\n(</para></entry>)}
|
|
|
|
{$1$3}gs;
|
|
|
|
|
|
|
|
# 2002-01-31 arjen@mysql.com
|
|
|
|
print STDERR "Removing whitespace before /PARA...\n";
|
|
|
|
$data =~ s{[ ]+</para>}
|
|
|
|
{</para>}gs;
|
|
|
|
|
|
|
|
# 2002-01-31 arjen@mysql.com
|
|
|
|
print STDERR "Removing empty PARA in ENTRY...\n";
|
|
|
|
$data =~ s{<entry><para></para></entry>}
|
|
|
|
{<entry></entry>}gs;
|
|
|
|
|
|
|
|
# 2002-01-31 arjen@mysql.com
|
|
|
|
print STDERR "Removing PARA around INDEXENTRY if no text in PARA...\n";
|
|
|
|
$data =~ s{<para>((<indexterm role=\"(cp|fn)\">(<(primary|secondary)>[^<]+?</(primary|secondary)>)+?</indexterm>)+?)[\n]*</para>[\n]*}
|
|
|
|
{$1\n}gs;
|
|
|
|
|
|
|
|
# -----
|
|
|
|
|
2001-11-01 16:18:05 +10:00
|
|
|
@apx = ("Users", "MySQL Testimonials", "News",
|
2001-10-17 18:49:39 -05:00
|
|
|
"GPL-license", "LGPL-license");
|
2001-10-14 19:29:23 -05:00
|
|
|
|
|
|
|
foreach $apx (@apx) {
|
|
|
|
print STDERR "Removing appendix $apx...\n";
|
|
|
|
$data =~ s{<appendix id=\"$apx\">(.+?)</appendix>}
|
|
|
|
{}gs;
|
2001-11-28 22:11:14 +02:00
|
|
|
|
|
|
|
print STDERR " ... Building list of removed nodes ...\n";
|
|
|
|
foreach(split "\n", $&) {
|
|
|
|
push @nodes, $2 if(/<(\w+) id=\"(.+?)\">/)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
print STDERR "Fixing references to removed nodes...\n";
|
|
|
|
foreach $node (@nodes) {
|
|
|
|
$web = $node;
|
|
|
|
$web =~ s/[ ]/_/;
|
|
|
|
$web = "http://www.mysql.com/doc/" .
|
|
|
|
(join "/", (split //, $web)[0..1])."/$web.html";
|
|
|
|
print STDERR "$node -> $web\n";
|
|
|
|
$data =~ s{<(\w+) linkend=\"$node\">}
|
|
|
|
{$web}gs;
|
2001-10-14 19:29:23 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
print STDOUT $data;
|