模块:ExampleTable:修订间差异
无编辑摘要 |
无编辑摘要 |
||
| 第7行: | 第7行: | ||
local input = args[1] or "" | local input = args[1] or "" | ||
local output = args[2] | local output = args[2] | ||
local has_nowiki = input:match("</?nowiki>") | |||
if not output then | if not output then | ||
local nowiki_content = input:gsub("</?nowiki>", "") | if has_nowiki then | ||
output = frame:preprocess( | local nowiki_content = input:gsub("</?nowiki>", "") | ||
output = frame:preprocess(nowiki_content) | |||
else | |||
output = frame:preprocess(input) | |||
end | |||
end | end | ||
2025年10月16日 (四) 09:03的版本
此模块的文档可以在模块:ExampleTable/doc创建
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p.main(frame)
local args = getArgs(frame)
local input = args[1] or ""
local output = args[2]
local has_nowiki = input:match("</?nowiki>")
if not output then
if has_nowiki then
local nowiki_content = input:gsub("</?nowiki>", "")
output = frame:preprocess(nowiki_content)
else
output = frame:preprocess(input)
end
end
local tableHtml = mw.html.create('table')
:addClass('wikitable')
:tag('tr')
:tag('th')
:css('width', '50%')
:wikitext('输入')
:done()
:tag('th')
:css('width', '50%')
:wikitext('输出')
:done()
:done()
:tag('tr')
:tag('td')
:css({
['vertical-align'] = 'middle',
width = '50%'
})
:tag('pre')
:css('white-space', 'pre-wrap')
:wikitext(input)
:done()
:done()
:tag('td')
:css({
['vertical-align'] = 'middle',
width = '50%'
})
:wikitext(output)
:done()
:done()
return tostring(tableHtml)
end
return p