diff options
Diffstat (limited to 'gemtext2html.awk')
-rw-r--r-- | gemtext2html.awk | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/gemtext2html.awk b/gemtext2html.awk index 43da533..f494301 100644 --- a/gemtext2html.awk +++ b/gemtext2html.awk @@ -12,6 +12,8 @@ BEGIN{ modo_pre = 0 modo_parrafo = 0 + en_section = 1 + bloque = 0 # para no agregar <br/> después de headers y blockquotes print "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>" @@ -20,7 +22,7 @@ BEGIN{ print "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />" print "<meta content='initial-scale=1.0, maximum-scale=1.0, user-scalable=yes' name='viewport'/>" - contenido = "<main>" + contenido = "<main><section>" nav = "<nav><ul>" } @@ -40,6 +42,10 @@ NR == 1{ print "<header>" print "<h1>"titulo"</h1>" print "</header>" + + bloque = 1 + + getline # lee la siguiente línea } $0 !~ /^(=>|```|#{1,3} |* |>|[[:blank:]]*$)/{ # líneas de texto (no "especiales") @@ -164,9 +170,24 @@ $0 !~ /^(=>|```|#{1,3} |* |>|[[:blank:]]*$)/{ # líneas de texto (no "especiales sub("#[[:blank:]]+","",$0) #prefijo sub("$","",$0) #sufijo bloque = 1 + + if( !en_section ){ # si no se ha iniciado una sección antes + appendContenido( "<section>" ) + en_section = 1 + } + else{ + appendContenido( "</section><section>" ) + } + + appendContenido( "<h1 id='"$0"'>"$0"</h1>" ) + + # agrega header a navegación + appendNav( "<li><a href='#"$0"'>"$0"</a></li>" ) } - appendNav( "<li><a href='#"$0"'>"$0"</a></li>" ) - appendContenido( "<h1 id='"$0"'>"$0"</h1>" ) + else{ + appendContenido( $0 ) + } + } /^## /{ # h2 @@ -199,9 +220,13 @@ END{ else if(modo_lista) print "</ul>" + print "</section>" print "</main>" print "<footer>" - # TODO footer + print "<p>página actualizada en: " + fecha = system( "date -r " FILENAME " --rfc-3339=date" ) + print "</p>" + print "</footer>" print "</body>" print "</html>" |