-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpod2html.pl
executable file
·50 lines (37 loc) · 1.04 KB
/
pod2html.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/perl
use strict;
use utf8;
use warnings 'all';
use Data::Dumper;
use File::Find;
use FindBin qw($Bin);
use Pod::Simple::HTML;
use Regexp::Common qw(comment);
my $path = "$Bin/pod";
chdir $path;
my @files;
find(sub { push @files, $File::Find::name if /\.pod$/ && -f $_ } => '.');
my $css = 'http://st.pimg.net/tucs/style.css';
my @docs = qw(.. html);
foreach my $pod (@files) {
my @path = split m{/}, $pod;
shift @path;
my $html_file = pop @path;
$html_file =~ s/\.pod$//;
$html_file .= '.html';
my $link = join('/', @path, $html_file);
unshift @path, @docs;
mkdir join('/', @path[0 .. $_]) for 1 .. $#path;
printf STDERR "%s/%s -> %s\n", $path, $pod, $html_file;
my $p = new Pod::Simple::HTML;
my $html = '';
$p->accept_targets('*');
$p->html_css($css);
$p->index(1);
$p->output_string(\$html);
$p->parse_file("$path/$pod");
$html =~ s/$RE{comment}{HTML}\s*//gos;
open(my $fh, '>:encoding(latin1)', join('/', @path, $html_file));
print $fh $html;
close $fh;
}