Wednesday, 27 February 2013

Pod to HTML | Toby Inkster [blogs.perl.org]

OK, so there were already a thousand solutions for converting pod to HTML, but I wasn't especially happy with any of them. Things I wanted were:

Clean-looking XHTML and/or HTML5 output.
Unicode support. ?
Good syntax highlighting for Perl code samples within the pod.
Links to metacpan.org by default rather than search.cpan.org.

And so I've cobbled together a solution using Pod::Simple, PPI::HTML, HTML::HTML5::Parser, HTML::HTML5::Writer, XML::LibXML::PrettyPrint and Moo, and released it as TOBYINK::Pod::HTML.

Here's the example from the synopsis section:
1: #!/usr/bin/perl
2:
3: use strict;
4: use warnings;
5: use TOBYINK::Pod::HTML;
6:
7: my $pod2html = "TOBYINK::Pod::HTML"->new(
8: pretty => 1, # nicely indented HTML
9: code_highlighting => 1, # use PPI::HTML
10: code_line_numbers => undef,
11: code_styles => { # some CSS
12: comment => 'color:green',
13: keyword => 'font-weight:bold',
14: }
15: );
16:
17: print $pod2html->file_to_html(__FILE__);
There's a basic command-line script pod2html-tobyink supplied with it.
Oh, and this blog post was written as pod and converted to HTML.
crawled from : Perl

No comments:

Post a Comment