#!/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) { # This is of much more limited utility than I initially realized. 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 = "" $3; for (i=4;i<=NF;i++) link = link " " $i; link = link ""; bufpush(link); next; } /^-/ { # Unordered lists if (! (tag == "ul")) tag = "ul"; sub(/^-[ \t]*/, "