Pod::Html, which ships with the core, breaks on things like
L<PerlMonks|http://www.perlmonks.org/>
...with an error message like
C:\STRAWB~1\perl\bin/pod2html.bat: ../test.pod: cannot resolve L<PerlM +onks|http://www.perlmonks.org/> in paragraph 6.
This is not unique or new, as evidenced by hyperlinks in pod and others.
I still use 5.12.3 (too lazy to reinstall all the modules I've accumulated), so I decided to patch the module so it does accept the URLs by putting together two other expressions.
In v1.09 (the latest version of its kind), around line 1605, add this snippet after the if block:
# some L<>'s that shouldn't be: # a) full-blown URL's are emitted as-is if( $par =~ m{^\w+://}s ){ return make_URL_href( $par ); } # --- add this: --- elsif( $par =~ m{^([^|]+)\|(\w+)://(.+)}s ) { #link text in $1, scheme in $2, everything else in $3 return sprintf '<a href="%s://%s">%s</a>', $2, $3, html_escape($1) +; }
It might not work in all cases, but it seems to work for everything I could think of.
Pod::Html was replaced with a Pod::Simple solution in v5.16.0 (as evidenced by perl5160delta), but if you use something older like I do, and you've run into this frustration, it might save you the bother of having to rewrite a bunch of code to use something else.
The output may say that it's XHTML-1.0 compliant, but this is not the case. One example that bothers XML parsers is that the <dt> tags aren't closed all the time. For example, when you have...
=over 1 =item bla asdfghjk =back
... the resulting dt is closed as you would expect. But when you have...
=over 1 =item sdfsfgsdh =back
...it just outputs a blank, unclosed dt tag (followed by a dd tag with the text in it, as expected). To fix this, change this part around line 1211:
if ($text =~ /\A(.+)\Z/s ){ # should have text emit_item_tag( $otext, $text, 1 ); # write the definition term and close <dt> tag print HTML "</dt>\n"; }
to this:
if ($text =~ /\A(.+)\Z/s ){ # should have text emit_item_tag( $otext, $text, 1 ); } # write the definition term and close <dt> tag print HTML "</dt>\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Support for URLs with link titles in Pod::Html
by beech (Parson) on Apr 19, 2016 at 06:28 UTC |