compudanzas/gmo2gmi.awk

62 lines
1.2 KiB
Awk
Raw Normal View History

2021-06-15 03:03:28 +00:00
function nombre2Link( t, r ){ # convierte un nombre con espacios, a uno con r (e.g. "_"
gsub(" ",r,t);
return t
}
2022-01-08 17:59:43 +00:00
/^\+ /{ # literal html
2021-06-15 03:03:28 +00:00
next # salta la línea
}
/^& /{ # literal gemtext
sub(/^& /,"",$0)
print $0
next
}
2021-11-06 01:28:14 +00:00
/^=>/{ # link
gsub(/[{}]/,"")
2021-06-15 03:03:28 +00:00
}
# si tienen sintaxis de wikilink, y no son líneas de enlace, agrega el link
# (el % es por las líneas de uxn jaja)
/^[^=%]*{.+}/{
2022-01-22 00:44:13 +00:00
enlaces = ""
t = $0
while(match(t,/\{[^{}]+\}/)){ # has {key}
nombre = substr(t, RSTART+1, RLENGTH-2)
link = nombre2Link( nombre, "_" )
enlace = "=> ./" link ".gmi " nombre "\n"
enlaces = enlaces enlace
t = substr(t, RSTART+RLENGTH)
}
2021-11-06 01:28:14 +00:00
gsub(/[{}]/,"")
print $0
2022-01-22 00:44:13 +00:00
gsub(/\n$/,"",enlaces)
print enlaces
2021-11-06 01:28:14 +00:00
next
}
# imprime líneas normamlmente
2021-06-15 03:03:28 +00:00
2021-11-06 01:28:14 +00:00
{
print $0
2021-06-15 03:03:28 +00:00
}
# agrega footer
END{
print ""
2021-07-28 03:09:43 +00:00
print ""
sub("tmp/","",FILENAME)
if(FILENAME != "home.gmo"){
2022-01-22 01:22:31 +00:00
print "updated on 1" fecha
2021-11-09 19:02:39 +00:00
print "=> https://tildegit.org/sejo/compudanzas/src/branch/main/src/" FILENAME " source file"
2021-07-23 18:42:53 +00:00
}
2021-11-17 01:32:11 +00:00
print ""
2022-01-22 01:22:31 +00:00
print "=> ./home.gmi compudanzas"
print "=> ./contact.gmi contact"
2021-11-17 01:32:11 +00:00
print "=> https://wiki.p2pfoundation.net/Peer_Production_License text, images, and code are shared with the peer production license"
2021-06-15 03:03:28 +00:00
}