Module:Sandbox/HistoryM:修订间差异

来自Minecraft Wiki
跳转到导航 跳转到搜索
添加的内容 删除的内容
无编辑摘要
(重命名)
 
(未显示同一用户的5个中间版本)
第1行: 第1行:
local p = {}
local p = {}
local Hmode = nil
local mode = nil
local Hver = nil
local tableHead
local HV = {
local currentVersion = nil
local currentConsoleVersions = {
xbox = nil,
xb360 = nil,
xbone = nil,
xbone = nil,
ps = nil,
ps = nil,
第9行: 第10行:
switch = nil
switch = nil
}
}
local HVindex
local consoleRowspanIndexes
local HVrowspan
local consoleRowspans
local Hindex
local rowspanIndex
local Hrowspan
local rowspans
local versionLink = require( 'Module:Version link' ).main
local versionLink = require( 'Module:Version link' ).main


第78行: 第79行:
}
}


function resetCon()
local function resetConsole()
HV.xbox = nil
currentConsoleVersions.xb360 = nil
HV.xbone = nil
currentConsoleVersions.xbone = nil
HV.ps = nil
currentConsoleVersions.ps = nil
HV.wiiu = nil
currentConsoleVersions.wiiu = nil
HV.switch = nil
currentConsoleVersions.switch = nil
end
end


function reset()
local function reset()
Hver = nil
currentVersion = nil
resetCon()
resetConsole()
end
end


function footReset()
local function footReset()
Hmode = nil
mode = nil
reset()
reset()
end
end


function getVersionLink(link,text,isSnap)
local function getVersionLink(link,text,isSnap)
local cat = ''
local cat = ''
if(not isSnap) then
if(not isSnap) then
-- upcoming categories
-- upcoming categories
if(Hmode == 'java upcoming') then cat = '[[Category:Java版即将到来/'..text..']]'
if(mode == 'java upcoming') then cat = '[[Category:Java版即将到来/'..text..']]'
elseif(Hmode == 'bedrock upcoming') then cat = '[[Category:基岩版即将到来/'..text..']]'
elseif(mode == 'bedrock upcoming') then cat = '[[Category:基岩版即将到来/'..text..']]'
elseif(Hmode == 'education upcoming') then cat = '[[Category:教育版即将到来/'..text..']]'
elseif(mode == 'education upcoming') then cat = '[[Category:教育版即将到来/'..text..']]'
end
end
end
end
if(link == 'none') then
if(link == 'none') then
if(text == 'unknown' or text == '?') then return '?[[Category:有未知版本的History模板的页面]]' end
if(text == 'unknown' or text == '?') then return '?[[Category:有未知版本的History模板的页面]]' end
if(isSnap and text == 'java') then return '' end
if(isSnap and text == 'java') then return '' end --不知道有什么用
return text .. cat
return text .. cat
end
end
if(link == 'ver') then
if(link == 'ver') then
if(text == 'unknown' or text == '?') then return '?[[Category:有未知版本的History模板的页面]]' end
if(text == 'unknown' or text == '?') then return '?[[Category:有未知版本的History模板的页面]]' end
if(isSnap and text == 'java') then return '' end
if(isSnap and text == 'java') then return '' end --不知道有什么用
if((not isSnap) and (Hmode == 'realms')) then return text end
if((not isSnap) and (mode == 'realms')) then return text end
local c
local c
if(not isSnap) then
if(not isSnap) then
if(text == 'Pre-release' and Hmode == 'pocket Alpha') then c = 'pocket Pre-release'
if(text == 'Pre-release' and mode == 'pocket Alpha') then c = 'pocket Pre-release'
elseif(Hmode == 'java Classic server') then c = 'java Classic服务器' .. text
else c = (versionLinks[mode] or mode) .. ' ' .. text
elseif(Hmode == 'java Alpha server') then c = 'java Alpha服务器' .. text
else c = (versionLinks[Hmode] or Hmode) .. ' ' .. text
end
end
else
else
c = text:lower()
c = text:lower()
if(c:match('^pre') or c:match('^rc') or c:match('^exp')) then c = Hver .. '-' .. text
if(c:match('^pre') or c:match('^rc') or c:match('^exp')) then c = currentVersion .. '-' .. text
elseif(c:match('^test build') or c:match('^pre%-release') or c:match('^build') or c:match('^20[01]')) then c = Hver .. ' ' .. text
elseif(c:match('^test build') or c:match('^pre%-release') or c:match('^build') or c:match('^20[01]')) then c = currentVersion .. ' ' .. text
elseif(c:match('^release')) then c = ver
elseif(c:match('^release')) then c = currentVersion
else c = text
else c = text
end
end
c = (versionLinks[Hmode] or Hmode) .. ' ' .. c
c = (versionLinks[mode] or mode) .. ' ' .. c
end
end
return versionLink({c,text:gsub( '^%((.*)%)$', '%1')}) .. cat
return versionLink({c,text:gsub( '^%((.*)%)$', '%1')}) .. cat
第138行: 第137行:




function consoleVersionLink(platform,version)
local function consoleVersionLink(platform,ver)
if(version == 'none') then return ' ' end
if(ver == 'none') then return ' ' end
if(version == 'unknown' or version=='?') then return '?[[Category:有未知版本的History模板的页面]]' end
if(ver == 'unknown' or ver=='?') then return '?[[Category:有未知版本的History模板的页面]]' end
local r = ' '.. version
local full = platform..' '.. ver
if(platform == 'ps') then ver = ver:gsub('%w*%(.*%)$','')
local s = version
if(platform == 'xbox') then r = 'xb360' .. r
elseif(platform == 'xbone') then r = 'xbone' .. r
elseif(platform == 'wiiu') then r = 'wiiu'.. r
elseif(platform == 'switch') then r = 'switch'.. r
elseif(platform == 'ps') then r ='ps'.. r s = s:gsub('%w*%(.*%)$','')
end
end
return versionLink({r,s})
return versionLink({full,ver})
end
end


function addConsoleVersions(platform,version,prnt)
local function addConsoleVersions(platform,ver,prnt)
if((version ~= nil and version == HV[platform]) or (version == nil and HV[platform] ~= nil))
if((ver ~= nil and ver == currentConsoleVersions[platform]) or (ver == nil and currentConsoleVersions[platform] ~= nil))
then
then
return
return
end
end
prnt('<th class="nowrap" rowspan="')
prnt('<th class="nowrap" rowspan="')
HV[platform] = version or "none"
currentConsoleVersions[platform] = ver or "none"
HVindex[platform] = HVindex[platform] + 1
consoleRowspanIndexes[platform] = consoleRowspanIndexes[platform] + 1
prnt(HVrowspan[platform][HVindex[platform]]..'">')
prnt(consoleRowspans[platform][consoleRowspanIndexes[platform]]..'">')
prnt(consoleVersionLink(platform,version or 'none'))
prnt(consoleVersionLink(platform,ver or 'none'))
prnt('</th>')
prnt('</th>')
end
end




function processLine(args, prnt)
local function processLine(args, prnt)
local snapRows = 1
local snapRows = 1
for i,_ in ipairs(args) do
for i,_ in ipairs(args) do
if(i > 3) then snapRows = snapRows + 1
if(i > 3) then snapRows = snapRows + 1
end
end
end --要保证3不是nil
end


--Header or Foot
--Header or Foot
if(args[1] ~= nil and args[1] ~= '') then
if(args[1] ~= nil and args[1] ~= '') then
local mode = (args[1]):lower()
local temp = (args[1]):lower()
if (mode == 'foot') then
if (temp == 'foot') then
prnt('</table>')
prnt('</table>')
footReset()
footReset()
Hhead = 0
tableHead = 0
return
return
end
end
Hmode = editionAlias[mode] or mode
mode = editionAlias[temp] or temp
reset()
reset()
prnt('<tr><th colspan="6">')
prnt('<tr><th colspan="6">')
prnt(headerText[Hmode] or ('[['.. Hmode ..']]'))
prnt(headerText[mode] or ('[['.. mode ..']]'))
prnt('</th></tr>')
prnt('</th></tr>')
return
return
第194行: 第188行:
prnt('<tr>')
prnt('<tr>')


if((Hmode == 'console') and (args.xbox or args.xbone or args.ps or args.wiiu or args.switch )) then
if((mode == 'console') and (args.xbox or args.xbone or args.ps or args.wiiu or args.switch )) then
Hver = nil
currentVersion = nil


if(args[3] ~= nil and args[3] ~= '') then
if(args[3] ~= nil and args[3] ~= '') then
第201行: 第195行:
end
end
addConsoleVersions("xbox",args.xbox,prnt)
addConsoleVersions("xb360",args.xbox,prnt)
addConsoleVersions("xbone",args.xbone,prnt)
addConsoleVersions("xbone",args.xbone,prnt)
addConsoleVersions("ps",args.ps,prnt)
addConsoleVersions("ps",args.ps,prnt)
第212行: 第206行:
if(k > 2) then prnt('<tr><td>' .. v .. '</td></tr>')
if(k > 2) then prnt('<tr><td>' .. v .. '</td></tr>')
end
end
end --要保证中间没有nil
end


return
return
第219行: 第213行:
--Other versions:
--Other versions:


resetCon()
resetConsole()
if((args.snap == nil) or (args[2] and args[2]~='' and (args[2] ~= Hver))) then
if((args.snap == nil) or (args[2] and args[2]~='' and (args[2] ~= currentVersion))) then
Hver = nil
currentVersion = nil
prnt('<th ')
prnt('<th ')
if( not (args.link or args[2]:find('(', 1, true))) then prnt('class="nowrap"') end
if( not (args.link or args[2]:find('(', 1, true))) then prnt('class="nowrap"') end
prnt(' rowspan="')
prnt(' rowspan="')
if( args.snap ~= nil) then
if( args.snap ~= nil) then
Hver = args[2]
currentVersion = args[2]
Hindex = Hindex + 1
rowspanIndex = rowspanIndex + 1
prnt(Hrowspan[Hindex]..'" colspan="2">')
prnt(rowspans[rowspanIndex]..'" colspan="2">')
else
else
prnt(snapRows .. '" colspan="5">')
prnt(snapRows .. '" colspan="5">')
第244行: 第238行:


prnt('<td>' .. args[3] .. '</td></tr>')
prnt('<td>' .. args[3] .. '</td></tr>')
for k,v in ipairs(args) do if(k>3) then prnt('<tr><td>'..v..'</td></tr>') end end --要保证中间不是nil
for k,v in ipairs(args) do if(k>3) then prnt('<tr><td>'..v..'</td></tr>') end end


return
return
end
end





第294行: 第287行:
end
end


function countConsoleRowspan(platform,version,snapRows)
local function countConsoleRowspans(platform,ver,snapRows)
if((version ~= nil and version == HV[platform]) or (version == nil and HV[platform] ~= nil))
if((ver ~= nil and ver == currentConsoleVersions[platform]) or (ver == nil and currentConsoleVersions[platform] ~= nil))
then
then
HVrowspan[platform][HVindex[platform]] = HVrowspan[platform][HVindex[platform]] + snapRows
consoleRowspans[platform][consoleRowspanIndexes[platform]] = consoleRowspans[platform][consoleRowspanIndexes[platform]] + snapRows
return
return
end
end
HV[platform] = version or "none"
currentConsoleVersions[platform] = ver or "none"
HVindex[platform] = HVindex[platform] + 1
consoleRowspanIndexes[platform] = consoleRowspanIndexes[platform] + 1
HVrowspan[platform][HVindex[platform]] = (HVrowspan[platform][HVindex[platform]] or 0) + snapRows
consoleRowspans[platform][consoleRowspanIndexes[platform]] = (consoleRowspans[platform][consoleRowspanIndexes[platform]] or 0) + snapRows
end
end


function countRowspan(args)
local function countRowspans(args)
local snapRows = 1
local snapRows = 1
for i,_ in ipairs(args) do
for i,_ in ipairs(args) do
if(i>3) then snapRows = snapRows + 1
if(i>3) then snapRows = snapRows + 1
end
end
end --要保证3不是nil
end


--Header or Foot
--Header or Foot
if(args[1] ~= nil and args[1] ~= '') then
if(args[1] ~= nil and args[1] ~= '') then
local mode = (args[1]):lower()
local temp = (args[1]):lower()
if (mode == 'foot') then
if (temp == 'foot') then
footReset()
footReset()
return
return
end
end
Hmode = editionAlias[mode] or mode
mode = editionAlias[temp] or temp
reset()
reset()
return
return
第326行: 第319行:
--Content rows
--Content rows


if((Hmode == 'console') and (args.xbox or args.xbone or args.ps or args.wiiu or args.switch )) then
if((mode == 'console') and (args.xbox or args.xbone or args.ps or args.wiiu or args.switch )) then
Hver = nil
currentVersion = nil


if(args[3] ~= nil and args[3] ~= '') then
if(args[3] ~= nil and args[3] ~= '') then
第333行: 第326行:
end
end
countConsoleRowspan("xbox",args.xbox,snapRows)
countConsoleRowspans("xb360",args.xbox,snapRows)
countConsoleRowspan("xbone",args.xbone,snapRows)
countConsoleRowspans("xbone",args.xbone,snapRows)
countConsoleRowspan("ps",args.ps,snapRows)
countConsoleRowspans("ps",args.ps,snapRows)
countConsoleRowspan("wiiu",args.wiiu,snapRows)
countConsoleRowspans("wiiu",args.wiiu,snapRows)
countConsoleRowspan("switch",args.switch,snapRows)
countConsoleRowspans("switch",args.switch,snapRows)
return
return
第344行: 第337行:
--Other versions:
--Other versions:


resetCon()
resetConsole()
if((args.snap == nil) or (args[2] and args[2] ~= '' and (args[2] ~= Hver))) then
if((args.snap == nil) or (args[2] and args[2] ~= '' and (args[2] ~= currentVersion))) then
Hver = nil
currentVersion = nil
if( args.snap ~= nil) then
if( args.snap ~= nil) then
Hver = args[2]
currentVersion = args[2]
Hindex = Hindex + 1
rowspanIndex = rowspanIndex + 1
end
end
end
end


if(args.snap ~= nil) then
if(args.snap ~= nil) then
Hrowspan[Hindex] = (Hrowspan[Hindex] or 0) + snapRows
rowspans[rowspanIndex] = (rowspans[rowspanIndex] or 0) + snapRows
end
end
return
return
end
end


function initRowspan()
local function initRowspans()
Hrowspan = {}
rowspans = {}
HVrowspan = {
consoleRowspans = {
xbox = {},
xb360 = {},
xbone = {},
xbone = {},
ps = {},
ps = {},
第370行: 第363行:
end
end


function initRowspanIndex()
local function resetRowspanIndexes()
Hindex = 0
rowspanIndex = 0
consoleRowspanIndexes = {
HVindex = {
xbox = 0,
xb360 = 0,
xbone = 0,
xbone = 0,
ps = 0,
ps = 0,
第384行: 第377行:
local lines = p.getLines(f)
local lines = p.getLines(f)


initRowspan()
initRowspans()
initRowspanIndex()
resetRowspanIndexes()
for k,v in ipairs(lines) do
for _,v in ipairs(lines) do
countRowspan(v)
countRowspans(v)
end
end


resetRowspanIndexes()
initRowspanIndex()
Hhead=0
local result = {}
local result = {}
tableHead=0
for k,v in ipairs(lines) do
for _,v in ipairs(lines) do
if(Hhead~=1) then
if(tableHead~=1) then
table.insert(result, '<table class="wikitable" data-description="历史">')
table.insert(result, '<table class="wikitable" data-description="历史">')
Hhead = 1
tableHead = 1
end
end
processLine(v,function(a) table.insert(result, a) end)
processLine(v, function(a) table.insert(result, a) end)
end
end
return table.concat(result)
return table.concat(result)

2023年8月9日 (三) 10:55的最新版本

[ 创建 | 刷新 ]文档页面
此模块没有文档页面。如果你知道此模块的使用方法,请帮助为其创建文档页面。
local p = {}
local mode = nil
local tableHead
local currentVersion = nil
local currentConsoleVersions = {
    xb360 = nil,
    xbone = nil,
    ps = nil,
    wiiu = nil,
    switch = nil
}
local consoleRowspanIndexes
local consoleRowspans
local rowspanIndex
local rowspans
local versionLink = require( 'Module:Version link' ).main

local editionAlias = {
	['pre-classic'] = "java pre-Classic", ['java pre-classic'] = "java pre-Classic",
	classic = "java Classic", ['java classic'] = "java Classic",
	['classic server'] = "java Classic server", ['java classic server'] = "java Classic server",
	indev = "java Indev", ['java indev'] = "java Indev",
	infdev = "java Infdev", ['java infdev'] = "java Infdev",
	alpha = "java Alpha", ['java alpha'] = "java Alpha", ['java edition alpha'] = "java Alpha",
	['alpha server'] = "java Alpha server", ['java alpha server'] = "java Alpha server", ['java edition alpha server'] = "java Alpha server",
	beta = "java Beta", ['java beta'] = "java Beta", ['java edition beta'] = "java Beta",
	je = "java", java = "java", ['java edition'] = "java",
	['java edition upcoming'] = "java upcoming", ['java upcoming'] = "java upcoming", ['upcoming java'] = "java upcoming",
	['pe alpha'] = "pocket Alpha", ['pocket alpha'] = "pocket Alpha", ['pocket edition alpha'] = "pocket Alpha",
	pe = "pocket", pocket = "pocket", ['pocket edition'] = "pocket",
	ce = "console", lce = "console", console = "console", ['legacy console'] = "console", ['console edition'] = "console", ['legacy console edition'] = "console",
	be = "bedrock", bedrock = "bedrock", ['bedrock edition'] = "bedrock",
	['be upcoming'] = "bedrock upcoming", ['bedrock upcoming'] = "bedrock upcoming", ['bedrock edition upcoming'] = "bedrock upcoming", ['upcoming bedrock'] = "bedrock upcoming",
	['3ds'] = "3ds", new3ds = "3ds", ['new 3ds'] = "3ds",
	realms = "realms",
	edu = "edu", minecraftedu = "edu",
	education = "education", ['education edition'] = "education",
	['ee upcoming'] = "education upcoming", ['education upcoming'] = "education upcoming", ['education edition upcoming'] = "education upcoming", ['upcoming education'] = "education upcoming",
	ps4 = "ps4", playstation4 = "ps4", ['playstation 4'] = "ps4",
	earth = "earth", ['minecraft earth'] = "earth",
	dungeons = "dungeons", ['minecraft dungeons'] = "dungeons",
	['?'] = "unknown", unknown = "unknown"
}

local headerText = {
    ['java pre-Classic']    = '[[Java版pre-Classic]]',
    ['java Classic']        = '[[Java版Classic]]',
    ['java Classic server'] = '[[Java版Classic|Java版Classic服务器]]',
    ['java Indev']          = '[[Java版Indev]]',
    ['java Infdev']         = '[[Java版Infdev]]',
    ['java Alpha']          = '[[Java版Alpha]]',
    ['java Alpha server']   = '[[Java版Alpha|Java版Alpha服务器]]',
    ['java Beta']           = '[[Java版Beta]]',
    ['java']                = '[[Java版版本记录|Java版]]',
    ['java upcoming']       = '[[计划版本#Java版|Java版(即将到来)]][[Category:Java版即将到来]]',
    ['pocket Alpha']        = '[[携带版Alpha]]',
    ['pocket']              = '[[携带版]]',
    ['bedrock']             = '[[基岩版版本记录|基岩版]]',
    ['bedrock upcoming']    = '[[计划版本#基岩版|基岩版(即将到来)]][[Category:基岩版即将到来]]',
    ['edu']                 = '[[MinecraftEdu]]',
    ['education']           = '[[教育版版本记录|教育版]]',
    ['education upcoming']  = '[[计划版本#教育版|教育版(即将到来)]][[Category:教育版即将到来]]',
    ['console']             = '[[原主机版版本记录|原主机版]]',
    ['realms']              = '[[Realms#历史|Realms]]',
    ['3ds']                 = '[[New Nintendo 3DS版版本记录|New Nintendo 3DS版]]',
    ['ps4']                 = '[[原主机版版本记录|PlayStation 4版]]',
    ['earth']               = '[[Minecraft Earth]]',
    ['dungeons']            = '[[Minecraft Dungeons]]',
    ['unknown']             = '未知[[Category:有未知版本的History模板的页面]]'
}

local versionLinks = {
    ['java upcoming'] = 'java',
    ['bedrock upcoming'] = 'bedrock',
    ['education upcoming'] = 'education',
    ps4 = 'ps4',
    earth = 'Earth',
    dungeons = 'Dungeons'
}

local function resetConsole()
    currentConsoleVersions.xb360 = nil
    currentConsoleVersions.xbone = nil
    currentConsoleVersions.ps = nil
    currentConsoleVersions.wiiu = nil
    currentConsoleVersions.switch = nil
end

local function reset()
    currentVersion = nil
    resetConsole()
end

local function footReset()
    mode = nil
    reset()
end

local function getVersionLink(link,text,isSnap)
    local cat = ''
    if(not isSnap) then
        -- upcoming categories
        if(mode == 'java upcoming') then cat = '[[Category:Java版即将到来/'..text..']]'
        elseif(mode == 'bedrock upcoming') then cat = '[[Category:基岩版即将到来/'..text..']]'
        elseif(mode == 'education upcoming') then cat = '[[Category:教育版即将到来/'..text..']]'
        end
    end
    if(link == 'none') then 
      	if(text == 'unknown' or text == '?') then return '?[[Category:有未知版本的History模板的页面]]' end
		if(isSnap and text == 'java') then return '' end --不知道有什么用
      	return text .. cat
    end
    if(link == 'ver') then 
      	if(text == 'unknown' or text == '?') then return '?[[Category:有未知版本的History模板的页面]]' end
		if(isSnap and text == 'java') then return '' end --不知道有什么用
      	if((not isSnap) and (mode == 'realms')) then return text end
      	local c
			if(not isSnap) then
				if(text == 'Pre-release' and mode == 'pocket Alpha') then c = 'pocket Pre-release'
				else c = (versionLinks[mode] or mode) .. ' ' .. text
				end
			else
                c = text:lower()
                if(c:match('^pre') or c:match('^rc') or c:match('^exp')) then c = currentVersion .. '-' .. text
                elseif(c:match('^test build') or c:match('^pre%-release') or c:match('^build') or c:match('^20[01]')) then c = currentVersion .. ' ' .. text
                elseif(c:match('^release')) then c = currentVersion
                else c = text
                end
				c = (versionLinks[mode] or mode) .. ' ' .. c
			end
      	return versionLink({c,text:gsub( '^%((.*)%)$', '%1')}) .. cat
    end
    if(text == 'unknown' or text == '?') then cat = '[[Category:有未知版本的History模板的页面]]' end
    if(link:find('//',1,true)) then return '['..link..' '..text..']'..cat else return '[['..link..'|'..text..']]'..cat end
      
end


local function consoleVersionLink(platform,ver)
    if(ver == 'none') then return ' ' end
    if(ver == 'unknown' or ver=='?') then return '?[[Category:有未知版本的History模板的页面]]' end
    local full = platform..' '.. ver
    if(platform == 'ps') then ver = ver:gsub('%w*%(.*%)$','')
    end
    return versionLink({full,ver})
end

local function addConsoleVersions(platform,ver,prnt)
    if((ver ~= nil and ver == currentConsoleVersions[platform]) or (ver == nil and currentConsoleVersions[platform] ~= nil))
    then
        return
    end
    prnt('<th class="nowrap" rowspan="')
    currentConsoleVersions[platform] = ver or "none"
    consoleRowspanIndexes[platform] = consoleRowspanIndexes[platform] + 1
    prnt(consoleRowspans[platform][consoleRowspanIndexes[platform]]..'">')
    prnt(consoleVersionLink(platform,ver or 'none'))
    prnt('</th>')
end


local function processLine(args, prnt)
    local snapRows = 1
    for i,_ in ipairs(args) do
    	if(i > 3) then snapRows = snapRows + 1
    	end
    end

    --Header or Foot
    if(args[1] ~= nil and args[1] ~= '') then
        local temp = (args[1]):lower()
        if (temp == 'foot') then
            prnt('</table>')
            footReset()
            tableHead = 0
            return
        end
        mode = editionAlias[temp] or temp
        reset()
        prnt('<tr><th colspan="6">')
        prnt(headerText[mode] or ('[['.. mode ..']]'))
        prnt('</th></tr>')
        return
    end

    --Content rows

    prnt('<tr>')

    if((mode == 'console') and (args.xbox or args.xbone or args.ps or args.wiiu or args.switch )) then
        currentVersion = nil

        if(args[3] ~= nil and args[3] ~= '') then
            snapRows = snapRows + 1
        end
  
        addConsoleVersions("xb360",args.xbox,prnt)
        addConsoleVersions("xbone",args.xbone,prnt)
        addConsoleVersions("ps",args.ps,prnt)
        addConsoleVersions("wiiu",args.wiiu,prnt)
        addConsoleVersions("switch",args.switch,prnt)
  
        prnt('<td>'..args[2]..'</td></tr>')
  
        for k,v in ipairs(args) do
        	if(k > 2) then prnt('<tr><td>' .. v .. '</td></tr>')
        		end
        end

        return
    end

    --Other versions:

    resetConsole()
    if((args.snap == nil) or (args[2] and args[2]~='' and (args[2] ~= currentVersion))) then
  	    currentVersion = nil
        prnt('<th ')
        if( not (args.link or args[2]:find('(', 1, true))) then prnt('class="nowrap"') end
        prnt(' rowspan="')
        if( args.snap ~= nil) then
            currentVersion = args[2]
            rowspanIndex = rowspanIndex + 1
            prnt(rowspans[rowspanIndex]..'" colspan="2">')
        else
            prnt(snapRows .. '" colspan="5">')
        end

        prnt(getVersionLink(args.link or 'ver', args[2], false))
        prnt('</th>')
    end

    if(args.snap ~= nil) then
        prnt('<th colspan="3" rowspan="' .. snapRows .. '">')
        prnt(getVersionLink(args.slink or 'ver', args.snap, true))
        prnt('</th>')
    end

    prnt('<td>' .. args[3] .. '</td></tr>')
    for k,v in ipairs(args) do if(k>3) then prnt('<tr><td>'..v..'</td></tr>') end end

    return
end


function p.getLines(f)
	local args = f
	if f == mw.getCurrentFrame() then 
		args = require( 'Module:ProcessArgs' ).merge( true )
	end
	assert(mw.text.trim(args[1]):sub(-14)=='<!--LineEnd-->')
	local stringLines = mw.text.split(mw.text.trim(args[1]):sub(1,-15),'<!--LineEnd-->',true)
	local tableLines = {}
	local stringArgs
	local temp,temp1,temp2
	for i,l in ipairs(stringLines) do
		tableLines[i] = {}
		temp = mw.text.trim(l) or ''
		if(temp ~= '') then
			stringArgs = mw.text.split(temp,'<!--ArgSep-->',true)
			for m,n in ipairs(stringArgs) do
				if(n ~= '') then
					temp = n:find("=", 1, true)
					temp1 = mw.text.trim(n:sub(1, temp - 1))
					temp1 = tonumber(temp1) or temp1
					temp2 = mw.text.trim(n:sub(temp + 1))
					tableLines[i][temp1] = temp2
				end
			end
		end
	end
	return tableLines
end


function p.printArgs(f)
	local args = f
	if f == mw.getCurrentFrame() then 
		args = require( 'Module:ProcessArgs' ).merge( false )
	end
	local result = ''
	for k,v in pairs(args) do
		result = result .. k .. '=' .. v .. '<!--ArgSep-->'
	end
	result = result .. '<!--LineEnd-->'
	return result
end

local function countConsoleRowspans(platform,ver,snapRows)
    if((ver ~= nil and ver == currentConsoleVersions[platform]) or (ver == nil and currentConsoleVersions[platform] ~= nil))
    then
        consoleRowspans[platform][consoleRowspanIndexes[platform]] = consoleRowspans[platform][consoleRowspanIndexes[platform]] + snapRows
        return
    end
    currentConsoleVersions[platform] = ver or "none"
    consoleRowspanIndexes[platform] = consoleRowspanIndexes[platform] + 1
    consoleRowspans[platform][consoleRowspanIndexes[platform]] = (consoleRowspans[platform][consoleRowspanIndexes[platform]] or 0) + snapRows
end

local function countRowspans(args)
    local snapRows = 1
    for i,_ in ipairs(args) do
    	if(i>3) then snapRows = snapRows + 1
    	end
    end

    --Header or Foot
    if(args[1] ~= nil and args[1] ~= '') then
        local temp = (args[1]):lower()
        if (temp == 'foot') then
            footReset()
            return
        end
        mode = editionAlias[temp] or temp
        reset()
        return
    end

    --Content rows

    if((mode == 'console') and (args.xbox or args.xbone or args.ps or args.wiiu or args.switch )) then
        currentVersion = nil

        if(args[3] ~= nil and args[3] ~= '') then
            snapRows = snapRows + 1
        end
  
        countConsoleRowspans("xb360",args.xbox,snapRows)
        countConsoleRowspans("xbone",args.xbone,snapRows)
        countConsoleRowspans("ps",args.ps,snapRows)
        countConsoleRowspans("wiiu",args.wiiu,snapRows)
        countConsoleRowspans("switch",args.switch,snapRows)
  
        return
    end

    --Other versions:

    resetConsole()
    if((args.snap == nil) or (args[2] and args[2] ~= '' and (args[2] ~= currentVersion))) then
  	    currentVersion = nil
  	    if( args.snap ~= nil) then
            currentVersion = args[2]
            rowspanIndex = rowspanIndex + 1
        end
    end

    if(args.snap ~= nil) then
        rowspans[rowspanIndex] = (rowspans[rowspanIndex] or 0) + snapRows
    end
    return
end

local function initRowspans()
    rowspans = {}
    consoleRowspans = {
        xb360 = {},
        xbone = {},
        ps = {},
        wiiu = {},
        switch = {}
    }
end

local function resetRowspanIndexes()
	rowspanIndex = 0
	consoleRowspanIndexes = {
		xb360 = 0,
		xbone = 0,
		ps = 0,
		wiiu = 0,
		switch = 0
	}
end

function p.main(f)
    local lines = p.getLines(f)

    initRowspans()
    resetRowspanIndexes()
	for _,v in ipairs(lines) do
		countRowspans(v)
	end

	resetRowspanIndexes()
    local result = {}
    tableHead=0
	for _,v in ipairs(lines) do
		if(tableHead~=1) then
        	table.insert(result, '<table class="wikitable" data-description="历史">')
        	tableHead = 1
		end
		processLine(v, function(a) table.insert(result, a) end)
	end
	return table.concat(result)
end

return p