forked from garretfick/openplcproject.github.io
-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathRakefile
61 lines (53 loc) · 1.69 KB
/
Rakefile
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require 'nokogiri'
task :checkhtml do
sh "bundle exec jekyll build"
num_with_errors = 0
last_error = ""
files = Dir['_site/**/*.html']
for file_name in files do
file = File.open(file_name).read
# Max errors is default to nil, which returns 0 error. This just
# needs any positive number of which 10 satisfies the conditions
begin
doc = Nokogiri::HTML5(file, max_errors: 10)
if doc.errors.length > 0
puts("Error: " + file_name + "\n")
doc.errors.each do |err|
puts(err)
last_error = err
end
num_with_errors += 1
else
puts("OK: " + file_name + "\n")
end
rescue => ex
puts("Error: " + file_name + "\n")
puts(ex)
num_with_errors += 1
end
end
if num_with_errors > 0
puts("Num files with errors:" + num_with_errors.to_s + "\n")
raise "One or more files contains an error. Last error: " + last_error
end
end
task :spellcheck do
sh "bundle exec jekyll build"
sh "aspell --lang=en create master ./aspell-dict.rws < ./aspell-dict.txt"
num_with_errors = 0
last_error = ""
files = Dir['_site/**/*.html']
for file_name in files do
misspelled = `cat #{file_name} | aspell --list -H --html-skip=script --add-html-skip=style --add-html-skip=pre --add-html-skip=code --extra-dicts=./aspell-dict.rws | sed '/^$/d'`
if misspelled.length > 0
puts("Error: " + file_name + " words: " + misspelled)
num_with_errors += 1
else
puts("OK: " + file_name)
end
end
if num_with_errors > 0
puts("Num files with errors:" + num_with_errors.to_s + "\n")
raise "One or more files contains an misspelling. Add false positives to aspell-dict.txt"
end
end