damus.io

damus.io website
git clone git://jb55.com/damus.io
Log | Files | Refs | README | LICENSE

gmi2md (451B)


      1 #!/usr/bin/env sedef
      2 
      3 # gmi2md: Sed script to convert text/gemini to markdown.
      4 # Based on v0.14.2 of the gemini spec.
      5 #
      6 # This script is dedicated to the public domain according to the terms of CC0:
      7 # https://creativecommons.org/publicdomain/zero/1.0/
      8 
      9 x
     10 /^```/ {
     11     x
     12     /^```/ {
     13         x
     14         s/.*//
     15         x
     16     }
     17     b
     18 }
     19 g
     20 
     21 /^=>/ {
     22     s/[][()]/\\&/g
     23     s/^=>\s*([^[:space:]]+)\s*$/[\1](\1)/
     24     s/^=>\s*([^[:space:]]+)\s+(.+)/[\2](\1)/
     25 }