diff --git a/gemtext2html.awk b/gemtext2html.awk
index 98580a8..13d51bc 100644
--- a/gemtext2html.awk
+++ b/gemtext2html.awk
@@ -55,23 +55,17 @@ function appendNav( t ){
}
function wikiLink( t ){
- i = match( t, /\{.+\}/)
- if ( i ){
- ifinal = index(t, "}") # índice del } final
+ out = ""
+ while(match(t,/\{[^{}]+\}/)){ # has {key}
+ nombre = substr(t, RSTART+1, RLENGTH-2)
+ link = nombre2Link( nombre, "_" )
+ enlace = "" nombre ""
+ out = out substr(t, 1, RSTART-1) enlace
- 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
- link = nombre
- nombre = nombre2Link( nombre, "_" )
-
- post = substr(t, ifinal+1) # string posterior
-
- return prev "" link "" post
- }
- else{
- return t
+ t = substr(t, RSTART+RLENGTH)
}
+ out = out t "\n"
+ return out
}
function nombre2Link( t, r ){ # convierte un nombre con espacios, a uno con r (e.g. "_"
diff --git a/gmo2gmi.awk b/gmo2gmi.awk
index 6e9d8b3..d90199a 100644
--- a/gmo2gmi.awk
+++ b/gmo2gmi.awk
@@ -21,16 +21,20 @@ function nombre2Link( t, r ){ # convierte un nombre con espacios, a uno con r (e
# si tienen sintaxis de wikilink, y no son líneas de enlace, agrega el link
# (el % es por las líneas de uxn jaja)
/^[^=%]*{.+}/{
- i = match( $0, /\{.+\}/)
- ifinal = index($0, "}") # índice del } final
-
- link = substr($0, i, ifinal-i+1) # {link}
- nombre = substr($0, i+1, ifinal-i-1) # link
- filename = nombre2Link( nombre, "_" )
+ 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)
+ }
gsub(/[{}]/,"")
print $0
- print "=> ./" filename ".gmi " nombre
+ gsub(/\n$/,"",enlaces)
+ print enlaces
next
}
diff --git a/links.py b/links.py
index f216da0..816047d 100644
--- a/links.py
+++ b/links.py
@@ -32,7 +32,7 @@ for filename in os.listdir():
pre_mode = not pre_mode
if pre_mode: # skip preformatted mode
continue
- m=re.search("\{.+\}",line)
+ m=re.search("\{[^{}]+\}",line)
if m:
match = m.group(0) # get matched string
if match not in incoming: # create a new set for that page