1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-10 00:12:09 +00:00
seirdy.one/scripts/xhtmlize.sh
Rohan Kumar b4850ed89a
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
2022-05-31 17:16:44 -07:00

11 lines
525 B
Bash

#!/bin/sh
# takes an arg for the output dir.
# 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.
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