跳转到内容

模块:ExampleTable:修订间差异

来自DJMAX中文资料库
Raxter留言 | 贡献
创建页面,内容为“-- 模块:ExampleTable local p = {} local getArgs = require('Module:Arguments').getArgs function p.main(frame) local args = getArgs(frame) -- 获取参数(匿名参数1为input,匿名参数2为output) local input = args[1] or "" local output = args[2] or input -- 如果没有提供output,默认使用input -- 构建表格(无表头) local tableHtml = mw.html.create('table') :addClass('wikitable') :t…”
 
Raxter留言 | 贡献
无编辑摘要
第1行: 第1行:
-- 模块:ExampleTable
local p = {}
local p = {}
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
第6行: 第5行:
     local args = getArgs(frame)
     local args = getArgs(frame)
      
      
    -- 获取参数(匿名参数1为input,匿名参数2为output)
     local input = args[1] or ""
     local input = args[1] or ""
     local output = args[2] or input -- 如果没有提供output,默认使用input
     local output = args[2] or input
      
      
    -- 构建表格(无表头)
     local tableHtml = mw.html.create('table')
     local tableHtml = mw.html.create('table')
         :addClass('wikitable')
         :addClass('wikitable')
        :tag('tr')
            :tag('th')
                :css('width', '50%')
                :wikitext('输入')
            :done()
            :tag('th')
                :css('width', '50%')
                :wikitext('输出')
            :done()
        :done()
         :tag('tr')
         :tag('tr')
             :tag('td')
             :tag('td')
                 :css({
                 :css('vertical-align', 'top')
                    ['vertical-align'] = 'top',
                    width = '50%'
                })
                 :tag('pre')
                 :tag('pre')
                     :css('white-space', 'pre-wrap') -- 允许自动换行
                     :css('white-space', 'pre-wrap')
                     :wikitext(input)
                     :wikitext(input)
                 :done()
                 :done()
             :done()
             :done()
             :tag('td')
             :tag('td')
                 :css({
                 :css('vertical-align', 'top')
                    ['vertical-align'] = 'top',
                    width = '50%'
                })
                 :wikitext(output)
                 :wikitext(output)
             :done()
             :done()

2025年10月16日 (四) 08:31的版本

此模块的文档可以在模块: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] or input
    
    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', 'top')
                :tag('pre')
                    :css('white-space', 'pre-wrap')
                    :wikitext(input)
                :done()
            :done()
            :tag('td')
                :css('vertical-align', 'top')
                :wikitext(output)
            :done()
        :done()
    
    return tostring(tableHtml)
end

return p