跳转到内容

模块:ExampleTable:修订间差异

来自DJMAX中文资料库
Raxter留言 | 贡献
无编辑摘要
Raxter留言 | 贡献
无编辑摘要
第6行: 第6行:
      
      
     local input = args[1] or ""
     local input = args[1] or ""
     local output = args[2] or input
     local output = args[2] or frame:preprocess(input)
      
      
     local tableHtml = mw.html.create('table')
     local tableHtml = mw.html.create('table')
         :addClass('wikitable')
         :addClass('wikitext')
         :tag('tr')
         :tag('tr')
             :tag('th')
             :tag('th')
第22行: 第22行:
         :tag('tr')
         :tag('tr')
             :tag('td')
             :tag('td')
                 :css('vertical-align', 'top')
                 :css({
                    ['vertical-align'] = 'middle',
                    width = '50%'
                })
                 :tag('pre')
                 :tag('pre')
                     :css('white-space', 'pre-wrap')
                     :css('white-space', 'pre-wrap')
第29行: 第32行:
             :done()
             :done()
             :tag('td')
             :tag('td')
                 :css('vertical-align', 'top')
                 :css({
                    ['vertical-align'] = 'middle',
                    width = '50%'
                })
                 :wikitext(output)
                 :wikitext(output)
             :done()
             :done()

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

此模块的文档可以在模块: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 frame:preprocess(input)
    
    local tableHtml = mw.html.create('table')
        :addClass('wikitext')
        :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