Code

added website to trunk
[rrdtool-all.git] / website / bin / fix-hrefs.pl
diff --git a/website/bin/fix-hrefs.pl b/website/bin/fix-hrefs.pl
new file mode 100755 (executable)
index 0000000..4b6701b
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/perl -w
+
+use strict;
+use HTML::Parser;
+
+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: $!");
+
+sub startsub {
+        my $tag = shift;
+        my $text = shift;
+        
+       if ($tag eq "a") {
+               $text =~ s,".*?/doc/,",;
+               $text =~ /^http:/ || $text =~ s,\.html,.en.html,;
+               $text =~ s/name=".+?"//;
+       }
+       print $text;
+}