fix links conversoin and convert --- to ─── - tttml - converters for a simpler syntax than markdown HTML git clone git://bitreich.org/tttml git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/tttml DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit b9898661168d039dc96cb69c093089fde465cbbe DIR parent 83b0368ca37208587a5abadefd12628d80374ab4 HTML Author: Josuah Demangeon <mail@josuah.net> Date: Tue, 15 May 2018 10:35:15 +0200 fix links conversoin and convert --- to ─── Diffstat: M tttml-gopher | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) --- DIR diff --git a/tttml-gopher b/tttml-gopher @@ -10,7 +10,6 @@ # [tag]: gopher://host/t/path # [tag]: t/path - BEGIN { if (ARGC < 3 || 4 < ARGC) { print("usage: tttml-gph <host> <port> [<file>]"); @@ -32,16 +31,28 @@ match($0, "^\\[[^]]*\\]: ") { if (match(uri, "^[01789aghI]/")) { type = substr(uri, 1, 1); path = uri; sub(".", "", path); + } else if (sub("^gopher://", "", uri)) { - path = uri; sub(".*/", "/", path); host = uri; sub("/.*", "", host); if (match(host, "[a-z.-]+:")) { port = substr(host, RLENGTH + 1); host = substr(host, RSTART, RLENGTH - 1); } + + path = uri; sub(".*/", "/", path); + if (match(path, "^/./")) { + type = substr(path, 2, 1); + sub("^/./", "/", path); + } else if (match(path, "^/?$")) { + type = "1"; + } else { + type = "3"; + } + } else if (match(uri, "^/")) { path = uri; type = sub("/$", "", uri) ? "1" : "0"; + } else { path = "URL:" uri; type = "h"; host = ""; port = ""; @@ -57,6 +68,11 @@ match($0, "^\\[[^]]*\\]: ") { if (end) exit; } +/^###+ / { sub("##", ""); gsub("#", "•"); } +/^=+$/ { gsub("=", "━"); } +/^-+$/ { gsub("-", "─"); } +/^\t/ { sub("^\t", "│ "); } + { gsub("\t", " "); printf("i%s\t\t\t\n", $0);