Named links in POD

cwest on 2002-07-17T14:20:28

I recently wrote a document in POD and I wanted to have named links in it for it's HTML conversion. Currently, pod2html doesn't support that. It will convert links found in documents to standard links but it doesn't support a method of having named links.

So after much pain I devised a method of coverting text to links after the POD has been converted to HTML. It's ugly and otherwise scary but it might just work for you.

Firt, for every link you want to have you need to create a separate POD file with items for each link like so.

=item Perl

http://perl.org

=item POE

http://poe.perl.org

=item OSCON LAN Party

http://cwest.aaronsen.com/lanparty


Next you run the following series of commands over the resources file and your document file. This way all the text of the =item's will get converted to the appropriate links.

pod2text resources.pod | perl -MStorable -nle'BEGIN{$/=""}@p=/\s+([^\n]+)\s+(\S+)/;$i{$p[0]}=$p[1]}store \%i, "resources.dat";{'

pod2html document.pod > document.html

perl -MStorable -0 -n -e'$f=$_;$f=~s#$_#<a href="$i{$_}">$_</a>#g for keys(%{{%i=%{retrieve "resources.dat"}}});print $f' document.html > document.html.fixed

mv document.html.fixed document.html

html2ps document.html | pd2pdf - document.pdf


I hope my pain eases yours some day.


Here's the definitive answer

davorg on 2002-07-17T14:39:32

I found this in perlpodspec.

Authors wanting to link to a particular (absolute) URL, must do so only with "L<scheme:...>" codes (like L<http://www.perl.org>), and must not attempt "L<Some Site Name|scheme:...>" codes. This restriction avoids many problems in parsing and rendering L<...> codes.

That's not so say that it's a restriction that absolutely can't be removed.