X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=website%2Fbin%2Ffix-pod2html.pl;fp=website%2Fbin%2Ffix-pod2html.pl;h=a48eb7c328f8cb4966a97f9e998c90627f6d8b52;hb=d1e370000219d7f46144fcda05ff6884da89042f;hp=0000000000000000000000000000000000000000;hpb=ea3ebe6e517f024dd6c2a36898082ae4855becf7;p=rrdtool-all.git
diff --git a/website/bin/fix-pod2html.pl b/website/bin/fix-pod2html.pl
new file mode 100755
index 00000000..a48eb7c3
--- /dev/null
+++ b/website/bin/fix-pod2html.pl
@@ -0,0 +1,87 @@
+#!/usr/bin/perl -w
+
+use strict;
+use HTML::Parser;
+
+# fix pod2html output:
+# v1.0: defer and tags until
+# the next
, or
+
+# v1.1: don't nest any elements;
+# end one before beginning another
+
+# v1.2: insert tags if occurs
+# inside -
+
+# v1.3: anchors must not start with a digit;
+# insert a letter "N" at the start if they do
+
+# v1.4: insert the "N" letter into too.
+
+my $p = HTML::Parser->new(api_version => 3);
+$p->handler(start => \&startsub, 'tagname, text');
+$p->handler(end => \&endsub, 'tagname, text');
+$p->handler(default => sub { print shift() }, 'text');
+$p->parse_file(shift||"-") or die("parse: $!");
+
+my @ddstack;
+my @listack;
+my $a=0;
+
+sub startsub {
+ my $tag = shift;
+ my $text = shift;
+ if ($tag eq "dl") {
+ if (@ddstack and $ddstack[0] eq "dt") {
+ $ddstack[0] = "dd";
+ print "
- ";
+ }
+ unshift @ddstack, 0;
+ }
+ if ($tag =~ /^[uo]l$/) {
+ unshift @listack, 0;
+ }
+ if (($tag eq "dt" or $tag eq "dd") and $ddstack[0]) {
+ print "$ddstack[0]>";
+ $ddstack[0] = 0;
+ }
+ if (($tag eq "li") and $listack[0]) {
+ print "$listack[0]>";
+ $listack[0] = 0;
+ }
+ if ($tag eq "a") {
+ if ($a) {
+ print "
";
+ } else {
+ $a++;
+ }
+ $text =~ s/(name="|href="#)(\d)/$1N$2/;
+ }
+ print $text;
+}
+
+
+sub endsub {
+ my $tag = shift;
+ my $text = shift;
+ if ($tag eq "dl") {
+ print "$ddstack[0]>" if $ddstack[0];
+ shift @ddstack;
+ } elsif ($tag =~ /^[uo]l$/) {
+ print "$listack[0]>" if $listack[0];
+ shift @listack;
+ }
+
+ if ($tag eq "a") {
+ if ($a) {
+ print "";
+ $a--;
+ }
+ } elsif ($tag eq "dd" or $tag eq "dt") {
+ $ddstack[0] = $tag;
+ } elsif ($tag eq "li") {
+ $listack[0] = $tag;
+ } else {
+ print $text;
+ }
+}