#!/usr/bin/env bash # dillo-gemini # © 2020 Charles E. Lehner # Copying and distribution of this file, with or without modification, # are permitted in any medium without royalty provided the copyright # notice and this notice are preserved. This file is offered as-is, # without any warranty. # Note: "read -d" is a Bashism; -r disables line wrapping with # backslashes read -rd '>' auth read -rd '>' cmd case "$cmd" in "\n" printf "Content-type: text/plain\r\n\r\n" echo Not found } render_gemini() { printf "Content-type: text/html\r\n\r\n" if command -v ansi2html >/dev/null then ansi2html else cat fi | awk ' function escape_html(str) { gsub(/&/, "\\&", str) gsub(//, "\\>", str) return str } BEGIN { print "" } { sub(/\r$/, "") } /^```/ { if (!in_literal) { in_literal = 1 print "
"
			} else {
				in_literal = 0
				print "
" } next } in_literal { print escape_html($0) next } in_list && !/^\*/ { in_list = 0 print "" } /^\*/ { if (!in_list) { in_list = 1 printf "