PageRenderTime 55ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/devel.docs/blog/2013-02-26.pod

https://bitbucket.org/tobyink/p5-tobyink-pod-html
Perl | 76 lines | 10 code | 5 blank | 61 comment | 0 complexity | 56958a383716645984a05452f4284584 MD5 | raw file
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use TOBYINK::Pod::HTML;
  5. my $pod2html = "TOBYINK::Pod::HTML"->new(
  6. pretty => 1, # nicely indented HTML
  7. code_highlighting => 1, # use PPI::HTML
  8. code_line_numbers => undef,
  9. );
  10. print $pod2html->file_to_html(__FILE__);
  11. __END__
  12. =pod
  13. =encoding utf-8
  14. OK, so there were already
  15. L<a thousand solutions|https://metacpan.org/search?q=pod+html> for
  16. converting pod to HTML, but I wasn't especially happy with any of
  17. them. Things I wanted were:
  18. =over
  19. =item *
  20. Clean-looking XHTML and/or HTML5 output.
  21. =item *
  22. Unicode support. ☝
  23. =item *
  24. Good syntax highlighting for Perl code samples within the pod.
  25. =item *
  26. Links to L<metacpan.org|https://metacpan.org/> by default rather than
  27. L<search.cpan.org|http://search.cpan.org/>.
  28. =back
  29. And so I've cobbled together a solution using L<Pod::Simple>, L<PPI::HTML>,
  30. L<HTML::HTML5::Parser>, L<HTML::HTML5::Writer>, L<XML::LibXML::PrettyPrint>
  31. and L<Moo>, and released it as L<TOBYINK::Pod::HTML>.
  32. Here's the example from the synopsis section:
  33. #!/usr/bin/perl
  34. use strict;
  35. use warnings;
  36. use TOBYINK::Pod::HTML;
  37. my $pod2html = "TOBYINK::Pod::HTML"->new(
  38. pretty => 1, # nicely indented HTML
  39. code_highlighting => 1, # use PPI::HTML
  40. code_line_numbers => undef,
  41. code_styles => { # some CSS
  42. comment => 'color:green',
  43. keyword => 'font-weight:bold',
  44. }
  45. );
  46. print $pod2html->file_to_html(__FILE__);
  47. There's a basic command-line script C<pod2html-tobyink> supplied with it.
  48. Oh, and this blog post was
  49. L<written as pod|https://bitbucket.org/tobyink/p5-tobyink-pod-html/src/tip/devel.docs/blog/2013-02-26.pod>
  50. and
  51. L<converted to HTML|https://bitbucket.org/tobyink/p5-tobyink-pod-html/src/tip/devel.docs/blog/2013-02-26.html>.