Skip to content

Commit

Permalink
Use HTML parser to validate document markup
Browse files Browse the repository at this point in the history
As the status of polyglot markup is either deprecated or undefined it's
better to use a HTML parser to validate the markup. The issue is that it
seems that Nokogiri doesn't support any HTML5 tags so we need to filter
out the errors created by those. Adding the tags to Nokogiri directly
appears to be non-trivial.
  • Loading branch information
pixeltrix committed Mar 1, 2016
1 parent 90e4528 commit 5cee223
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions features/step_definitions/validation_steps.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
Then /^the markup should be valid$/ do
document = Nokogiri::XML(page.source)
expect(document.errors).to be_empty
tags = %w[header nav main details summary section footer]
pattern = /\ATag (?:#{tags.join('|')}) invalid\z/
filter = -> (error){ error.message =~ pattern }

document = Nokogiri::HTML(page.source)
expect(document.errors.reject(&filter)).to be_empty
end

0 comments on commit 5cee223

Please sign in to comment.