1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-09 16:02:10 +00:00

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
This commit is contained in:
Rohan Kumar 2022-05-31 17:16:44 -07:00
parent c936ca1902
commit b4850ed89a
No known key found for this signature in database
GPG key ID: 1E892DB2A5F84479
4 changed files with 9 additions and 16 deletions

View file

@ -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:

View file

@ -1,5 +1,5 @@
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<meta charset="UTF-8" />
{{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }}
<meta name="disabled-adaptations" content="watch" /><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
{{ if or (eq site.BaseURL site.Params.CanonicalBaseURL) (in site.BaseURL "wgq3bd2kqoybhstp77i3wrzbfnsyd27wt34psaja4grqiezqircorkyd.onion") -}}
@ -8,7 +8,7 @@
<link href="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}" rel="canonical" />
<link href="{{ .Site.Params.WebmentionEndpoint }}" rel="webmention" />
{{ $webmanifest := resources.Get "/manifest.webmanifest" | resources.ExecuteAsTemplate "manifest.webmanifest" . | resources.Minify | resources.Fingerprint "md5" -}}
{{- printf `<link href="%s" rel="manifest" />` $webmanifest.RelPermalink | safeHTML }}
{{- printf `<link href="%s" rel="manifest" />` $webmanifest.RelPermalink | safeHTML -}}
<!--Feeds for both notes and posts; posts come first unless we're in the notes section.-->
{{- $isNotes := false -}}
{{- if or (eq .Section "notes") (eq .Title "Notes") -}}

View file

@ -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
)
)

View file

@ -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 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" | cat - "$0" | grep -Fv "<meta charset=\"UTF-8\" />" >"${0%*.html}.xhtml"' {} \;
# done