-- CFB schedule table conversion
-- {{subst:#invoke:CFB schedule/convert|table|...}}
local p = {}
local function parseHeader(s)
return '{' .. s .. '}'
end
local function parseFooter(s)
return '{' .. s .. '}'
end
local function parseEntry(s)
local templates = {}
k = 0
while mw.ustring.find(s, '{[^{}]*}') do
k = k + 1
templates[k] = mw.ustring.match(s, '{[^{}]*}')
s = mw.ustring.gsub(s, '{[^{}]*}', '♦' .. k .. '♦', 1)
end
return '{' .. s .. '}'
end
function p.table(frame)
local res = ''
for t in mw.text.gsplit(frame.args[1] or '', '{{[_%s]*CFB[_%s]*Schedule[_%s]*') do
local s = t:match( '^%s*(.-)%s*$' )
if mw.ustring.sub(s,-2) == '}}' then
s = mw.ustring.sub(s,1,-3)
if mw.ustring.sub(s,1,5) == 'Entry' then
res = res .. parseEntry(mw.ustring.sub(s,6))
elseif mw.ustring.sub(s,1,5) == 'Start' then
res = res .. parseHeader(mw.ustring.sub(s,6))
elseif mw.ustring.sub(s,1,3) == 'End' then
res = res .. parseFooter(mw.ustring.sub(s,4))
else
res = res .. t
end
else
res = res .. t
end
end
return res
end
return p