diff options
author | Marc Green <marcgreen@cpan.org> | 2011-06-23 08:52:12 -0400 |
---|---|---|
committer | Marc Green <marcgreen@cpan.org> | 2011-10-31 13:26:41 -0400 |
commit | dfda798153289a39950353bad0b79816b837683b (patch) | |
tree | 942b19fd90cbf18feccff5834fe7e4fcbeae5096 | |
parent | f360b455d78a650d8df53a90267a8b249797c655 (diff) | |
download | perl-dfda798153289a39950353bad0b79816b837683b.tar.gz |
Update old-p2h to new-p2h script conversion
It converts more and correctly converts anchored =head directives and
index elements
-rw-r--r-- | ext/Pod-Html/t/old/old2new.pl | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/ext/Pod-Html/t/old/old2new.pl b/ext/Pod-Html/t/old/old2new.pl index 66297740ff..77989b7836 100644 --- a/ext/Pod-Html/t/old/old2new.pl +++ b/ext/Pod-Html/t/old/old2new.pl @@ -8,20 +8,18 @@ $/ = undef; # slurp whole file # Does basic conversion, simplifying the conversion by hand process # XXX: Watch out for [(REL)CURRENTWORKINGDIR] being s///'d, put it back after copy/paste -my $bindex = <<INDEX; +my $bindex = qr| <!-- INDEX BEGIN --> <div name="index"> <p><a name="__index__"></a></p> +(?:<!--)?\s+<ul> -<ul> +|; -INDEX - -my $eindex = <<END_INDEX; -</div> +my $eindex = qr|\s*(?:-->\s*)?</div> <!-- INDEX END --> -END_INDEX +|; while (<>) { # keep it [PERLADMIN] @@ -29,8 +27,8 @@ while (<>) { s#<title>.+?</title>#<title></title>#; s#$bindex#\n<ul id="index">\n#; - s#$eindex##; - s#</html>#</html>\n\n#; # ::xhtml adds newlines + s#$eindex#\n#; + s#</html>\s*#</html>\n\n\n#; # ::xhtml adds newlines s#<hr.*? />##g; # remove <hr>s s#<p>\n</p>##g; # remove <p></p>s @@ -38,16 +36,17 @@ while (<>) { s/">(.+?) in the (.+?) manpage/">"$1" in $2/g; s/the (.+?) manpage/$1/g; s#<em>(.+?)</em>#<a>$1</a>#g; # links not found + s/class="block"/class="_podblock_"/g; # from --header # index elements # Note: only works for sections w/o inner <ul>s b/c new Pod::Html handles them differently - s|<li><a href="#(.+?)">(??{ uc $1 })</a></li>| - '<li><a href="#' . uc($1) . '">'. uc($1) . '</a></li>'|eg; + s|<li><a href="#(.+?)">(.+?)(?{ (\1 =~ tr/_/ /r) eq lc(\2) })</a></li>| + '<li><a href="#' . uc($1 =~ tr/_/-/r) . "\">$2</a></li>"|eg; # anchored =head1 -> id'd =head1 - s#<h(\d)><a name="(.+?)">(??{ uc $2 })</a></h\1># - "<h$1 id=\"" . uc($2) . '">' . uc($2) . "</h$1>\n"#eg; + s#<h(\d)><a name="(.+?)">(.+?)(?{ (\2 =~ tr/_/ /r) eq lc(\3) })</a></h\1># + "<h$1 id=\"" . ($3 =~ tr/_/-/r) . "\">$3</h$1>\n"#eg; print; } |