Last active
October 19, 2020 23:11
-
-
Save smartwatermelon/7f0d5e110d571cac3db667e53894b16e to your computer and use it in GitHub Desktop.
htmlValidator: @cassidoo's 2020-10-19 newsletter interview question
This file contains hidden or 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 | |
function htmlValidator () | |
{ | |
if xmllint --noout --nowarning - 2> /dev/null <<< "$1"; then | |
echo "valid"; | |
else | |
echo "not valid"; | |
fi | |
} | |
# htmlValidator '<tag>I love coding <Component />!</tag>' | |
# => valid | |
# htmlValidator '<tag>I love coding <Component />!</ta' | |
# => not valid | |
# note: xmllint is included in macOS since at least 10.7.5, probably earlier | |
# source this file to add the function, e.g. | |
# source htmlvalidator.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment