#!../perl # The beginning of the url for the anchors to the other sections. chop($wd=`pwd`); $type="{"pods"}}=grep(/\.pod$/,readdir(DIR)); closedir(DIR); # learn the important stuff foreach $tmpod (@{$p->{"pods"}}){ ($pod=$tmpod)=~s/\.pod$//; $p->{"podnames"}->{$pod}=1; next if grep(/$pod/,@exclusions); open(POD,"<$tmpod"); while(){ s/B<([^<>]*)>/$1/g; # bold s/I<([^<>]*)>/$1/g; # bold if (s/^=//) { s/\n$//s; s/\n/ /g; ($cmd, $_) = split(' ', $_, 2); if ($cmd eq "item") { ($what,$rest)=split(' ', $_, 2); $what=~s#(-.).*#$1#; $what=~s/\s*$//; next if defined $p->{"items"}->{$what}; $p->{"items"}->{$what} = $pod."_".$i++; } elsif($cmd =~ /^head/){ $_=~s/\s*$//; next if defined($p->{"headers"}->{$_}); $p->{"headers"}->{$_} = $pod."_".$i++; } } } } $/=""; # parse the pods, produce html foreach $tmpod (@{$p->{"pods"}}){ open(POD,"<$tmpod") || die "cant open $pod"; ($pod=$tmpod)=~s/\.pod$//; open(HTML,">$pod.html"); print HTML "\n"; print HTML "\n"; print HTML "\n"; print HTML " \U$pod\E \n"; $cutting = 1; while () { if ($cutting) { next unless /^=/; $cutting = 0; } chop; length || (print "\n") && next; # Translate verabatim paragraph if (/^\s/) { $unordered=0; &pre_escapes; &post_escapes; @lines = split(/\n/); if($lines[0]=~/^\s+(\w*)\t(.*)/){ # listing or unordered list ($key,$rest)=($1,$2); if(defined($p->{"podnames"}->{$key})){ print HTML "\n
    \n"; $unordered = 1; } else{ print HTML "\n\n"; } foreach $line (@lines){ ($line =~ /^\s+(\w*)\t(.*)/) && (($key,$rest)=($1,$2)); print HTML defined($p->{"podnames"}->{$key}) ? "
  • $type$key.html\">$key<\/A>\t$rest\n" : "$line \n"; } print HTML $unordered ? "
\n" : "\n"; next; }else{ # preformatted text print HTML "
\n";
		for(@lines){
		    s/^/    /;
		    s/\t/        /g;
		    print HTML  $_,"\n";
	        }
            print  HTML "
\n"; next; } } &pre_escapes; s/S<([^<>]*)>/$1/g; # embedded special $_ = &Do_refs($_,$pod); s/Z<>/

/g; # ? s/E<([^<>]*)>/\&$1\;/g; # embedded special &post_escapes; if (s/^=//) { s/\n$//s; s/\n/ /g; ($cmd, $_) = split(' ', $_, 2); if ($cmd eq 'cut') { $cutting = 1; } elsif ($cmd eq 'head1') { print HTML qq{

$_

\n}; } elsif ($cmd eq 'head2') { print HTML qq{

$_

\n}; } elsif ($cmd eq 'over') { push(@indent,$indent); $indent = $_ + 0; print HTML qq{\n
\n}; } elsif ($cmd eq 'back') { $indent = pop(@indent); warn "Unmatched =back\n" unless defined $indent; $needspace = 1; print HTML qq{\n
\n\n}; } elsif ($cmd eq 'item') { ($what,$rest)=split(' ', $_, 2); $what=~s/\s*$//; if($justdid ne $what){ print HTML "\n
{"items"}->{$what}."\">\n"; $justdid=$what; } print HTML qq{
$_
\n}; $next_para=1; } else { warn "Unrecognized directive: $cmd\n"; } } else { length || next; $next_para && (print HTML qq{
\n}); print HTML "$_

"; $next_para && (print HTML qq{

\n

\n}) && ($next_para=0); } } } print HTML "\n\n"; ######################################################################### sub pre_escapes { s/\&/\&\;/g; s/<>/\>\;\>\;/g; s/([^"AIB])>/$1\>\;/g; } sub Do_refs{ local($para,$pod)=@_; foreach $char ("L","C","I","B"){ next unless /($char<[^<>]*>)/; local(@ar) = split(/($char<[^<>]*>)/,$para); local($this,$key,$num); for($this=0;$this<=$#ar;$this++){ next unless $ar[$this] =~ /${char}<([^<>]*)>/; $key=$1; if((defined($p->{"podnames"}->{$key})) && ($char eq "L")){ $ar[$this] = "\n$type$key.html\">\nthe $key manpage<\/A>\n"; # } elsif(defined($p->{"items"}->{$key})){ ($pod2,$num)=split(/_/,$p->{"items"}->{$key},2); $ar[$this] = (($pod2 eq $pod) && ($para=~/^\=item/)) ? "\n{"items"}->{$key}."\">\n$key\n" : "\n$type$pod2.html\#".$p->{"items"}->{$key}."\">$key<\/A>\n"; } elsif(defined($p->{"headers"}->{$key})){ ($pod2,$num)=split(/_/,$p->{"headers"}->{$key},2); $ar[$this] = (($pod eq $pod2) && ($para=~/^\=head/)) ? "\n{"headers"}->{$key}."\">\n$key\n" : "\n$type$pod2.html\#".$p->{"headers"}->{$key}."\">$key<\/A>\n"; } else{ (warn "No \"=item\" or \"=head\" reference for $ar[$this] in $pod\n") if $debug; if($char =~ /^[BCF]$/){ $ar[$this]="$key"; } elsif($char eq "L"){ $ar[$this]=$key; } elsif($char eq "I"){ $ar[$this]="$key"; } } } $para=join('',@ar); } $para; } sub wait{1;}