Module:Color
可在Module:Color/doc创建此模块的帮助文档
local p = {} local getArgs = require('Module:Arguments').getArgs local list = { ["难度I"] = 'lvl_i', ["难度1"] = 'lvl_i', ["难度Ⅰ"] = 'lvl_i', ["难度II"] = 'lvl_ii', ["难度2"] = 'lvl_ii', ["难度Ⅱ"] = 'lvl_ii', ["难度III"] = 'lvl_iii', ["难度3"] = 'lvl_iii', ["难度Ⅲ"] = 'lvl_iii', ["难度IV"] = 'lvl_iv', ["难度4"] = 'lvl_iv', ["难度Ⅳ"] = 'lvl_iv', ["TAP"] = 'note tap', ["FLICK"] = 'note flick', ["CATCH"] = 'note catch', ["SLIDE"] = 'note slide', ["ROTATE"] = function(span) span:addClass('note rotate') :tag('span'):addClass('rot'):wikitext('ROT'):done() :tag('span'):addClass('ate'):wikitext('ATE'):done() end, ["BOMB"] = 'note bomb', } -- Start -- local function makeInvokeFunc(funcName) return function(frame) local args = getArgs(frame) return p[funcName](args) end end p.main = makeInvokeFunc('_main') function p._main(args)-- 生成HTML的主函数 部分代码来源:[[Module:Songtable]] --- 构建HTML --- local span = mw.html.create("span"); local a = list[args[1]]; if type(a) == 'nil' then span:css('color',(args[1] or 'unset')):wikitext(args[2]); elseif type(a) == 'string' then span:addClass(a):wikitext(args[1]); elseif type(a) == 'function' then a(span); end if args['style'] then span:attr('style',args['style']) end return tostring(span) end return p