]>
Commit | Line | Data |
---|---|---|
a98a223e PO |
1 | #!/bin/bash |
2 | ||
3 | set -e | |
4 | ||
5 | RET=0 | |
6 | ||
7 | OUT=`mktemp` | |
8 | ||
9 | for fn in "$@"; do | |
10 | echo "Validating $fn..." | |
11 | echo | |
12 | ||
13 | case $fn in | |
14 | *.html) | |
15 | type="text/html" | |
16 | ;; | |
17 | *.css) | |
18 | type="text/css" | |
19 | ;; | |
20 | *) | |
21 | echo "Unknown format!" | |
22 | echo | |
23 | RET=1 | |
24 | continue | |
25 | ;; | |
26 | esac | |
27 | ||
28 | curl --silent \ | |
29 | --header "Content-Type: ${type}; charset=utf-8" \ | |
30 | --data-binary @${fn} \ | |
31 | https://validator.w3.org/nu/?out=text > $OUT | |
32 | cat $OUT | |
33 | echo | |
34 | ||
35 | # We don't fail the check for warnings as some warnings are | |
36 | # not relevant for us, and we don't currently have a way to | |
37 | # ignore just those | |
38 | if grep -q -s -E "^Error:" $OUT; then | |
39 | RET=1 | |
40 | fi | |
41 | done | |
42 | ||
43 | rm $OUT | |
44 | ||
45 | exit $RET |