neingeist
/
neinomaten
Archived
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

29 lines
646 B
Ruby

def parse_template(title, template)
18 years ago
template_re = Regexp.new("\\\{\\\{" + template + "(.*?)\\\}\\\}", Regexp::MULTILINE)
fields = {}
fields_string = @wiki.article(title).text.scan(template_re)[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
end
end
fields
end
def datum2isodate(datum)
return datum[6..9] + "-" + datum[3..4] + "-" + datum[0..1]
end