aboutsummaryrefslogtreecommitdiff
path: root/gemini.filter.dpi
diff options
context:
space:
mode:
authorcel <cel@lOUVT+Phkvai9a/cCS/RKo+S9hnPAQdVixms/7ldpPA=.ed25519>2020-05-19 20:22:28 -0400
committercel <cel@lOUVT+Phkvai9a/cCS/RKo+S9hnPAQdVixms/7ldpPA=.ed25519>2020-05-19 20:26:15 -0400
commitdd96e675ca9b0f50b38a6ceb2a9624a90ab74042 (patch)
tree914fdcc205e2962b1725401cfd20d49fc4c6e3a5 /gemini.filter.dpi
parent1f08735f01516b8d9989be75b5bcc40f13fa4110 (diff)
Render list items
Diffstat (limited to 'gemini.filter.dpi')
-rwxr-xr-xgemini.filter.dpi27
1 files changed, 24 insertions, 3 deletions
diff --git a/gemini.filter.dpi b/gemini.filter.dpi
index bebf3ba..86ecf8a 100755
--- a/gemini.filter.dpi
+++ b/gemini.filter.dpi
@@ -29,7 +29,10 @@ render_gemini() {
else
sed 's/^\(=>\s*\)\(\S*\)*\(.*\)/\1<a href="\2">\2<\/a>\3/' | awk '
BEGIN {
- print "<!doctype html><body style=\"font:monospace; white-space:pre-wrap\">"
+ print "<!doctype html><body><style>"\
+ "div { font:monospace; white-space:pre-wrap; }\n"\
+ "h1, h2, h3 { margin: 0; }\n"\
+ "</style>"
}
/^```/ {
if (!in_literal) {
@@ -45,16 +48,34 @@ render_gemini() {
print
next
}
+ in_list && !/^\*/ {
+ in_list = 0
+ print "</ul>"
+ }
+ /^\*/ {
+ if (!in_list) {
+ in_list = 1
+ printf "<ul>"
+ }
+ match($0, /^\*+\s*/)
+ text = substr($0, RLENGTH+1)
+ printf "<li>%s</li>\n", text
+ next
+ }
/^#+/ {
match($0, /^#+/)
tag = "h" RLENGTH
match($0, /^(#+\s*)/)
text = substr($0, RLENGTH+1)
- printf "<%s style=\"font:sans-serif\">%s</%s>", tag, text, tag
+ printf "<%s style=\"font:sans-serif\">%s</%s>\n", tag, text, tag
+ next
+ }
+ /^$/ {
+ print "<br>"
next
}
{
- print
+ printf "<div>%s</div>\n", $0
}
END {
print "</body>"