-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathChecks
36 lines (30 loc) · 1.12 KB
/
Checks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require 'open3'
require 'json'
check :html5 do
cmd = "java -jar opt/validator/vnu.jar --format json --skip-non-html --schema http://s.validator.nu/html5-all.rnc #{@config[:output_dir]}"
res = Open3.popen3(cmd) { |_stdin, _stdout, stderr| stderr.read }
JSON.parse(res).fetch('messages', []).each do |err|
subject = err['url'].sub(/^file:#{Regexp.escape File.dirname(__FILE__)}\//, '')
add_issue("#{err['message']} (line #{err['lastLine']}, column #{err['firstColumn']})", subject: subject)
end
end
check :no_unprocessed_erb do
@output_filenames.each do |filename|
if @config[:text_extensions].any? { |ext| filename =~ /#{ext}$/ } && File.read(filename).match(/<%/)
add_issue("erb detected", :subject => filename)
end
end
end
check :no_unprocessed_markdown do
@output_filenames.each do |filename|
if filename =~ /html$/ && File.read(filename).match(/]\(/)
add_issue('unprocessed markdown detected', subject: filename)
end
end
end
deploy_check :internal_links
deploy_check :mixed_content
deploy_check :stale
deploy_check :no_unprocessed_erb
deploy_check :no_unprocessed_markdown
# vi: ft=ruby