Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

cwest (1514)

cwest
  (email not shown publicly)
http://caseywest.com/
AOL IM: caseyrwest (Add Buddy, Send Message)

Perl geek.

Journal of cwest (1514)

Wednesday July 17, 2002
09:20 AM

Named links in POD

[ #6415 ]

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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I found this in perlpodspec [cpan.org].

    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.