180 |
qr/inserting missing 'title' element/, |
qr/inserting missing 'title' element/, |
181 |
qr/lacks "summary" attribute/, |
qr/lacks "summary" attribute/, |
182 |
] ); |
] ); |
|
if ( $tidy->parse('html', $html) ) { |
|
|
if ( $tidy->messages ) { |
|
|
$html .= '<div class="tidy">HTML Tidy output:'; |
|
183 |
|
|
184 |
my @lines = split(/[\n\r]+/, $html); |
my @lines = split( "\n", $html ); |
185 |
|
$_ = "$_\n" for @lines; |
186 |
|
|
187 |
|
if ( $tidy->parse('tidy', @lines) ) { |
188 |
|
if ( $tidy->messages ) { |
189 |
|
$html .= <<__TIDY_CLOSE__; |
190 |
|
<div id="tidy_show" class="notice" style="display: none;" onclick="Element.hide('tidy_show'); Element.show('tidy');">?</div> |
191 |
|
<div id="tidy" class="tidy"> |
192 |
|
<a href="#" onclick="Element.hide('tidy'); Element.show('tidy_show'); return false;">close</a> |
193 |
|
HTML Tidy output: |
194 |
|
<br/> |
195 |
|
__TIDY_CLOSE__ |
196 |
# Escape <, >, & and ", and to produce valid XML |
# Escape <, >, & and ", and to produce valid XML |
197 |
my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); |
my %escape = ('<'=>'<', '>'=>'>', '&'=>'&', '"'=>'"'); |
198 |
my $escape_re = join '|' => keys %escape; |
my $escape_re = join '|' => keys %escape; |
199 |
|
|
|
|
|
200 |
foreach my $m ( $tidy->messages ) { |
foreach my $m ( $tidy->messages ) { |
201 |
my $c = $lines[ ( $m->line - 2 ) ]; |
my $c = $lines[ ( $m->line - 1 ) ]; |
202 |
my $txt = $m->as_string; |
my $txt = $m->as_string; |
203 |
$c =~ s/($escape_re)/$escape{$1}/g; |
$c =~ s/($escape_re)/$escape{$1}/g; |
204 |
$txt =~ s/($escape_re)/$escape{$1}/g; |
$txt =~ s/($escape_re)/$escape{$1}/g; |
205 |
my $class = ''; |
my $class = ''; |
206 |
$class = ' class="tidy_'.lc($1).'"' if ($txt =~ /(Warning|Error):/s); |
$class = ' class="tidy_'.lc($1).'"' if ($txt =~ /(Warning|Error):/s); |
207 |
$html .= "<div${class}>$txt | <tt>$c</tt></div>"; |
$html .= 'line ' . $m->line . ":<span${class}>$txt<tt>$c</tt></span>"; |
208 |
} |
} |
209 |
$html .= '</div>'; |
$html .= '</div>'; |
210 |
} |
} |