#!/usr/bin/perl # # Format XHTML generated by pod2html (via tidy) for websites # # Usage: tidy ... pydoc.html | fix-python-xhtml OUTPUT-FILE # # (C) Copyright 2002 Dave Beckett - http://www.dajobe.org/ # University of Bristol # use strict; use File::Basename; my $progname=basename $0; my $main_title="Redland RDF Application Framework"; my $doc_title="Python API Reference"; die "USAGE: $progname OUTPUT-FILE\n" if @ARGV < 1; my($file)=@ARGV; my($pod_rdf_rel)=($file =~ m%^pod/RDF/%) ? '../' : ''; my($pod_rdf_redland_rel)=($file =~ m%^pod/RDF/Redland/%) ? '' : 'Redland/'; my $skip_heading=0; open(OUT, ">$file") or die "$progname: Cannot create $file - $!\n"; print OUT qq{\n}; open(IN, "-"); while() { if(m%(.*?)%) { s%(.*?)%$main_title - $doc_title%; } next if /^\#%) { $skip_heading=1; next; } elsif ($skip_heading == 1) { if(m%\#

%) { $skip_heading=2; print OUT "\n"; } next; } # Links to other Python modules, exceptions s%(.+?)%$2%g; #" # The horrors of guessing urls in text s%([^<]+)%$2%g; # " s%([^<]+)%$2%g; # " # Never leave these in web pages s%/[^<]+%%g; # " s%RDF.html\#%#%; # Bad IDs, who writes this stuff? s%%my $a=$1; $a =~ s/\<.*?\>//g; qq{}%ge; s%%my $a=$1; $a =~ s/\<.*?\>//g; $a =~ s/^-//; $a=~ s/ /-/g; qq{}%ge; s%%%g; # All the __new__ links are broken s%__new__%__new__%; # This is broken too, dunno why s%debug%debug%; if(m%^%) { print OUT qq{\n\n

$main_title - $doc_title

\n\n}; next; } my $year=1900+(localtime)[5]; print OUT <<"EOT" if m%^%;

(C) Copyright 2000-$year Dave Beckett, Copyright 2000-2005 University of Bristol

EOT print OUT; } close(IN); close(OUT);