diff options
-rw-r--r-- | README.md | 2 | ||||
-rwxr-xr-x | gemini.filter.dpi | 12 |
2 files changed, 11 insertions, 3 deletions
@@ -10,6 +10,8 @@ dillo-gemini requires the `openssl` command-line tool. +[ansi2html](https://pypi.org/project/ansi2html/) is optionally required to render pages that use ANSI escape codes (e.g. for colors). + This repo is hosted on the [SSB Network][SSB] using [git-ssb][]. ```sh diff --git a/gemini.filter.dpi b/gemini.filter.dpi index 3400c45..c9e17d1 100755 --- a/gemini.filter.dpi +++ b/gemini.filter.dpi @@ -22,9 +22,15 @@ serve_404() { } render_gemini() { - printf "Content-type: text/html\r\n\r\n<!doctype html><pre>" - sed 's/^\(=>\s*\)\(\S*\)*\(.*\)/\1<a href="\2">\2<\/a>\3/' - printf "%s" "</pre>" + printf "Content-type: text/html\r\n\r\n" + if which ansi2html 2>&1 >/dev/null + then + ansi2html | sed 's/^\(=>\s*\)\(\S*\)*\(.*\)/\1<a href="\2">\2<\/a>\3/' + else + printf "<!doctype html><pre>" + sed 's/^\(=>\s*\)\(\S*\)*\(.*\)/\1<a href="\2">\2<\/a>\3/' + printf "%s" "</pre>" + fi } send_status_msg() { |