模块:少女歌剧
此模块的文档可以在模块:少女歌剧/doc创建
local module = {} function module.scenario(frame) local args = frame.args local node = mw.html.create("table") :addClass("wikitable") :css("width", "100%") :tag("tr") :tag("th") :css("width", "50%") :wikitext("原文") :done() :tag("th") :css("width", "50%") :wikitext("译文") :done() :done() local actor = "???" local counter = 0 for _, line in ipairs(args) do line = mw.text.trim(line) if mw.ustring.find(mw.text.trim(line), "^@[^@]") then actor = mw.text.trim(mw.ustring.sub(line, 2)) if counter == 1 then node:tag("td"):done() counter = 0 end elseif mw.ustring.find(mw.text.trim(line), "^-[^-]") then local chapter = mw.text.trim(mw.ustring.sub(line, 2)) if counter == 1 then node:tag("td") node = node.done() end node:tag("tr"):tag("th") :attr("colspan", 2) :wikitext(chapter) counter = 0 else node:tag("td") :wikitext("<sup>") :wikitext(actor) :wikitext("</sup>") :wikitext(mw.ustring.gsub(line, "[-@][-@]", function(match) return mw.ustring.sub(match, 1, 2) end)) end if counter == 0 then node = node:tag("tr") end end return tostring(node) end return module