don't rewrite log at end if nothing appended
[diohsc.git] / tools / gmi2md.sed
blobb39ca55230207d194a7b126d89ec500cf60b693d
1 #!/bin/sed -Ef
2 # gmi2md: Sed script to convert text/gemini to markdown.
3 # Based on v0.14.2 of the gemini spec.
5 # This script is dedicated to the public domain according to the terms of CC0:
6 # https://creativecommons.org/publicdomain/zero/1.0/
9 /^```/ {
10     x
11     /^```/ {
12         x
13         s/.*//
14         x
15     }
16     b
20 /^=>/ {
21     s/[][()]/\\&/g
22     s/^=>\s*([^[:space:]]+)\s*$/[\1](\1)/
23     s/^=>\s*([^[:space:]]+)\s+(.+)/[\2](\1)/