aboutsummaryrefslogtreecommitdiff
path: root/scripts/tidy-content.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-02-14 23:09:21 -0300
committerEuAndreh <eu@euandre.org>2020-02-14 23:09:21 -0300
commit59d41b136edcc728499c4bd2da3a010e34581d3f (patch)
treef55e6c8224dfc7ac0cce6e2b1d9fc85ef44c3bf7 /scripts/tidy-content.sh
parent.build.yml: Don't publish when not on master branch (diff)
parentImprove error message of tidy-content.sh (diff)
downloadeuandre.org-59d41b136edcc728499c4bd2da3a010e34581d3f.tar.gz
euandre.org-59d41b136edcc728499c4bd2da3a010e34581d3f.tar.xz
Merge branch 'tidy'
Add HTML linting and identing validation step.
Diffstat (limited to 'scripts/tidy-content.sh')
-rwxr-xr-xscripts/tidy-content.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/tidy-content.sh b/scripts/tidy-content.sh
new file mode 100755
index 0000000..6dc13c6
--- /dev/null
+++ b/scripts/tidy-content.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+set -Eeuo pipefail
+
+end="\033[0m"
+red="\033[0;31m"
+red() { echo -e "${red}${1}${end}"; }
+
+usage() {
+ red "Missing argument <${1}>.\n"
+ cat <<EOF
+Usage:
+ $0 <INPUT_DIR>
+
+ Arguments:
+ INPUT_DIR Input directory with the static HTML to be tidy-ed
+
+Examples:
+ $0 _site/
+EOF
+}
+
+INPUT_DIR="${1:-}"
+[[ -z "${INPUT_DIR}" ]] && {
+ usage 'INPUT_DIR'
+ exit 2
+}
+
+format() {
+ echo "${1}" >&2
+ tidy --quiet yes -utf8 -indent -modify "${1}"
+}
+export -f format
+
+find "${INPUT_DIR}" -type f -name '*.html' -print0 | \
+ xargs -0 -I{} bash -c "format {}"