$/ = "";
my @poddata = <POD>;
close(POD);
+
+ # be eol agnostic
+ for (@poddata) {
+ if (/\r/) {
+ if (/\r\n/) {
+ @poddata = map { s/\r\n/\n/g;
+ /\n\n/ ?
+ map { "$_\n\n" } split /\n\n/ :
+ $_ } @poddata;
+ } else {
+ @poddata = map { s/\r/\n/g;
+ /\n\n/ ?
+ map { "$_\n\n" } split /\n\n/ :
+ $_ } @poddata;
+ }
+ last;
+ }
+ }
+
clean_data( \@poddata );
# scan the pod for =head[1-6] directives and build an index
if ($title) {
$title =~ s/\s*\(.*\)//;
} else {
- warn "$0: no title for $podfile" unless $quiet;
+ warn "$0: no title for $podfile.\n" unless $quiet;
$podfile =~ /^(.*)(\.[^.\/]+)?\z/s;
$title = ($podfile eq "-" ? 'No Title' : $1);
warn "using $title" if $verbose;
if (/^=(head[1-6])\s+(.*\S)/s) { # =head[1-6] heading
process_head( $1, $2, $doindex && $index );
} elsif (/^=item\s*(.*\S)?/sm) { # =item text
- warn "$0: $podfile: =item without bullet, number or text"
- . " in paragraph $paragraph.\n" if !defined($1) or $1 eq '';
$need_dd = process_item( $1 );
$after_item = 1;
} elsif (/^=over\s*(.*)/) { # =over N
print HTML "</p>\n";
}
- my $name = htmlify( depod( $heading ) );
- $name =~ s/\s/_/g; # htmlify keeps spaces but we don't want them here...
+ my $name = anchorify( depod( $heading ) );
my $convert = process_text( \$heading );
print HTML "<h$level><a name=\"$name\">$convert</a></h$level>\n";
}
if ($items_named{$item}++) {
print HTML process_text( \$otext );
} else {
- my $name = 'item_' . $item;
- $name =~ s/\s/_/g; # we don't want spaces here...
+ my $name = 'item_' . $item;
+ $name = anchorify($name);
print HTML qq{<a name="$name">}, process_text( \$otext ), '</a>';
}
print HTML "</strong><br />\n";
$rest = $$text;
# insert spaces in place of tabs
- $rest =~ s#.*#
- my $line = $&;
- 1 while $line =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e;
+ $rest =~ s#(.+)#
+ my $line = $1;
+ 1 while $line =~ s/(\t+)/' ' x ((length($1) * 8) - $-[0] % 8)/e;
$line;
#eg;
# warning; show some text.
$linktext = $opar unless defined $linktext;
- warn "$0: $podfile: cannot resolve L<$opar> in paragraph $paragraph.";
+ warn "$0: $podfile: cannot resolve L<$opar> in paragraph $paragraph.\n";
}
# now we have a URL or just plain code
} elsif( $func eq 'Z' ){
# Z<> - empty
- warn "$0: $podfile: invalid X<> in paragraph $paragraph."
+ warn "$0: $podfile: invalid X<> in paragraph $paragraph.\n"
unless $$rstr =~ s/^>//;
} else {
if( $lev == 1 ){
$res .= pure_text( $$rstr );
} else {
- warn "$0: $podfile: undelimited $func<> in paragraph $paragraph.";
+ warn "$0: $podfile: undelimited $func<> in paragraph $paragraph.\n";
}
}
return $res;
}
$res .= $2;
}
- warn "$0: $podfile: undelimited $func<> in paragraph $paragraph.";
+ warn "$0: $podfile: undelimited $func<> in paragraph $paragraph.\n";
return $res;
}
$rest =~ s/</</g;
$rest =~ s/>/>/g;
$rest =~ s/"/"/g;
- $rest =~ s/'/'/g;
+ # ' is only in XHTML, not HTML4. Be conservative
+ #$rest =~ s/'/'/g;
return $rest;
}
$page83=dosify($page);
$page=$page83 if (defined $pages{$page83});
if ($page eq "") {
- $link = "#" . htmlify( $section );
+ $link = "#" . anchorify( $section );
} elsif ( $page =~ /::/ ) {
$page =~ s,::,/,g;
# Search page cache for an entry keyed under the html page name,
}
$link = "$htmlroot/$page.html";
- $link .= "#" . htmlify( $section ) if ($section);
+ $link .= "#" . anchorify( $section ) if ($section);
} elsif (!defined $pages{$page}) {
$link = "";
} else {
- $section = htmlify( $section ) if $section ne "";
+ $section = anchorify( $section ) if $section ne "";
### print STDERR "...section=$section\n";
# if there is a directory by the name of the page, then assume that an
}
#
+# similar to htmlify, but turns spaces into underscores
+#
+sub anchorify {
+ my ($anchor) = @_;
+ $anchor = htmlify($anchor);
+ $anchor =~ s/\s/_/g; # fixup spaces left by htmlify
+ return $anchor;
+}
+
+#
# depod - convert text by eliminating all interior sequences
# Note: can be called with copy or modify semantics
#