diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 9f8e606c..119d6af8 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -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 \ diff --git a/Build.PL b/Build.PL index 2a9b5f6a..ca5ad317 100644 --- a/Build.PL +++ b/Build.PL @@ -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, diff --git a/lib/npg_testing/html.pm b/lib/npg_testing/html.pm index bc5c5577..6ed62d02 100644 --- a/lib/npg_testing/html.pm +++ b/lib/npg_testing/html.pm @@ -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'; @@ -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 @@ -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; @@ -76,7 +75,7 @@ __END__ =item Exporter -=item HTML::Tidy +=item HTML::Valid =back diff --git a/t/00-critic.t b/t/00-critic.t index 3d055c3f..655953dc 100644 --- a/t/00-critic.t +++ b/t/00-critic.t @@ -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', diff --git a/t/10-npg_testing-html.t b/t/10-npg_testing-html.t index 0f83c924..3acdd222 100644 --- a/t/10-npg_testing-html.t +++ b/t/10-npg_testing-html.t @@ -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; \ No newline at end of file +1;