Changes

MyWikiBiz, Author Your Legacy — Saturday September 06, 2025
Jump to navigationJump to search
1,045 bytes added ,  07:32, 16 July 2021
Pywikibot 6.4.0
local p = {}

function p.main(frame)
local frame = mw.getCurrentFrame()
local chart = frame:getParent().args[1]:lower():gsub('%s*(.+)%s*','%1')
local pagename = frame.args[2] or ''
local table_id = frame.args[3] or ''
local source = ''
local data = ''
local first = frame.args['first']
local count = 0
if pagename == '' then
source = frame:getParent():getTitle():getContent()
else
source = mw.title.new(pagename):getContent()
end
if table_id ~= '' then source = source:match('{|.-id -="?'..table_id..'"? -.-(\n|%-.+\n)|}') end
for x, y in source:gmatch('\n|%-.-\n[!|]%s*(.-)%s*[|\n]|%s*([^|\n]+)') do
count = count + 1
data = data.."("..y..":"..x..")\n"
if count == first then return require('Module:Chart')[chart](frame) end
end
if frame:getParent().args['debug'] then
return string.format(' chart: '..chart..'\n pagename: '..pagename..'\n table: '..table_id..'\n data: ' .. data)
else
if chart == 'pie chart' then
frame.args.slices = data
end
return require('Module:Chart')[chart](frame)
end
end

return p

Navigation menu