#!/usr/bin/awk -f # HAT TRICK # (C) 2022 C. Duckworth # ht.awk converts mostly-html (with some conveniences) to actual html function bufpush(s) { BUF = BUF (BUF ? "\n" : "") s; } function buflush() { if (BUF) print BUF; BUF = ""; if (tag && (tag != "html")) print "" tag ">"; } function esc(t) { gsub(/&/, "\\&", t); gsub(/, "\\<", t); gsub(/>/, "\\>", t); return t; } /^;/ { sub(/^;/,""); print ""; next; } /^ { # Raw HTML if (! (tag == "html")) tag = "html"; bufpush($0); next; } /^=>/ { # Links (Gemini-style) link = "" esc($3); for (i=4;i<=NF;i++) link = link " " esc($i); link = link ""; bufpush(link); next; } /^-/ { # Unordered lists if (! (tag == "ul")) tag = "ul"; esc($0); sub(/^-[ \t]*/, "