Skip to content

Commit 3f3d91f

Browse files
committed
handle html5validator
1 parent 5a58dee commit 3f3d91f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Dangerfile

+27
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,33 @@ else
279279
end
280280
end
281281

282+
# Handle `html5validator` output
283+
#
284+
# Example:
285+
# WARNING:html5validator.validator:"file:/home/coder/mystamps/src/main/webapp/WEB-INF/views/series/info.html":110.11-114.58: error: very long err msg.
286+
# "file:/home/coder/mystamps/src/main/webapp/WEB-INF/views/series/info.html":438.16-438.35: error: very long err msg.
287+
#
288+
validator_output = 'validator.log'
289+
unless File.file?(validator_output)
290+
warn("Couldn't find #{validator_output}. html5validator result is unknown")
291+
else
292+
errors_count = 0
293+
File.readlines(validator_output).each do |line|
294+
line.sub!(/^WARNING:html5validator.validator:/, '')
295+
296+
parsed = line.match(/^"file:(?<file>[^"]+)":(?<line>\d+)[^:]+: error: (?<msg>.+)/)
297+
msg = parsed['msg'].sub(/\.$/, '')
298+
file = parsed['file'].sub(pwd, '')
299+
lineno = parsed['line']
300+
file = github.html_link("#{file}#L#{lineno}")
301+
302+
fail("html5validator error in #{file}:\n#{msg}")
303+
end
304+
305+
# TODO: add link to wiki page (#541)
306+
print_errors_summary 'html5validator', errors_count
307+
end
308+
282309
# Handle `mvn org.apache.maven.plugins:maven-compiler-plugin:compile` output
283310
# Handle `mvn org.apache.maven.plugins:maven-compiler-plugin:testCompile` output
284311
# Handle `mvn org.codehaus.gmaven:gmaven-plugin:testCompile` output

0 commit comments

Comments
 (0)