line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Statocles::Plugin::HTMLLint; |
2
|
|
|
|
|
|
|
our $VERSION = '0.084'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Check HTML for common errors and issues |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
36248
|
use Statocles::Base 'Class'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
6
|
|
|
|
|
|
|
with 'Statocles::Plugin'; |
7
|
|
|
|
|
|
|
BEGIN { |
8
|
1
|
50
|
|
1
|
|
6793
|
eval { require HTML::Lint::Pluggable; HTML::Lint::Pluggable->VERSION( 0.06 ); 1 } |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
298
|
|
9
|
|
|
|
|
|
|
or die "Error loading Statocles::Plugin::HTMLLint. To use this plugin, install HTML::Lint::Pluggable"; |
10
|
|
|
|
|
|
|
}; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#pod =attr plugins |
13
|
|
|
|
|
|
|
#pod |
14
|
|
|
|
|
|
|
#pod The L<HTML::Lint::Pluggable> plugins to use. Defaults to a generic set of |
15
|
|
|
|
|
|
|
#pod plugins good for HTML5: 'HTML5' and 'TinyEntitesEscapeRule' |
16
|
|
|
|
|
|
|
#pod |
17
|
|
|
|
|
|
|
#pod =cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has plugins => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
isa => ArrayRef, |
22
|
|
|
|
|
|
|
default => sub { [qw( HTML5 TinyEntitesEscapeRule )] }, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#pod =method check_pages |
26
|
|
|
|
|
|
|
#pod |
27
|
|
|
|
|
|
|
#pod $plugin->check_pages( $event ); |
28
|
|
|
|
|
|
|
#pod |
29
|
|
|
|
|
|
|
#pod Check the pages inside the given |
30
|
|
|
|
|
|
|
#pod L<Statocles::Event::Pages|Statocles::Event::Pages> event. |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod =cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub check_pages { |
35
|
1
|
|
|
1
|
1
|
3
|
my ( $self, $event ) = @_; |
36
|
1
|
|
|
|
|
2
|
my @plugins = @{ $self->plugins }; |
|
1
|
|
|
|
|
4
|
|
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
10
|
my $lint = HTML::Lint::Pluggable->new; |
39
|
1
|
|
|
|
|
88
|
$lint->load_plugins( @plugins ); |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
11142
|
for my $page ( @{ $event->pages } ) { |
|
1
|
|
|
|
|
5
|
|
42
|
34
|
100
|
|
|
|
1162
|
if ( $page->DOES( 'Statocles::Page::Document' ) ) { |
43
|
11
|
|
|
|
|
278
|
my $html = $page->render( site => $event->emitter ); |
44
|
11
|
|
|
|
|
190
|
my $page_url = $page->path; |
45
|
|
|
|
|
|
|
|
46
|
11
|
|
|
|
|
73
|
$lint->newfile( $page_url ); |
47
|
11
|
|
|
|
|
150
|
$lint->parse( $html ); |
48
|
11
|
|
|
|
|
33465
|
$lint->eof; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
1
|
50
|
|
|
|
25
|
if ( my @errors = $lint->errors ) { |
53
|
1
|
|
|
|
|
13
|
for my $error ( @errors ) { |
54
|
3
|
|
|
|
|
373
|
$event->emitter->log->warn( "-" . $error->as_string ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
#pod =method register |
60
|
|
|
|
|
|
|
#pod |
61
|
|
|
|
|
|
|
#pod Register this plugin to install its event handlers. Called automatically. |
62
|
|
|
|
|
|
|
#pod |
63
|
|
|
|
|
|
|
#pod =cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub register { |
66
|
1
|
|
|
1
|
1
|
26
|
my ( $self, $site ) = @_; |
67
|
1
|
|
|
1
|
|
8
|
$site->on( build => sub { $self->check_pages( @_ ) } ); |
|
1
|
|
|
|
|
1201
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=pod |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=encoding UTF-8 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 NAME |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Statocles::Plugin::HTMLLint - Check HTML for common errors and issues |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 VERSION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
version 0.084 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SYNOPSIS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# site.yml |
89
|
|
|
|
|
|
|
site: |
90
|
|
|
|
|
|
|
class: Statocles::Site |
91
|
|
|
|
|
|
|
args: |
92
|
|
|
|
|
|
|
plugins: |
93
|
|
|
|
|
|
|
lint: |
94
|
|
|
|
|
|
|
$class: Statocles::Plugin::HTMLLint |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 DESCRIPTION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This plugin checks all of the HTML to ensure it's correct and complete. If something |
99
|
|
|
|
|
|
|
is missing, this plugin will write a warning to the screen. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 plugins |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
The L<HTML::Lint::Pluggable> plugins to use. Defaults to a generic set of |
106
|
|
|
|
|
|
|
plugins good for HTML5: 'HTML5' and 'TinyEntitesEscapeRule' |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 METHODS |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 check_pages |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
$plugin->check_pages( $event ); |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Check the pages inside the given |
115
|
|
|
|
|
|
|
L<Statocles::Event::Pages|Statocles::Event::Pages> event. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 register |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Register this plugin to install its event handlers. Called automatically. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 AUTHOR |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Doug Bell <preaction@cpan.org> |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Doug Bell. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
130
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |