Skip to content

Commit

Permalink
replace tidy with valid
Browse files Browse the repository at this point in the history
  • Loading branch information
jmtcsngr committed May 1, 2024
1 parent a4faeb0 commit cc64754
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 21 deletions.
1 change: 0 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ jobs:
eval $(perl -I ${{ env.PERL_CACHE }}/lib/perl5/ -Mlocal::lib)
cpanm --quiet --notest Module::Build
cpanm --quiet --notest Alien::Tidyp
./scripts/install_wsi_dependencies.sh "$NPG_LIB" \
perl-dnap-utilities \
Expand Down
2 changes: 1 addition & 1 deletion Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ my $builder = $class->new(
'GD::Text' => 0,
'Getopt::Long' => '2.37',
'HTML::PullParser' => '3.57',
'HTML::Tidy' => 0,
'HTML::Valid' => 0,
'HTTP::Request' => '5.818',
'HTTP::Request::Common' => '5.822',
'HTTP::Response' => 0,
Expand Down
27 changes: 13 additions & 14 deletions lib/npg_testing/html.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use warnings;
use Carp;
use English qw{-no_match_vars};
use Exporter;
use HTML::Tidy;
use HTML::Valid;

our $VERSION = '0';

Expand All @@ -28,21 +28,21 @@ A collection of test routines for html

## no critic (ProhibitExplicitISA)
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(html_tidy_ok);
our @EXPORT_OK = qw(html_valid_ok);

=head2 html_tidy_ok
=head2 html_valid_ok
Test utilising HTML::Tidy
Test utilising HTML::Valid
=cut
sub html_tidy_ok {
sub html_valid_ok {
my $html_string = shift;
my $tidy = HTML::Tidy->new( {} );
my $is_tidy = 1;
$tidy->parse(q[], $html_string);
if (scalar $tidy->messages() > 0) {
$is_tidy = 0;
carp (join qq[\n], q[HTML::Tidy messages:], $tidy->messages());
my $valid = HTML::Valid->new( {} );
my $is_valid = 1;
my ($output, $errors) = $valid->run($html_string);
if (scalar $errors > 0) {
$is_valid = 0;
carp (join qq[\n], q[HTML::Valid errors:], $errors);
## no critic (ProhibitStringySplit)
my @lines = split qq[\n], $html_string;
## use critic
Expand All @@ -51,8 +51,7 @@ sub html_tidy_ok {
foreach my $line (@lines) { $count++; push @counted_lines, "$count: $line"; }
carp (join qq[\n], @counted_lines);
}
$tidy->clear_messages();
return $is_tidy;
return $is_valid;
}

1;
Expand All @@ -76,7 +75,7 @@ __END__
=item Exporter
=item HTML::Tidy
=item HTML::Valid
=back
Expand Down
3 changes: 1 addition & 2 deletions t/00-critic.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ if($EVAL_ERROR) {
} else {
Test::Perl::Critic->import(
-severity => 1,
-exclude => ['tidy',
'ValuesAndExpressions::ProhibitImplicitNewlines',
-exclude => ['ValuesAndExpressions::ProhibitImplicitNewlines',
'Documentation::PodSpelling',
'RegularExpressions::ProhibitEscapedMetacharacters',
'RegularExpressions::ProhibitEnumeratedClasses',
Expand Down
6 changes: 3 additions & 3 deletions t/10-npg_testing-html.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use strict;
use warnings;
use Test::More tests => 2;

my @subs = qw(html_tidy_ok);
my @subs = qw(html_valid_ok);
use_ok( 'npg_testing::html', @subs);
can_ok(__PACKAGE__, 'html_tidy_ok');
can_ok(__PACKAGE__, 'html_valid_ok');

1;
1;

0 comments on commit cc64754

Please sign in to comment.