#!/bin/sed -Ef
gmi2html: Sed script to convert text/gemini to html.
Based on v0.14.2 of the gemini spec.
#
This script is dedicated to the public domain according to the terms of CC0:
https://creativecommons.org/publicdomain/zero/1.0/
TODO: add meta charset header, I suppose, to ensure utf8?
s/\&/\&/g
s/"/\"/g
s/\</g
/^=?>/! s/>/\>/g
/^=?>/ {
:loop
s/^((=?>).*)>/\1\>/
t loop
}
1 {
i\
\
h
s/^#\s*//
t title_set
s/.*/Untitled/
:title_set
s/.*/
p
i\
s/.*//
x
}
x
/^```/ {
x
/^```/ {
s/.*/<\/pre>/
h
}
b end
}
/^(\*|=>) / {
x
/^(\*|=>) / {
s/^\* (.*)/
s/^=>\s*([^[:space:]]+)\s*$/
s/^=>\s*([^[:space:]]+)\s+(.+)/
b end
}
i\
h
}
g
t linetypes
:linetypes
s/^```.*/
/s/^\* (.*)/