#!/usr/bin/env bash # Build the standalone web page from the Artifact source. # # _artifact/*.html is written "bare" (no doctype/html/head/body) because the # Artifact publisher supplies that skeleton itself. A file served by Apache # needs the real skeleton: this server sends no Content-Type header, so the # browser falls back to MIME sniffing, which only recognises HTML when the # file starts with . A leading tag is sniffed as plain # text, which is why the bare file rendered as source. Run this after every # edit to _artifact/. # # The source's head material (meta/title/link/style) runs up to and including # the single ; everything after it is body content. set -euo pipefail cd "$(dirname "$0")" for src in _artifact/*.html; do out="$(basename "$src")" n=$(grep -c '' "$src" || true) if [ "$n" -ne 1 ]; then echo "skip $src: expected exactly one , found $n" >&2 continue fi { printf '\n\n\n' printf '\n' awk 'NR==1,/<\/style>/' "$src" cat <<'RESET' RESET printf '\n\n' awk 'f{print} /<\/style>/{f=1}' "$src" printf '\n\n' } > "$out" printf 'built %-34s %8d bytes\n' "$out" "$(stat -c%s "$out")" done