aboutsummaryrefslogtreecommitdiffstats
path: root/gemtext2html.awk
diff options
context:
space:
mode:
authorsejo <sejo@texto-plano.xyz>2021-05-19 22:21:49 -0500
committersejo <sejo@texto-plano.xyz>2021-05-19 22:21:49 -0500
commit72c93faec78c967f9fb101430ebb110cc2e97547 (patch)
treeec4d5a627e4bcb6c9bb3d6bc430a1eba8e8cd7df /gemtext2html.awk
parent4498c5c12945d3b1546e206e358f9950f3f36f92 (diff)
downloadsitio-72c93faec78c967f9fb101430ebb110cc2e97547.tar.gz
agregando estilos
Diffstat (limited to 'gemtext2html.awk')
-rw-r--r--gemtext2html.awk38
1 files changed, 28 insertions, 10 deletions
diff --git a/gemtext2html.awk b/gemtext2html.awk
index c808a40..ce11980 100644
--- a/gemtext2html.awk
+++ b/gemtext2html.awk
@@ -1,16 +1,21 @@
# gemtext2html
# convierte un archivo en gemtext a html de acuerdo a la spec
# excepción: enlaces a imagen (jpg, png, gif) se vuelven <img>
+# TODO actualizar descripción
+#
+# importante: solo un {wikilink} (con o sin espacios) por línea
#
# modo de uso:
# awk -f gemtext2html.awk archivo.gmi > archivo.html
#
BEGIN{
+ sitio = "HOLO"
# para poder abrir y cerrar <ul>, <pre>, <p>:
modo_lista = 0
modo_pre = 0
modo_parrafo = 0
+ modo_galeria = 0
en_section = 1
@@ -28,10 +33,10 @@ BEGIN{
}
function appendContenido( t ){
- contenido = contenido t
+ contenido = contenido t "\n"
}
function appendNav( t ){
- nav = nav t
+ nav = nav t "\n"
}
function wikiLink( t ){
@@ -56,10 +61,11 @@ function wikiLink( t ){
NR == 1{
titulo = $0
sub("#[[:blank:]]+","",titulo) #prefijo
- print "<title>"titulo"</title>"
+ print "<title>" sitio " &mdash; " titulo "</title>"
print "</head>"
print "<body>"
print "<header>"
+ print "<p><a href='./index.html'>{" sitio "}</a></p>"
print "<h1>"titulo"</h1>"
print "</header>"
@@ -95,10 +101,15 @@ $0 !~ /^(=>|```|#{1,3} |* |>|[[:blank:]]*$)/{ # líneas de texto (no "especiales
modo_parrafo = 0
appendContenido( "</p>" )
}
- else if( bloque ) # si lo previo fue header o blockquote
- bloque = 0;
+ else if( modo_galeria ){
+ modo_galeria = 0
+ appendContenido( "</gallery>" )
+ }
# else
# appendContenido( "<br/>" )
+ if( bloque ) # si lo previo fue header o blockquote
+ bloque = 0;
+
}
else
appendContenido( $0 )
@@ -132,7 +143,11 @@ $0 !~ /^(=>|```|#{1,3} |* |>|[[:blank:]]*$)/{ # líneas de texto (no "especiales
# si el path es imagen
if( match($1, /(png|jpg|gif)$/) ){
# crea imagen <img>
- $0="<img src='"$1"' alt='"texto"' loading='lazy'/>"
+ if( !modo_galeria ){
+ appendContenido("<gallery>")
+ modo_galeria = 1
+ }
+ appendContenido("<img src='"$1"' alt='"texto"' loading='lazy'/>")
}
# si el path no es imagen
else{
@@ -140,14 +155,16 @@ $0 !~ /^(=>|```|#{1,3} |* |>|[[:blank:]]*$)/{ # líneas de texto (no "especiales
sub(".gmi$",".html",$1)
# crea link <a>
- $0="<p><a href='"$1"'>"texto"</a></p>"
+ appendContenido("<p><a href='"$1"'>"texto"</a></p>")
}
}
else{ # link externo
- $0="<p><a href='"$1"' rel=external target=_blank>"texto"</a></p>"
+ appendContenido("<p><a href='"$1"' rel=external target=_blank>"texto"</a></p>")
}
}
- appendContenido( $0 )
+ else{
+ appendContenido( $0 )
+ }
}
/^* /{ # lista
@@ -263,7 +280,8 @@ END{
print "<p>página actualizada en: "
fecha = system( "date -r " FILENAME " --rfc-3339=date" )
print "</p>"
- print "<p><a href='./index.html'>inicio</a></p>"
+ print "<p><a href='./index.html'>{" sitio "}</a></p>"
+ print "<a href='https://endefensadelsl.org/ppl_es.html' rel=external target=_blank>ppl: licencia de producción de pares</a></p>"
print "</footer>"
print "</body>"
print "</html>"
Un proyecto texto-plano.xyz