         COLOR: blue foreground ,,
     ] H{ } make format nl ;
 
+: gemini-pad ( text -- text' )
+    ! XXX: break on dashes and soft-hyphens
+    80 [ over length over > ] [
+        dup pick [ blank? ] find-last-from drop
+        dup [ 2dup - 5 >= [ drop f ] when ] when
+        [ nip ] [ [ cut " " glue ] keep ] if* 81 +
+    ] while drop ;
+
 : gemini-quoted. ( text -- )
-    70 wrap-lines [ "> " write print ] each ;
+    gemini-pad 78 wrap-lines [ "> " write print ] each ;
 
 PRIVATE>
 

: read-body ( -- body )
    [ 1024 read ] loop>array concat ;

: ?read-body ( status -- body/f )
    ?first CHAR: 2 = [ read-body ] [ f ] if ;

: read-response ( -- status meta body/f )
    readln utf8 decode "\r" ?tail drop [ blank? ] split1-when over ?read-body ;

                { [ "```" ?head ] [ drop "pre" on ] }
                { [ "=>" ?head ] [ base-url gemini-link. ] }
                { [ "> " ?head ] [ gemini-quoted. ] }
                [ "pre" get [ gemini-pad 80 wrap-string ] unless print ]
            } cond
        ] each
    ] with-variable ;
