模块:ExampleTable
此模块的文档可以在模块: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]
if not output then
local nowiki_content = input:gsub("</?nowiki>", "")
output = frame:preprocess(nowiki_content)
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