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 ){
|
||||
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 = "<a href='./" link ".html'>" nombre "</a>"
|
||||
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 "<a href='./" nombre ".html'>" link "</a>" 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. "_"
|
||||
|
|
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
|
||||
# (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
|
||||
}
|
||||
|
||||
|
|
2
links.py
2
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
|
||||
|
|
Loading…
Reference in New Issue