------------------------------------------------------------
#!/bin/bash
# 2020-11-21
# gem2html.sh file.gmi > file.html

filename="${1}"

title="${filename##*/}"

addr_pub="your-onion-site-hash-here.onion"

cat <

  
    
    
    ${title}
  
  
EOF

OLDIFS=$IFS
IFS='' # preserve (leading!) white space, e.g. in 
...
in_list=0 in_pre=0 ( cat ${filename} && echo "") | while read line do if [ $in_list -eq 1 ] then case "${line}" in (\**) in_list=1 text=$(echo "$line" | sed -e 's/^[*][ ]*//') echo "
  • ${text}
  • " ;; (*) in_list=0 # fall through into next case! echo " " esac elif [ $in_pre -eq 1 ] then case "${line}" in (\`\`\`*) echo "
    " in_pre=0 continue ;; (*) # emacs/eww chokes on '<>' in pre section? text=$(echo "$line" | sed -e 's//\>/g') echo "$text" ;; esac fi if [[ $in_list -eq 0 && $in_pre -eq 0 ]] then case "${line}" in (\#[^#]*) text=$(echo "$line" | sed -e 's/^#[ ]*//') echo "

    ${text}

    " ;; (\#\#[^#]*) text=$(echo "$line" | sed -e 's/^##[ ]*//') echo "

    ${text}

    " ;; (\#\#\#[^#]*) text=$(echo "$line" | sed -e 's/^###[ ]*//') echo "

    ${text}

    " ;; (\=\>*) text=$(echo "$line" | sed -e 's/^=>[ ]*//') link=$(echo "$text" | cut -d' ' -f1) desc=$(echo "$text" | cut -d' ' -f2- | sed -e 's|^[ ]*||') # rewrite site internal links case "${link}" in (/*\.gmi) link=$( echo "${link}" | sed -e 's|\.gmi$|.html|' ) ;; (*) : ;; esac echo "

    ${desc}

    " ;; (\>*) text=$(echo "$line" | sed -e 's/^>[ ]*//') echo "

    ${text}

    " ;; (\**) in_list=1 text=$(echo "$line" | sed -e 's/^[*][ ]*//') echo "