# This awk program adds
to the end of each line # unless it's inside a codeblock. # It also converts the custom tag into # the actual HTML we want, and linkifies links BEGIN {isCode=0} { if ($0 == "") { isCode = 1; printf("
");
	# set the field separator before we read the next line
	# so we can read char by char
	FS = "";
        next;
    }
    
    if ($0 == "") {
        isCode = 0;
	print "
"; # reset field separator to default before reading next line FS = " "; next; } #if the thing we're in is a code block if (isCode == 1) { if ($0 == "") { print ""; next; } # convert special html chars to web safe versions field = 1; while (field <= NF) { if ($field == "&") { printf "&"; } else if ($field == "<") { printf "<"; } else if ($field == ">") { printf ">"; } else if ($field == "\"") { printf """; } else if ($field == "'") { printf "'"; } else { printf $field; } field++; if (field > NF) { print ""; } } } if (isCode == 0) { # if the line is empty, make it a
and move on # TODO make this write
even if the line has just spaces/tabs/etc. if ($0 == "") { print "
"; next; } field = 1; while (field <= NF) { if ($field ~ /^http:\/\/*/ || $field ~ /^https:\/\/*/ || $field ~ /^gopher:\/\/*/ || $field ~ /^gemini:\/\/*/) { printf ""$field" "; } else { printf $field" "; } field++; # print
if end of the line if (field > NF) { print "
"; } } } } END {}