aboutsummaryrefslogtreecommitdiffstats
path: root/gemtext2html.awk
diff options
context:
space:
mode:
authorsejo <sejo@texto-plano.xyz>2021-05-19 20:14:08 -0500
committersejo <sejo@texto-plano.xyz>2021-05-19 20:14:08 -0500
commit00b9fd4d76359fef500c19675ea37bcc7ea0a3c9 (patch)
tree2c8e8b57fb594e20ca7310f9c3f395a28b3247dc /gemtext2html.awk
parent890247d348ac1f4712b291b9f993e72617d70b68 (diff)
downloadsitio-00b9fd4d76359fef500c19675ea37bcc7ea0a3c9.tar.gz
conversión de {links}
Diffstat (limited to 'gemtext2html.awk')
-rw-r--r--gemtext2html.awk27
1 files changed, 25 insertions, 2 deletions
diff --git a/gemtext2html.awk b/gemtext2html.awk
index f494301..f2739ea 100644
--- a/gemtext2html.awk
+++ b/gemtext2html.awk
@@ -33,6 +33,23 @@ function appendNav( t ){
nav = nav t
}
+function wikiLink( t ){
+ i = match( t, /{.+}/)
+ if ( i ){
+ ifinal = index(t, "}") # índice del } final
+
+ prev = substr(t, 1, i-1) # string previa al link
+ link = substr(t, i, ifinal-i+1) # {link}
+ nombre = substr(t, i+1, ifinal-i-1) # link
+ post = substr(t, ifinal+1) # string posterior
+
+ return prev "<a href='" nombre ".html'>" link "</a>" post
+ }
+ else{
+ return t
+ }
+}
+
NR == 1{
titulo = $0
sub("#[[:blank:]]+","",titulo) #prefijo
@@ -57,8 +74,11 @@ $0 !~ /^(=>|```|#{1,3} |* |>|[[:blank:]]*$)/{ # líneas de texto (no "especiales
else # nueva línea en el mismo párrafo
appendContenido( "<br/>" )
+ appendContenido( wikiLink($0) )
+ }
+ else{
+ appendContenido( $0 )
}
- appendContenido( $0 )
}
/^[[:blank:]]*$/ { # línea vacía
@@ -130,8 +150,11 @@ $0 !~ /^(=>|```|#{1,3} |* |>|[[:blank:]]*$)/{ # líneas de texto (no "especiales
}
sub("*[[:blank:]]+","<li>",$0)
sub("$","</li>",$0)
+ appendContenido( $0 )
+ }
+ else{
+ appendContenido( $0 )
}
- appendContenido( $0 )
}
/^```/{ # preformatted
Un proyecto texto-plano.xyz