html-lint.sh 660 Bytes
Newer Older
FluidPublicBot's avatar
FluidPublicBot committed
1 2
#!/usr/bin/env bash

3 4 5
# This script locates all the generated HTML files and runs the linter
# Tidy-HTML against them, so the content served fulfills the HTML standards.

6 7 8 9 10
GC='\033[0;32m'
NC='\033[0m'

ERRORS=0

FluidPublicBot's avatar
FluidPublicBot committed
11
while IFS= read -r FILE;do
12
  # Erase empty span tags created by Pygments (known and accepted issue)
FluidPublicBot's avatar
FluidPublicBot committed
13 14
  sed -i 's/<span\ class=".\{1,3\}"><\/span>//g' "$FILE"
  echo -e "${GC}$FILE${NC}";
15
  # Run Tidy-HTML against the generagted files
FluidPublicBot's avatar
FluidPublicBot committed
16
  if ! tidy -e -q "$FILE";then
17 18
    ERRORS=1;
  fi;
FluidPublicBot's avatar
FluidPublicBot committed
19
done < <(find output -iname '*.html')
20 21 22 23 24 25

if [ "$ERRORS" = "0" ];then
  echo -e "${GC}Los HTML generados cumplen con los estándares para HTML5${NC}";
fi;

exit $ERRORS