aboutsummaryrefslogtreecommitdiff
path: root/spartan.filter.dpi
diff options
context:
space:
mode:
Diffstat (limited to 'spartan.filter.dpi')
-rwxr-xr-xspartan.filter.dpi13
1 files changed, 11 insertions, 2 deletions
diff --git a/spartan.filter.dpi b/spartan.filter.dpi
index 27128b1..586b71d 100755
--- a/spartan.filter.dpi
+++ b/spartan.filter.dpi
@@ -83,17 +83,26 @@ serve_page() {
printf "<cmd='start_send_page' url='' '>\n"
if [ "$ftype" == "text/gemini" ]; then
+ # Use first line as title if it is a top level header
+ IFS=" \n\r" read -r -u 9 first_line
+ title=
+ case "$first_line" in
+ "# "*) title="${first_line#"# "}";;
+ *) title="${noproto}";;
+ esac
+
printf "Content-type: text/html\r\n\r\n"
echo "<!DOCTYPE html>"
echo "<html>"
echo "<head>"
- echo "<title>${noproto}</title>"
+ echo "<title>${title}</title>"
echo "<style>"
cat "$dir/style.css"
echo "</style>"
echo "</head>"
echo "<body>"
- <&9 cat | tr -d '\r' | fix_links | markdown -f +fencedcode
+ (printf "%s\n" "$first_line"; <&9 cat) \
+ | tr -d '\r' | fix_links | markdown -f +fencedcode
echo "</body>"
echo "</html>"
else