diff options
author | cel <cel@lOUVT+Phkvai9a/cCS/RKo+S9hnPAQdVixms/7ldpPA=.ed25519> | 2020-05-19 20:22:28 -0400 |
---|---|---|
committer | cel <cel@lOUVT+Phkvai9a/cCS/RKo+S9hnPAQdVixms/7ldpPA=.ed25519> | 2020-05-19 20:26:15 -0400 |
commit | dd96e675ca9b0f50b38a6ceb2a9624a90ab74042 (patch) | |
tree | 914fdcc205e2962b1725401cfd20d49fc4c6e3a5 | |
parent | 1f08735f01516b8d9989be75b5bcc40f13fa4110 (diff) |
Render list items
-rwxr-xr-x | gemini.filter.dpi | 27 |
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>" |