more than one wikilink per line!
This commit is contained in:
parent
e78dc24793
commit
27ba37108d
|
@ -55,23 +55,17 @@ function appendNav( t ){
|
||||||
}
|
}
|
||||||
|
|
||||||
function wikiLink( t ){
|
function wikiLink( t ){
|
||||||
i = match( t, /\{.+\}/)
|
out = ""
|
||||||
if ( i ){
|
while(match(t,/\{[^{}]+\}/)){ # has {key}
|
||||||
ifinal = index(t, "}") # índice del } final
|
nombre = substr(t, RSTART+1, RLENGTH-2)
|
||||||
|
link = nombre2Link( nombre, "_" )
|
||||||
|
enlace = "<a href='./" link ".html'>" nombre "</a>"
|
||||||
|
out = out substr(t, 1, RSTART-1) enlace
|
||||||
|
|
||||||
prev = substr(t, 1, i-1) # string previa al link
|
t = substr(t, RSTART+RLENGTH)
|
||||||
# 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 "<a href='./" nombre ".html'>" link "</a>" post
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return t
|
|
||||||
}
|
}
|
||||||
|
out = out t "\n"
|
||||||
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
function nombre2Link( t, r ){ # convierte un nombre con espacios, a uno con r (e.g. "_"
|
function nombre2Link( t, r ){ # convierte un nombre con espacios, a uno con r (e.g. "_"
|
||||||
|
|
18
gmo2gmi.awk
18
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
|
# si tienen sintaxis de wikilink, y no son líneas de enlace, agrega el link
|
||||||
# (el % es por las líneas de uxn jaja)
|
# (el % es por las líneas de uxn jaja)
|
||||||
/^[^=%]*{.+}/{
|
/^[^=%]*{.+}/{
|
||||||
i = match( $0, /\{.+\}/)
|
enlaces = ""
|
||||||
ifinal = index($0, "}") # índice del } final
|
t = $0
|
||||||
|
while(match(t,/\{[^{}]+\}/)){ # has {key}
|
||||||
link = substr($0, i, ifinal-i+1) # {link}
|
nombre = substr(t, RSTART+1, RLENGTH-2)
|
||||||
nombre = substr($0, i+1, ifinal-i-1) # link
|
link = nombre2Link( nombre, "_" )
|
||||||
filename = nombre2Link( nombre, "_" )
|
enlace = "=> ./" link ".gmi " nombre "\n"
|
||||||
|
enlaces = enlaces enlace
|
||||||
|
t = substr(t, RSTART+RLENGTH)
|
||||||
|
}
|
||||||
|
|
||||||
gsub(/[{}]/,"")
|
gsub(/[{}]/,"")
|
||||||
print $0
|
print $0
|
||||||
print "=> ./" filename ".gmi " nombre
|
gsub(/\n$/,"",enlaces)
|
||||||
|
print enlaces
|
||||||
next
|
next
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
links.py
2
links.py
|
@ -32,7 +32,7 @@ for filename in os.listdir():
|
||||||
pre_mode = not pre_mode
|
pre_mode = not pre_mode
|
||||||
if pre_mode: # skip preformatted mode
|
if pre_mode: # skip preformatted mode
|
||||||
continue
|
continue
|
||||||
m=re.search("\{.+\}",line)
|
m=re.search("\{[^{}]+\}",line)
|
||||||
if m:
|
if m:
|
||||||
match = m.group(0) # get matched string
|
match = m.group(0) # get matched string
|
||||||
if match not in incoming: # create a new set for that page
|
if match not in incoming: # create a new set for that page
|
||||||
|
|
Loading…
Reference in New Issue