File Coverage

blib/lib/Pod/Simple/Role/XHTML/HTML5.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 17 18 94.4


line stmt bran cond sub pod time code
1             package Pod::Simple::Role::XHTML::HTML5;
2 1     1   477423 use Moo::Role;
  1         3  
  1         8  
3              
4             our $VERSION = '0.004000';
5             $VERSION =~ tr/_//d;
6              
7 1     1   671 use HTML::Entities qw(decode_entities encode_entities);
  1         4  
  1         123  
8 1     1   471 use URL::Encode qw(url_encode_utf8);
  1         6246  
  1         68  
9              
10 1     1   555 use namespace::clean;
  1         19894  
  1         9  
11              
12       1 0   sub BUILD {}
13             after BUILD => sub {
14             my $self = shift;
15             $self->html_doctype('');
16             $self->html_charset('UTF-8');
17             };
18              
19             around html_header_tags => sub {
20             my $orig = shift;
21             my $self = shift;
22             return $self->$orig(@_)
23             if @_;
24              
25             $self->{html_header_tags} ||= sprintf '',
26             $self->html_charset;
27             };
28              
29             around build_index => sub {
30             my $orig = shift;
31             my $self = shift;
32              
33             my $index = $self->$orig(@_);
34              
35             $index =~ s{\A
    }{
      };
36             return "";
37             };
38              
39             around emit => sub {
40             my $orig = shift;
41             my $self = shift;
42              
43             my $scratch = $self->{scratch};
44              
45             if ($scratch =~ //) {
46             $scratch =~ s{(}{$1>};
47             $self->{scratch} = $scratch;
48             }
49              
50             $self->$orig(@_);
51             };
52              
53             1;
54              
55             =head1 NAME
56              
57             Pod::Simple::Role::XHTML::HTML5 - Produce HTML5 content rather than XHTML
58              
59             =head1 SYNOPSIS
60              
61             package MyPodParser;
62             with 'Pod::Simple::Role::XHTML::HTML5';
63              
64             my $parser = MyPodParser->new;
65             $parser->output_string(\my $html);
66             $parser->parse_string_document($pod);
67              
68             =head1 DESCRIPTION
69              
70             L is the current state of the art formatter for producing
71             HTML from Pod. However, it is meant to produce XHTML, which is not the preferred
72             format to use at this time. When producing a full page including headers, the
73             self closing tags in the header will include a C<< /> >> on some tags. While
74             this is valid HTML, it is not the preferred format.
75              
76             Using this role will remove the trailing C<< /> >> from the header tags, change
77             the default character set to UTF-8, include a C<< >> doctype,
78             remove the C from the index, and wrap the index with a C<< >>
79             element.
80              
81             =head1 SUPPORT
82              
83             See L for support and contact information.
84              
85             =head1 AUTHORS
86              
87             See L for authors.
88              
89             =head1 COPYRIGHT AND LICENSE
90              
91             See L for the copyright and license.
92              
93             =cut