Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re^2: Find and convert all pod to html

by Anonymous Monk
on Apr 10, 2019 at 12:40 UTC ( #1232401=note: print w/replies, xml ) Need Help??

in reply to Re: Find and convert all pod to html
in thread Find and convert all pod to html

After posting the script above I realized that pod2html could not set the cross referencing between the html files correctly. Depending on the number of subdirectories it needs additionally "../../.." in href for relative referencing. Just one look to the possible parameters of pod2html showed that it needed the parameter "--htmldir=name". So this is the final version with creating a TOC-file and correct referencing:
use strict; use Pod::Html; use Pod::Find qw(pod_find); use File::Path; my $podroot = "C:/MySw/Strawberry5.28x64/perl"; my $htmldir = "C:/MySw/Strawberry5.28x64/html"; my $indexhtml = "$htmldir/my_alternative_index.html"; my $logfile = "C:/MySw/Strawberry5.28x64/allpod.txt"; if(!-e $htmldir) { mkdir($htmldir) || die "Cannot mkdir $htmldir !!\n" +; } my %pods = pod_find({ -verbose => 0, -inc => 1 }); my (@sorted); foreach my $podfile (keys %pods) { $podfile =~ s#\\#/#g; my ($path,$name) = ($podfile =~ m!^$podroot(/.+)?/([^\/]+)\.(pod|p +m|pl)$!i); my (@depth) = ($path =~ /(\/)/go); my $depth = scalar @depth; my $sorted = sprintf("%010d%-s",$depth,$podfile); push(@sorted,$sorted); } open IDX, ">$indexhtml" || die "Cannot open $indexhtml\n"; print IDX "<html><head><title>Perl Documentation - Ver 5.28</title></h +ead>\n"; print IDX "<body>\n<blockquote>\n<h2>Perl Documentation - Ver 5.28</h2 +>\n"; print IDX "<h3>Table of Content</h3>\n"; open LOG, ">$logfile" || die "Cannot open $logfile\n"; pmpod2html(); close(LOG); print IDX "</blockquote>\n</body></html>\n"; close(IDX); sub pmpod2html { my ($prepath,$predepth); foreach my $podfile (sort @sorted) { $podfile =~ s/^\d{10}//o; my ($path,$name) = ($podfile =~ m!^$podroot(/.+)?/([^\/]+)\.(p +od|pm|pl)$!i); $path =~ s/^\///o; my (@depth) = ($path =~ /(\/)/go); my $depth = scalar @depth; print IDX '</blockquote>' x$predepth . "\n\n" . '<blockquote>' + x$depth . "\n" . "<b>$path</b><br>\n" if($prepath ne $path); if (! -e "$htmldir/$path/$name\.html") { mkpath("$htmldir/$path"); pod2html( "--infile=$podfile", "--outfile=$htmldir/$path/$name.html", "--podroot=$podroot", "--podpath=lib:site:vendor", "--htmldir=$htmldir", ); my ($htmlfile); open(IN,"<$htmldir/$path/$name.html") || die "Cannot open +$htmldir/$path/$name.html\n"; while(<IN>) { $htmlfile .= $_; } my ($title) = ($htmlfile =~ /<title>\s*(.+?)\s*<\/title>/i +os); close(IN); print LOG "$podfile\n"; if($title) { print IDX "$title: <a href=\"$path/$name.html\">$name. +html</a><br>\n"; } else { print IDX "<a href=\"$path/$name.html\">$name.html< +/a><br>\n"; } } $prepath = $path; $predepth = $depth; } }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1232401]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2020-07-12 10:29 GMT
Find Nodes?
    Voting Booth?

    No recent polls found