-
-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #362 from jeremy/html5
HTML5 parsing and error checking
- Loading branch information
Showing
19 changed files
with
121 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
source 'http://rubygems.org' | ||
source 'https://rubygems.org' | ||
|
||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
class HtmlCheck < ::HTMLProofer::Check | ||
# tags embedded in scripts are used in templating languages: http://git.io/vOovv | ||
SCRIPT_EMBEDS_MSG = /Element script embeds close tag/.freeze | ||
INVALID_TAG_MSG = /Tag ([\w\-:]+) invalid/.freeze | ||
INVALID_PREFIX = /Namespace prefix/.freeze | ||
PARSE_ENTITY_REF = /htmlParseEntityRef: no name/.freeze | ||
DOCTYPE_MSG = /The doctype must be the first token in the document/.freeze | ||
|
||
def run | ||
@html.errors.each do |error| | ||
message = error.message | ||
line = error.line | ||
|
||
if message =~ INVALID_TAG_MSG || message =~ INVALID_PREFIX | ||
next unless options[:validation][:report_invalid_tags] | ||
end | ||
|
||
if message =~ PARSE_ENTITY_REF | ||
next unless options[:validation][:report_missing_names] | ||
end | ||
|
||
# tags embedded in scripts are used in templating languages: http://git.io/vOovv | ||
next if !options[:validation][:report_script_embeds] && message =~ SCRIPT_EMBEDS_MSG | ||
add_issue(error.message, line: error.line) if report?(error.message) | ||
end | ||
end | ||
|
||
add_issue(message, line: line) | ||
def report?(message) | ||
case message | ||
when SCRIPT_EMBEDS_MSG | ||
options[:validation][:report_script_embeds] | ||
when INVALID_TAG_MSG, INVALID_PREFIX | ||
options[:validation][:report_invalid_tags] | ||
when PARSE_ENTITY_REF | ||
options[:validation][:report_missing_names] | ||
when DOCTYPE_MSG | ||
options[:validation][:report_missing_doctype] | ||
else | ||
true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<nav> | ||
</nav> | ||
<article> | ||
<p>Some text</p> | ||
</article> | ||
</body> | ||
<body> | ||
<nav></nav> | ||
<article> | ||
<p>Some text</p> | ||
</article> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<a href="http://www.google.com" onClick="window.open('https://calendar.google.com/calendar/embed?src=o3uckm13gkcc5tu4u3846ik0pc%40group.calendar.google.com&ctz=America/Los_Angeles','Team Calendar','')"> | ||
<a href="http://www.google.com" onClick="window.open('https://calendar.google.com/calendar/embed?src=o3uckm13gkcc5tu4u3846ik0pc%40group.calendar.google.com&ctz=America/Los_Angeles','Team Calendar','')"></a> |
Oops, something went wrong.