Last active
September 11, 2018 09:09
-
-
Save samber/db98fd083efa0d763e4d888f37c2935f to your computer and use it in GitHub Desktop.
html validation script (epitech)
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
<html> | |
<body> | |
<p> | |
</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
#!/bin/bash | |
if [ $# != 2 ]; then | |
echo "usage: ./validate-w3c-html.sh <index.html> <error|info>" | |
exit 1 | |
fi | |
html_file=$1 | |
log_level=$2 | |
function check() { | |
echo "[$1]" | |
curl -H "Content-Type: text/html; charset=utf-8" \ | |
--data-binary @${html_file} -s \ | |
https://validator.w3.org/nu/?out=json | jq -r '.messages[] | select(.type=="'${1}'") | .message' | |
echo | |
} | |
check "error" | |
if [ ${log_level} = "info" ]; then | |
check "info" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment