跳转到内容
打开/关闭菜单
  • 505 条目
  • 936 文件
  • 22 用户
  • 1万 编辑
Blockland Wiki
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

那艺娜❤️‍🔥橘枳🍊好栓😝哈哈哈哈哈哈哈哈😆橘枳🍊栓栓😫Blockland正在不活跃期,设定内容正在放缓,676767676767。
内群链接:118793188,外群链接:1016063794。哈基米,咕咕嘎嘎咕咕嘎嘎咕咕嘎嘎,我也不知道啥时候推演awa。Xterfusion很好听,,,,,

模块:Note:修订间差异

来自Blockland Wiki
无编辑摘要
无编辑摘要
第3行: 第3行:


local function trim(s)
local function trim(s)
     if s == nil then return '' end
     if s == nil then return nil end
     return mw.text.trim(tostring(s))
     s = mw.text.trim(tostring(s))
    return s ~= '' and s or nil
end
end


local function link(page)
local function formatLink(page)
    page = trim(page)
     if not page then return nil end
     if page == '' then return '' end
     return "「'''[[" .. page .. "]]'''」"
     return '[[' .. page .. ']]'
end
end


function p.about(frame)
local function formatList(pages)
     local args = frame:getParent().args
    local formatted = {}
 
    for _, page in ipairs(pages) do
        table.insert(formatted, formatLink(page))
    end
 
    if #formatted == 0 then return nil end
    if #formatted == 1 then return formatted[1] end
    if #formatted == 2 then
        return formatted[1] .. '和' .. formatted[2]
    end
 
     local last = table.remove(formatted)
    return table.concat(formatted, '、') .. '和' .. last
end
 
local function getPageType(args)
    if trim(args.section) then
        return '章节'
    end
 
    local ns = mw.title.getCurrentTitle().namespace
 
    local types = {
        [0] = '条目',
        [4] = '项目页面',
        [6] = '文件',
        [10] = '模板',
        [14] = '分类',
        [828] = '模块'
    }
 
    return types[ns] or '页面'
end


local function buildText(args)
    local parts = {}
     local subject = trim(args[2])
     local subject = trim(args[2])
     local section = trim(args.section)
     local extra = trim(args.text)
    local pageType = section ~= '' and '章节' or '条目'


    local output = {}
     if subject then
 
     if subject ~= '' then
         table.insert(
         table.insert(
             output,
             parts,
             '此' .. pageType .. '介绍的是' .. subject .. '。'
             '此' .. getPageType(args) ..
            '介绍的是' .. subject .. '。'
         )
         )
    end
    local title = mw.title.getCurrentTitle().text
    local defaultPage = title .. ' (消歧义)'
    local maxArg = 2
    for k in pairs(args) do
        if type(k) == 'number' and k > maxArg then
            maxArg = k
        end
     end
     end


     local i = 3
     local i = 3


     while i <= 31 do
     -- 与 Wikipedia 的 About 参数结构一致:
         local description = trim(args[i])
    -- 主题 | 用法 | 页面 | 和 | 页面 | 下一用法 | 页面
        local target = trim(args[i + 1])
    if i <= maxArg or not extra then
        local finished = false
 
         repeat
            local use = trim(args[i])
            local pages = {}
 
            local firstPage = trim(args[i + 1])
            if firstPage then
                table.insert(pages, firstPage)
            end
 
            -- 收集通过“和”连接的多个页面
            while trim(args[i + 2]) == '和' do
                local nextPage = trim(args[i + 3])
 
                if nextPage then
                    table.insert(pages, nextPage)
                end
 
                i = i + 2
            end


        if description == '' and target == '' then
            -- 未指定页面时自动生成消歧义链接
             break
            if #pages == 0 then
        end
                table.insert(pages, defaultPage)
             end


        if target ~= '' then
             local description = use or '其他用法'
             local prefix = description ~= ''
                and description .. ',请参阅'
                or '其他用法,请参阅'


             table.insert(
             table.insert(
                 output,
                 parts,
                 prefix .. link(target) .. '。'
                 '关于' .. description ..
                ',请见' .. formatList(pages) .. '。'
             )
             )
             i = i + 2
             i = i + 2
         else
 
             table.insert(
            if not use or i > maxArg then
                output,
                finished = true
                '其他用法,请参阅' .. link(description) .. '。'
            end
             )
         until finished
            break
    end
 
    -- 附加文本
    if extra then
        if not extra:match('[。!?%.!?]$') then
             extra = extra .. '。'
        end
        table.insert(parts, extra)
    end
 
    return table.concat(parts)
end
 
function p.about(frame)
    local args = {}
 
    -- 读取模板参数
    local parent = frame:getParent()
 
    if parent then
        for k, v in pairs(parent.args) do
             args[k] = trim(v)
         end
         end
     end
     end


     local extra = trim(args.text)
     for k, v in pairs(frame.args) do
    if extra ~= '' then
        args[k] = trim(v)
        table.insert(output, extra)
     end
     end


     local content = table.concat(output)
     local content = buildText(args)
    if content == '' then return '' end


     -- 直接生成原模板的 HTML,避免循环
     -- 保留 Blockland Wiki 原 Note 外观
     local html = mw.html.create('div')
     local root = mw.html.create('div')
         :addClass('hatnote')
         :addClass('hatnote')
         :cssText(
         :cssText(
第77行: 第160行:
         )
         )


     html:tag('div')
     if trim(args.selfref) == 'yes' then
        root:addClass('selfref')
    end
 
    root:tag('div')
         :cssText(
         :cssText(
             'flex:0 0 25px;' ..
             'flex:0 0 25px;' ..
第88行: 第175行:
         )
         )


     html:tag('div')
     root:tag('div')
         :cssText('flex:1;min-width:0;')
         :cssText('flex:1;min-width:0;')
         :wikitext(content)
         :wikitext(content)


     return tostring(html)
     return tostring(root)
end
end


return p
return p

2026年11月15日 (日) 12:23的版本

此模块的文档可以在模块:Note/doc创建


local p = {}

local function trim(s)
    if s == nil then return nil end
    s = mw.text.trim(tostring(s))
    return s ~= '' and s or nil
end

local function formatLink(page)
    if not page then return nil end
    return "「'''[[" .. page .. "]]'''」"
end

local function formatList(pages)
    local formatted = {}

    for _, page in ipairs(pages) do
        table.insert(formatted, formatLink(page))
    end

    if #formatted == 0 then return nil end
    if #formatted == 1 then return formatted[1] end
    if #formatted == 2 then
        return formatted[1] .. '和' .. formatted[2]
    end

    local last = table.remove(formatted)
    return table.concat(formatted, '、') .. '和' .. last
end

local function getPageType(args)
    if trim(args.section) then
        return '章节'
    end

    local ns = mw.title.getCurrentTitle().namespace

    local types = {
        [0] = '条目',
        [4] = '项目页面',
        [6] = '文件',
        [10] = '模板',
        [14] = '分类',
        [828] = '模块'
    }

    return types[ns] or '页面'
end

local function buildText(args)
    local parts = {}
    local subject = trim(args[2])
    local extra = trim(args.text)

    if subject then
        table.insert(
            parts,
            '此' .. getPageType(args) ..
            '介绍的是' .. subject .. '。'
        )
    end

    local title = mw.title.getCurrentTitle().text
    local defaultPage = title .. ' (消歧义)'

    local maxArg = 2
    for k in pairs(args) do
        if type(k) == 'number' and k > maxArg then
            maxArg = k
        end
    end

    local i = 3

    -- 与 Wikipedia 的 About 参数结构一致:
    -- 主题 | 用法 | 页面 | 和 | 页面 | 下一用法 | 页面
    if i <= maxArg or not extra then
        local finished = false

        repeat
            local use = trim(args[i])
            local pages = {}

            local firstPage = trim(args[i + 1])
            if firstPage then
                table.insert(pages, firstPage)
            end

            -- 收集通过“和”连接的多个页面
            while trim(args[i + 2]) == '和' do
                local nextPage = trim(args[i + 3])

                if nextPage then
                    table.insert(pages, nextPage)
                end

                i = i + 2
            end

            -- 未指定页面时自动生成消歧义链接
            if #pages == 0 then
                table.insert(pages, defaultPage)
            end

            local description = use or '其他用法'

            table.insert(
                parts,
                '关于' .. description ..
                ',请见' .. formatList(pages) .. '。'
            )

            i = i + 2

            if not use or i > maxArg then
                finished = true
            end
        until finished
    end

    -- 附加文本
    if extra then
        if not extra:match('[。!?%.!?]$') then
            extra = extra .. '。'
        end
        table.insert(parts, extra)
    end

    return table.concat(parts)
end

function p.about(frame)
    local args = {}

    -- 读取模板参数
    local parent = frame:getParent()

    if parent then
        for k, v in pairs(parent.args) do
            args[k] = trim(v)
        end
    end

    for k, v in pairs(frame.args) do
        args[k] = trim(v)
    end

    local content = buildText(args)

    -- 保留 Blockland Wiki 原 Note 外观
    local root = mw.html.create('div')
        :addClass('hatnote')
        :cssText(
            'display:flex;' ..
            'align-items:flex-start;' ..
            'margin:0.45em 0 0.65em 1.6em;' ..
            'font-size:0.875em;' ..
            'line-height:1.55;'
        )

    if trim(args.selfref) == 'yes' then
        root:addClass('selfref')
    end

    root:tag('div')
        :cssText(
            'flex:0 0 25px;' ..
            'width:25px;' ..
            'margin-right:0.45em;' ..
            'padding-top:0.05em;'
        )
        :wikitext(
            '[[File:消歧义.png|23px|link=|alt=]]'
        )

    root:tag('div')
        :cssText('flex:1;min-width:0;')
        :wikitext(content)

    return tostring(root)
end

return p