neingeist
/
neinomaten
Archived
1
0
Fork 0

A litte bit of shh

master
neingeist 18 years ago
parent 600bcc3a16
commit ec3b85046e

@ -3,21 +3,25 @@ def parse_template(title, template)
fields = {}
fields_string = @wiki.article(title).text.scan(template_re)[0][0]
if (scanned = @wiki.article(title).text.scan(template_re)) != []
fields_string = scanned[0][0]
inlink = 0
field = ""
fields_string += "|" unless fields_string.match(/\|$/)
fields_string.split(//).each do |c|
if c == "|" && inlink == 0
(key, value) = field.split(/=/)
fields[key] = value
field = ""
else
inlink += 1 if c == "["
inlink -= 1 if c == "]"
field += c
inlink = 0
field = ""
fields_string += "|" unless fields_string.match(/\|$/)
fields_string.split(//).each do |c|
if c == "|" && inlink == 0
(key, value) = field.split(/=/)
fields[key] = value
field = ""
else
inlink += 1 if c == "["
inlink -= 1 if c == "]"
field += c
end
end
else
$stderr.print "Template #{template} not found in #{title}!"
end
fields