13 gemini_link "$line" $pre
15 \#*) gemini_header "$line" $pre ;;
16 \**) gemini_list "$line" $pre ;;
17 *) gemini_text "$line" $pre ;;
23 local re="^(=>)[[:blank:]]*([^[:blank:]]+)[[:blank:]]*(.*)"
24 local s t a # sigil, text, annotation(url)
25 if ! ${2-false} && [[ "$1" =~ $re ]]; then
26 s="${BASH_REMATCH[1]}"
27 t="${BASH_REMATCH[3]}"
28 a="${BASH_REMATCH[2]}"
30 printf "$C_SIGIL%-${MARGIN}s" "$s"
31 fold_line "$WIDTH" "$(printf "$C_LINK_TITLE%s $C_LINK_URL%s$C_RESET\n" \
39 local re="^(#+)[[:blank:]]*(.*)"
40 local s t a # sigil, text, annotation(lvl)
41 if ! ${2-false} && [[ "$1" =~ $re ]]; then
42 s="${BASH_REMATCH[1]}"
43 a="${#BASH_REMATCH[1]}"
44 t="${BASH_REMATCH[2]}"
47 hdrfmt="$(eval echo "\$C_HEADER$a")"
48 printf "$C_SIGIL%-${MARGIN}s$hdrfmt%s$C_RESET\n" \
49 "$s" "$(fold_line "$WIDTH" "$t")"
56 local re="^(\*)[[:blank:]]*(.*)"
57 local s t a # sigil, text, annotation(n/a)
58 if ! ${2-false} && [[ "$1" =~ $re ]]; then
59 s="${BASH_REMATCH[1]}"
60 t="${BASH_REMATCH[2]}"
62 printf "$C_SIGIL%-${MARGIN}s$C_LIST%s$C_RESET\n" \
63 "$s" "$(fold_line "$WIDTH" "$t")"
70 printf "%${MARGIN}s" ' '
72 fold_line "$WIDTH" "$1"
79 printf "%${MARGIN}s%s" ' ' "$1"
83 [[ "${!1}" == true || "${!1}" == false ]] || return 1
92 fold_line() { # fold_line WIDTH TEXT
95 # shellcheck disable=2086
96 # TODO: determine if this is the best way to do it
100 plain="${word//$'\x1b'\[*([0-9;])m/}"
101 wl=$((${#plain} + 1))
102 if (((ll + wl) >= width)); then
103 printf "\n%${MARGIN}s" ' '
113 # just here for reference
114 strip() { # strip control sequences
115 # https://stackoverflow.com/a/55872518
117 while IFS='' read -r x; do
119 echo "${x//$'\x1b'\[*([0-9;])m/}"
126 #shopt -s checkwinsize; (:;:)
127 #WIDTH="$((COLUMNS - (MARGIN*2)))"
128 C_LINK_TITLE=$'\e[34m'
131 typeset_gemini <<-'EOF'
136 Gemini is a new internet protocol which:
138 * Is heavier than gopher
139 * Is lighter than the web
140 * Will not replace either
141 * Strives for maximum power to weight ratio
142 * Takes user privacy very seriously
146 => docs/ Gemini documentation
147 => software/ Gemini software
148 => servers/ Known Gemini servers
149 => https://lists.orbitalfox.eu/listinfo/gemini Gemini mailing list
150 => gemini://gemini.conman.org/test/torture/ Gemini client torture test
154 => https://portal.mozz.us/?url=gemini%3A%2F%2Fgemini.circumlunar.space%2F&fmt=fixed Gemini-to-web proxy service
155 => https://proxy.vulpes.one/gemini/gemini.circumlunar.space Another Gemini-to-web proxy service
159 => gemini://gus.guru/ Gemini Universal Search engine
160 => gemini://houston.coder.town Houston search engine
162 ## Geminispace aggregators (experimental!)
165 => gemini://rawtext.club:1965/~sloum/spacewalk.gmi Spacewalk
167 ## Free Gemini hosting
169 => users/ Users with Gemini content on this server