From b4850ed89a9e13a267ce52333e46ef87ed213c5b Mon Sep 17 00:00:00 2001 From: Rohan Kumar Date: Tue, 31 May 2022 17:16:44 -0700 Subject: [PATCH] Use XML declaration on XHTML, other XHTML tweaks - Remove XHTML content-type meta header from HTML documents, reverting back to the meta charset - Give XHTML documents their own XHTML declaration - Remove now-redundant meta charset from XHTML - Since XHTML and HTML documents differ now, compress after running xhtmlize and make xhtmlize only act on uncompressed files. - Validate XHTML using vnu --- Makefile | 4 ++-- layouts/partials/head.html | 4 ++-- linter-configs/vnu_filter.jq | 6 ------ scripts/xhtmlize.sh | 11 +++++------ 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index bbc29f3..3fc5f2c 100644 --- a/Makefile +++ b/Makefile @@ -104,8 +104,8 @@ deploy: deploy-html deploy-gemini .prepare-deploy: @$(MAKE) clean @$(MAKE) hugo - @$(MAKE) compress @$(MAKE) xhtmlize + @$(MAKE) compress # deploy steps need to happen one at a time .PHONY: deploy-prod @@ -127,8 +127,8 @@ deploy-staging: .lint-and-prepare-deploy: @$(MAKE) clean @$(MAKE) hugo - @$(MAKE) lint-local compress @$(MAKE) xhtmlize + @$(MAKE) lint-local compress .PHONY: lint-and-deploy-staging lint-and-deploy-staging: diff --git a/layouts/partials/head.html b/layouts/partials/head.html index d55ff08..e5bcf9a 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,5 +1,5 @@ - + {{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }} {{ if or (eq site.BaseURL site.Params.CanonicalBaseURL) (in site.BaseURL "wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion") -}} @@ -8,7 +8,7 @@ {{ $webmanifest := resources.Get "/manifest.webmanifest" | resources.ExecuteAsTemplate "manifest.webmanifest" . | resources.Minify | resources.Fingerprint "md5" -}} -{{- printf `` $webmanifest.RelPermalink | safeHTML }} +{{- printf `` $webmanifest.RelPermalink | safeHTML -}} {{- $isNotes := false -}} {{- if or (eq .Section "notes") (eq .Title "Notes") -}} diff --git a/linter-configs/vnu_filter.jq b/linter-configs/vnu_filter.jq index 18204ca..8bb1301 100644 --- a/linter-configs/vnu_filter.jq +++ b/linter-configs/vnu_filter.jq @@ -11,14 +11,8 @@ or ( # See https://github.com/validator/validator/issues/1166 .message == "Attribute “media” not allowed on element “meta” at this point." - and .firstColumn == 1 and (.extract | test(" name=\"theme-color\"")) ) - or - ( # XHTML5 gang - .message == "Bad value “application/xhtml+xml; charset=utf-8” for attribute “content” on element “meta”: The legacy encoding declaration did not start with “text/html;”." - and .firstColumn == 1 - ) ) | not ) ) diff --git a/scripts/xhtmlize.sh b/scripts/xhtmlize.sh index aa42f7d..d7cd4eb 100644 --- a/scripts/xhtmlize.sh +++ b/scripts/xhtmlize.sh @@ -1,12 +1,11 @@ #!/bin/sh # takes an arg for the output dir. -# copies every .html file to an equivalent .xhtml file. -# does the same for compressed html files. +# copies every .html file to an equivalent .xhtml file, but replaces +# the meta charset with an XML declaration for compatibility with some +# XML tooling. # this means that every index.html file has an equivalent index.xhtml file. # content negotiation allows an agent to pick html or xhtml. -# too lazy to DRY this shit -find "$1" -type f -name '*.html' -exec sh -c 'cp "$0" "${0%*.html}.xhtml"' {} \; -find "$1" -type f -name '*.html.gz' -exec sh -c 'cp "$0" "${0%*.html.gz}.xhtml.gz"' {} \; -find "$1" -type f -name '*.html.br' -exec sh -c 'cp "$0" "${0%*.html.br}.xhtml.br"' {} \; +find "$1" -type f -name '*.html' \ + -exec sh -c 'echo "" | cat - "$0" | grep -Fv "" >"${0%*.html}.xhtml"' {} \; # done