aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rwxr-xr-xgemini.filter.dpi12
2 files changed, 11 insertions, 3 deletions
diff --git a/README.md b/README.md
index 3f19563..f1f611c 100644
--- a/README.md
+++ b/README.md
@@ -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/^\(=&gt;\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() {