line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Tidy::Message; |
2
|
|
|
|
|
|
|
|
3
|
24
|
|
|
24
|
|
154
|
use warnings; |
|
24
|
|
|
|
|
56
|
|
|
24
|
|
|
|
|
699
|
|
4
|
24
|
|
|
24
|
|
126
|
use strict; |
|
24
|
|
|
|
|
62
|
|
|
24
|
|
|
|
|
846
|
|
5
|
|
|
|
|
|
|
use overload |
6
|
24
|
|
|
|
|
199
|
q{""} => \&as_string, |
7
|
24
|
|
|
24
|
|
25108
|
fallback => 'sounds like a good idea'; |
|
24
|
|
|
|
|
21583
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
HTML::Tidy::Message - Message object for the Tidy functionality |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
See L<HTML::Tidy|HTML::Tidy> for all the gory details. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 EXPORTS |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
None. It's all object-based. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 METHODS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Almost everything is an accessor. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 new( $file, $line, $column, $text ) |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Create an object. It's not very exciting. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub new { |
32
|
177
|
|
|
177
|
1
|
2708
|
my $class = shift; |
33
|
|
|
|
|
|
|
|
34
|
177
|
|
|
|
|
285
|
my $file = shift; |
35
|
177
|
|
|
|
|
275
|
my $type = shift; |
36
|
177
|
|
100
|
|
|
469
|
my $line = shift || 0; |
37
|
177
|
|
100
|
|
|
434
|
my $column = shift || 0; |
38
|
177
|
|
|
|
|
276
|
my $text = shift; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Add an element that says what tag caused the error (B, TR, etc) |
41
|
|
|
|
|
|
|
# so that we can match 'em up down the road. |
42
|
177
|
|
|
|
|
654
|
my $self = { |
43
|
|
|
|
|
|
|
_file => $file, |
44
|
|
|
|
|
|
|
_type => $type, |
45
|
|
|
|
|
|
|
_line => $line, |
46
|
|
|
|
|
|
|
_column => $column, |
47
|
|
|
|
|
|
|
_text => $text, |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
177
|
|
|
|
|
337
|
bless $self, $class; |
51
|
|
|
|
|
|
|
|
52
|
177
|
|
|
|
|
787
|
return $self; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 where() |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Returns a formatted string that describes where in the file the |
58
|
|
|
|
|
|
|
error has occurred. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
For example, |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
(14:23) |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
for line 14, column 23. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
The terrible thing about this function is that it's both a plain |
67
|
|
|
|
|
|
|
ol' formatting function as in |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $str = where( 14, 23 ); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
AND it's an object method, as in: |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $str = $error->where(); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
I don't know what I was thinking when I set it up this way, but |
76
|
|
|
|
|
|
|
it's bad practice. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub where { |
81
|
392
|
|
|
392
|
1
|
658
|
my $self = shift; |
82
|
|
|
|
|
|
|
|
83
|
392
|
100
|
66
|
|
|
740
|
return '-' unless $self->line && $self->column; |
84
|
|
|
|
|
|
|
|
85
|
359
|
|
|
|
|
788
|
return sprintf( '(%d:%d)', $self->line, $self->column ); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 as_string() |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Returns a nicely-formatted string for printing out to stdout or some similar user thing. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub as_string { |
95
|
392
|
|
|
392
|
1
|
7127
|
my $self = shift; |
96
|
|
|
|
|
|
|
|
97
|
392
|
|
|
|
|
982
|
my %strings = ( |
98
|
|
|
|
|
|
|
1 => 'Info', |
99
|
|
|
|
|
|
|
2 => 'Warning', |
100
|
|
|
|
|
|
|
3 => 'Error', |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
return sprintf( '%s %s %s: %s', |
104
|
392
|
|
|
|
|
819
|
$self->file, $self->where, $strings{$self->type}, $self->text ); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 file() |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Returns the filename of the error, as set by the caller. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 type() |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Returns the type of the error. This will either be C<TIDY_ERROR>, |
114
|
|
|
|
|
|
|
or C<TIDY_WARNING>. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 line() |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Returns the line number of the error, or 0 if there isn't an applicable |
119
|
|
|
|
|
|
|
line number. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 column() |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Returns the column number, or 0 if there isn't an applicable column |
124
|
|
|
|
|
|
|
number. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 text() |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Returns the text of the message. This does not include a type string, |
129
|
|
|
|
|
|
|
like "Info: ". |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |
132
|
|
|
|
|
|
|
|
133
|
394
|
|
|
394
|
1
|
2433
|
sub file { my $self = shift; return $self->{_file} } |
|
394
|
|
|
|
|
955
|
|
134
|
435
|
|
|
435
|
1
|
2050
|
sub type { my $self = shift; return $self->{_type} } |
|
435
|
|
|
|
|
1185
|
|
135
|
753
|
|
|
753
|
1
|
2412
|
sub line { my $self = shift; return $self->{_line} } |
|
753
|
|
|
|
|
2023
|
|
136
|
720
|
|
|
720
|
1
|
3045
|
sub column { my $self = shift; return $self->{_column} } |
|
720
|
|
|
|
|
2734
|
|
137
|
417
|
|
|
417
|
1
|
2055
|
sub text { my $self = shift; return $self->{_text} } |
|
417
|
|
|
|
|
2430
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Copyright 2005-2017 Andy Lester. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
145
|
|
|
|
|
|
|
it under the terms of the Artistic License v2.0. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 AUTHOR |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Andy Lester, C<< <andy@petdance.com> >> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
1; # happy |