Module:Sandbox/Frietjes: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 2:
-- {{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
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)
Line 34 ⟶ 10:
s = mw.ustring.sub(s,1,-3)
if mw.ustring.sub(s,1,5) == 'Entry' then
res = res .. frame:expand('{{CFB Schedule Entry' .. parseEntry(mw.ustring.sub(s,6)) .. '}}')
elseif mw.ustring.sub(s,1,5) == 'Start' then
res = res .. parseHeaderframe:expand('{{CFB Schedule Start' .. parseEntry(mw.ustring.sub(s,6)) .. '}}')
elseif mw.ustring.sub(s,1,3) == 'End' then
res = res .. parseFooterframe:expand('{{CFB Schedule End' .. parseEntry(mw.ustring.sub(s,4)) .. '}}')
else
res = res .. t