Debian Codegraph @

docs/fix-pod-xhtml

raw
1 #!/usr/bin/perl
2 #
3 # Format XHTML generated by pod2html (via tidy) for websites
4 #
5 # Usage: pod2html ... MODULE.pm | tidy ... | fix-pod-xhtml OUTPUT-FILE
6 #
7 # Copyright (C) 2001-2004 David Beckett - http://www.dajobe.org/
8 # Copyright (C) 2001-2004 University of Bristol - http://www.bristol.ac.uk/
9 #
10
11 use strict;
12 use File::Basename;
13
14 my $progname=basename $0;
15
16 my $main_title="Redland RDF Application Framework";
17
18 die "USAGE: $progname OUTPUT-FILE\n" if @ARGV < 1;
19
20 my $doc_title;
21
22 my($file)=@ARGV;
23
24 my($pod_rdf_rel)=($file =~ m%^pod/RDF/%) ? '../' : '';
25 my($pod_rdf_redland_rel)=($file =~ m%^pod/RDF/Redland/%) ? '' : 'Redland/';
26
27 open(OUT, ">$file") or die "$progname: Cannot create $file - $!\n";
28 print OUT qq{<?xml version="1.0" encoding="iso-8859-1"?>\n};
29 open(IN, "-");
30 while(<IN>) {
31 if(m%<title>(.*?)</title>%) {
32 $doc_title=$1;
33 $doc_title =~ s/^(.*) - Redland (.*) Class$/Perl $1 Class/;
34 s%<title>(.*?)</title>%<title>$main_title - $doc_title</title>%;
35 }
36
37 next if /^\s*<link|meta/i;
38
39 s'(id|name)="([^"]+)"'my($a,$v)=($1,$2); $v=~ s/%/_/g; qq{$a="$v"}'eg;
40
41 s%<h1>%<h2>%; s%</h1>%</h2>%;
42 s%<hr />%%;
43
44 s%href="/docs/pod/RDF/Redland/([^"]+)"%href="$pod_rdf_redland_rel$1"%g;
45 s%href="/docs/pod/RDF/([^"]+)"%href="$pod_rdf_rel$1"%g;
46
47 s%^<body[^>]*>%<body>\n\n<h1 style="text-align:center">$main_title - $doc_title</h1>\n\n%;
48
49 s%^<p><a id="__index__".*</p>%%;
50
51 my $year=1900+(localtime)[5];
52 print OUT <<"EOT" if m%^</body>%;
53 <hr />
54
55 <p>(C) Copyright 2000-$year <a href="http://www.dajobe.org/">Dave Beckett</a>, (C) Copyright 2000-2005 <a href="http://www.bristol.ac.uk/">University of Bristol</a></p>
56
57 EOT
58 print OUT;
59 }
60 close(IN);
61 close(OUT);