From bbfa381368a8f06b15d0403710f80061820b9873 Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Wed, 15 Nov 2023 02:26:52 -0800 Subject: [PATCH] Add HTML-Tidy's generator tag manually It auto-inserts it to the start of but I want it at the end. --- linter-configs/tidy.conf | 1 + scripts/xhtmlize-single-file.sh | 5 +++-- scripts/xhtmlize.sh | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/linter-configs/tidy.conf b/linter-configs/tidy.conf index 363e0d3..fb2e8f5 100644 --- a/linter-configs/tidy.conf +++ b/linter-configs/tidy.conf @@ -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 diff --git a/scripts/xhtmlize-single-file.sh b/scripts/xhtmlize-single-file.sh index 41a9d56..98e6706 100644 --- a/scripts/xhtmlize-single-file.sh +++ b/scripts/xhtmlize-single-file.sh @@ -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 itemprop="familyName| " + 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