From 00b9fd4d76359fef500c19675ea37bcc7ea0a3c9 Mon Sep 17 00:00:00 2001 From: sejo Date: Wed, 19 May 2021 20:14:08 -0500 Subject: =?UTF-8?q?conversi=C3=B3n=20de=20{links}?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gemtext2html.awk | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'gemtext2html.awk') 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 "" link "" 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( "
" ) + 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:]]+","
  • ",$0) sub("$","
  • ",$0) + appendContenido( $0 ) + } + else{ + appendContenido( $0 ) } - appendContenido( $0 ) } /^```/{ # preformatted -- cgit v1.2.3