1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-23 12:52:10 +00:00

Add HTML-Tidy's generator tag manually

It auto-inserts it to the start of <head> but I want it at the end.
This commit is contained in:
Rohan Kumar 2023-11-15 02:26:52 -08:00
parent 6dbf6fa91c
commit bbfa381368
No known key found for this signature in database
GPG key ID: 1E892DB2A5F84479
3 changed files with 8 additions and 3 deletions

View file

@ -5,6 +5,7 @@ input-encoding: utf8
output-xhtml: yes
quiet: yes
indent: no
# I set this manually
tidy-mark: no
quote-nbsp: no
sort-attributes: alpha

View file

@ -17,7 +17,6 @@ set -e -u
html_file="$1"
tmp_file="$(mktemp)"
xhtml_file=${html_file%*.html}.xhtml
cleanup() {
rm -f "$tmp_file"
@ -33,10 +32,12 @@ run_tidy () {
sed 7d "$html_file" | xmllint --format --encode UTF-8 --noent - | tail -n +2 | run_tidy >"$tmp_file"
{
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 source=/home/rkumar/Executables/ghq/git.sr.ht/~seirdy/seirdy.one/scripts/xhtmlize.sh
sed \
-e '1,7d' \
-e "s|name=\"generator\" />|name=\"generator\" />\n${TIDY:?}|" \
-e 's|\.svg" width="16" /><span|.svg" width="16" /> <span|' \
-e 's|</span>(&nbsp;)?.span itemprop="familyName|</span>&#160;<span itemprop="familyName"|' \
-E \

View file

@ -8,6 +8,9 @@ set -e -u
output_dir="$1"
script_dir="$(dirname "$0")"
tidy_version="$(tidy -version)"
export TIDY="<meta content=\"$tidy_version\" name=\"generator\" />"
sed -e '7q;d' "$output_dir/index.html" | tr -d '\t' >"$output_dir/tmp.css"
cleanup() {
rm -f "$output_dir/tmp.css"
@ -16,5 +19,5 @@ trap cleanup EXIT
export XMLLINT_INDENT=' '
export OUTPUT_DIR="$output_dir"
find "$output_dir" -type f -name '*.html' | xargs -n1 sh "$script_dir/xhtmlize-single-file.sh"
find "$output_dir" -type f -name '*.html' -exec sh "$script_dir/xhtmlize-single-file.sh" {} \;
# done