mirror of
https://git.sr.ht/~seirdy/seirdy.one
synced 2024-11-27 14:12:09 +00:00
use html-tidy to format my pages
This commit is contained in:
parent
9e54f9321f
commit
72aa3606c5
2 changed files with 9 additions and 4 deletions
|
@ -4,3 +4,5 @@ char-encoding: utf8
|
||||||
input-encoding: utf8
|
input-encoding: utf8
|
||||||
output-xhtml: yes
|
output-xhtml: yes
|
||||||
quiet: yes
|
quiet: yes
|
||||||
|
indent: no
|
||||||
|
tidy-mark: no
|
||||||
|
|
|
@ -24,11 +24,15 @@ cleanup() {
|
||||||
}
|
}
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
run_tidy () {
|
||||||
|
tidy -asxhtml -config linter-configs/tidy.conf 2>/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
# delete the stylesheet from the html file; we'll re-insert it later.
|
# delete the stylesheet from the html file; we'll re-insert it later.
|
||||||
# Also remove two indentation levels
|
# Also remove two indentation levels
|
||||||
sed 7d "$html_file" | xmllint --format --encode UTF-8 --noent - | tail -n +2 | sd '^\t(?:\t)?' '' >"$tmp_file"
|
sed 7d "$html_file" | xmllint --format --encode UTF-8 --noent - | tail -n +2 | sd '^\t(?:\t)?' '' | run_tidy >"$tmp_file"
|
||||||
{
|
{
|
||||||
head -n7 "$tmp_file" | sd -s '/>' ' />'
|
head -n7 "$tmp_file"
|
||||||
cat "$OUTPUT_DIR/tmp.css"
|
cat "$OUTPUT_DIR/tmp.css"
|
||||||
# shellcheck disable=SC2016 # these are regex statements, not shell expressions
|
# shellcheck disable=SC2016 # these are regex statements, not shell expressions
|
||||||
tail -n +8 "$tmp_file" \
|
tail -n +8 "$tmp_file" \
|
||||||
|
@ -38,6 +42,5 @@ sed 7d "$html_file" | xmllint --format --encode UTF-8 --noent - | tail -n +2 | s
|
||||||
| sd -s ' ' ' ' \
|
| sd -s ' ' ' ' \
|
||||||
| sd -f m 'class="u-photo photo"[^<]*<' 'class="u-photo photo"/> <' \
|
| sd -f m 'class="u-photo photo"[^<]*<' 'class="u-photo photo"/> <' \
|
||||||
| sd '([a-z])<(data|time)' '$1 <$2' \
|
| sd '([a-z])<(data|time)' '$1 <$2' \
|
||||||
| sd '</span>(<a[^>]*rel="(?:nofollow ugc|ugc nofollow)"(?:[^>]*)?>liked</a>)' '</span> $1' \
|
| sd '</span>(<a[^>]*rel="(?:nofollow ugc|ugc nofollow)"(?:[^>]*)?>liked</a>)' '</span> $1'
|
||||||
| sd '([^ ])/>' '$1 />'
|
|
||||||
} >"$html_file"
|
} >"$html_file"
|
||||||
|
|
Loading…
Reference in a new issue