diff --git a/linter-configs/tidy.conf b/linter-configs/tidy.conf index 4f57f4a..363e0d3 100644 --- a/linter-configs/tidy.conf +++ b/linter-configs/tidy.conf @@ -6,3 +6,5 @@ output-xhtml: yes quiet: yes indent: no tidy-mark: no +quote-nbsp: no +sort-attributes: alpha diff --git a/scripts/populate-webrings.sh b/scripts/populate-webrings.sh index 139d8c9..358d163 100755 --- a/scripts/populate-webrings.sh +++ b/scripts/populate-webrings.sh @@ -56,60 +56,20 @@ while getopts "hd" flags; do esac done -trim_trailing_comma() { - sd ',$' '' -} - -values_to_csv() { - tr '\n' ',' | trim_trailing_comma && echo -} - -# values for the GEORGE webring -# Left bc I quit trying to make a good first-party iframe alternative -# that conformed to my site design standards while also imparting the -# message of GEORGE as intended. -# george() { -# printf 'GEORGE,' -# { -# curl -sSL --compressed 'https://george.gh0.pw/embed.cgi?seirdy' \ -# | htmlq -a href 'main p a' -# echo "null" -# } | values_to_csv -# } -# endless_orbit() { printf 'Endless Orbit,' - { - curl -sSL --compressed https://linkyblog.neocities.org/onionring/onionring-variables.js \ - | grep -C 1 https://seirdy.one/ - echo "'null'," - } | sd https://seirdy.one/ https://linkyblog.neocities.org/webring.html \ - | sd "\n|'" '' | trim_trailing_comma - echo -} - -netizens() { - printf 'Netizens,' - { - curl -sSL --compressed https://netizensring.link/onionring-variables.js \ - | grep -C 1 https://seirdy.one/ - } | sd 'https://seirdy.one/,?' 'https://netizensring.link/' \ - | sd "\n|'|\r" '' | trim_trailing_comma - echo ',null' -} - -print_csv_values() { - # george - endless_orbit - # netizens + curl -sSL --compressed https://linkyblog.neocities.org/onionring/onionring-variables.js \ + | grep -C 1 https://seirdy.one/ \ + | tr -d "'\n" | sed 's|https://seirdy.one/|https://linkyblog.neocities.org/webring.html|' + echo 'null' } if [ "$dry_run" = '1' ]; then - print_csv_values + endless_orbit elif [ -f "$webrings_dest" ]; then echo "webrings file already generated" else - print_csv_values | cat "$webrings_src" - >"$webrings_dest" + endless_orbit | cat "$webrings_src" - >"$webrings_dest" fi # vi:ft=sh diff --git a/scripts/xhtmlize-single-file.sh b/scripts/xhtmlize-single-file.sh index f140638..317b156 100644 --- a/scripts/xhtmlize-single-file.sh +++ b/scripts/xhtmlize-single-file.sh @@ -10,13 +10,13 @@ # use xmllint to do the formatting. # xmllint ruins inline CSS so delete the inline CSS and re-insert it. # xmllint also adds extra whitespace around
 which we remove
-# with "sd". I chose sd since it handles newlines well.
+# with sed.
 # It also decreases indents by one level
 
 set -e -u
 
 html_file="$1"
-tmp_file="$html_file.tmp"
+tmp_file="$(mktemp)"
 xhtml_file=${html_file%*.html}.xhtml
 
 cleanup() {
@@ -30,17 +30,18 @@ run_tidy () {
 
 # delete the stylesheet from the html file; we'll re-insert it later.
 # Also remove two indentation levels
-sed 7d "$html_file" | xmllint --format --encode UTF-8 --noent - | tail -n +2 | sd '^\t(?:\t)?' '' | run_tidy >"$tmp_file"
+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"
 	# shellcheck disable=SC2016 # these are regex statements, not shell expressions
-	tail -n +8 "$tmp_file" \
-		| sd '\n(?:\t|\s)*<(code|samp)( |>)' '
<$1$2' \
-		| sd '(?:\n)?\n(?:[\t\s]*)?
' '
' \ - | sd '(?: )?.span itemprop="familyName"' '  <' \ - | sd '([a-z])<(data|time)' '$1 <$2' \ - | sd '(]*rel="(?:nofollow ugc|ugc nofollow)"(?:[^>]*)?>liked)' ' $1' + sed \ + -e '1,7d' \ + -e 's|\.svg" width="16" /> ( )?.span itemprop="familyName| (]*rel="(nofollow ugc|ugc nofollow)"([^>]*)?>liked)# \1#' \ + -e 's#\n(\t|\s)*<(code|samp)( |>)#
<\3\4#' \
+			"$tmp_file"
 } >"$html_file"