package Padre::Pod2HTML; =pod =head1 NAME Padre::Pod2HTML - A customised Pod to HTML for Padre =head1 SYNOPSIS # The quicker way $html = Padre::Pod2HTML->pod2html( $pod_string ); # The slower way $parser = Padre::Pod2HTML->new; $parser->parse_string_document( $pod_string ); $html = $parser->html; =head1 DESCRIPTION C provides a central point for L functionality inside of Padre. Initially it just provides an internal convenience that converts L from printing to C to capturing the HTML. Currently the constructor does not take any options. =cut use 5.008; use strict; use warnings; use Pod::Simple::XHTML (); our $VERSION = '1.02'; our @ISA = 'Pod::Simple::XHTML'; ##################################################################### # One-Shot Methods sub file2html { my $class = shift; my $file = shift; my $self = $class->new(@_); # Generate the HTML $self->{html} = ''; $self->parse_file($file); $self->clean_html; return $self->{html}; } sub pod2html { my $class = shift; my $input = shift; my $self = $class->new(@_); # Generate the HTML $self->{html} = ''; $self->parse_string_document($input); $self->clean_html; return $self->{html}; } ##################################################################### # Capture instead of print # Prevent binding to STDOUT sub new { my $class = shift; my $self = $class->SUPER::new(@_); # Ignore POD irregularities $self->no_whining(1); $self->no_errata_section(1); $self->output_string( \$self->{html} ); return $self; } sub clean_html { my $self = shift; return unless defined $self->{html}; #FIX ME: this takes care of a bug in Pod::Simple::XHTML $self->{html} =~ s/<{html} =~ s/< /< /g; $self->{html} =~ s/<=/<=/g; #FIX ME: this is incredibly bad, but the anchors are predictible $self->{html} =~ s/|<\/a>//g; return 1; } 1; =pod =head1 AUTHOR Adam Kennedy C Ahmad M. Zawawi C =head1 SEE ALSO L =head1 COPYRIGHT Copyright 2008-2016 The Padre development team as listed in Padre.pm. This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5 itself. The full text of the license can be found in the LICENSE file included with this module. =cut