“模块:少女歌剧”的版本间的差异
(实现游戏台词表格式输出) |
小 (支持显示icon) |
||
第7行: | 第7行: | ||
:addClass("wikitable") | :addClass("wikitable") | ||
:tag("tr") | :tag("tr") | ||
+ | :tag("th") | ||
+ | :done() | ||
:tag("th") | :tag("th") | ||
:css("width", "50%") | :css("width", "50%") | ||
第36行: | 第38行: | ||
end | end | ||
node:tag("tr"):tag("th") | node:tag("tr"):tag("th") | ||
− | :attr("colspan", | + | :attr("colspan", 3) |
:wikitext(chapter) | :wikitext(chapter) | ||
counter = 0 | counter = 0 | ||
else | else | ||
if counter == 0 then | if counter == 0 then | ||
− | node = node:tag("tr") | + | module.images = require("Module:少女歌剧/images") |
+ | node = node:tag("tr"):tag("td") | ||
+ | :wikitext("[[File:") | ||
+ | :wikitext(module.images.icon(actor)) | ||
+ | :wikitext("|40px]]") | ||
+ | :done() | ||
end | end | ||
local rawtext = mw.ustring.gsub(line, "[-@][-@]", function(match) | local rawtext = mw.ustring.gsub(line, "[-@][-@]", function(match) | ||
第50行: | 第57行: | ||
end | end | ||
node:tag("td") | node:tag("td") | ||
− | |||
− | |||
− | |||
:wikitext(rawtext) | :wikitext(rawtext) | ||
if counter == 1 then | if counter == 1 then |
2020年8月14日 (五) 00:09的版本
此模块的文档可以在模块:少女歌剧/doc创建
local module = {} function module.scenario(frame) local args = frame.args local node = mw.html.create("table") :addClass("wikitable") :tag("tr") :tag("th") :done() :tag("th") :css("width", "50%") :wikitext("原文") :done() :tag("th") :css("width", "50%") :wikitext("译文") :done() :done() local actor = "???" local counter = 0 for index, 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") node = node.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() counter = 0 end node:tag("tr"):tag("th") :attr("colspan", 3) :wikitext(chapter) counter = 0 else if counter == 0 then module.images = require("Module:少女歌剧/images") node = node:tag("tr"):tag("td") :wikitext("[[File:") :wikitext(module.images.icon(actor)) :wikitext("|40px]]") :done() end local rawtext = mw.ustring.gsub(line, "[-@][-@]", function(match) return mw.ustring.sub(match, 1, 2) end) if counter == 0 then rawtext = frame:expandTemplate{ title = "lj", args = { rawtext } } end node:tag("td") :wikitext(rawtext) if counter == 1 then node = node:done() end counter = math.mod(counter + 1, 2) end end return tostring(node) end return module