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

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

模块:Note:修订间差异

来自Blockland Wiki
创建页面,内容为“ local p = {} local function trim(s) if s == nil then return '' end return mw.text.trim(tostring(s)) end local function link(page) page = trim(page) if page == '' then return '' end return '' .. page .. '' end function p.about(frame) local args = frame:getParent().args local subject = trim(args[2]) local section = trim(args.section) local pageType = section ~= '' and '章节' or '条目' local output = {} if…”
 
无编辑摘要
 
(未显示同一用户的4个中间版本)
第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)
-- 同时支持外部链接、内部链接、普通页面名称
     page = trim(page)
local function formatLink(value)
     if page == '' then return '' end
     value = trim(value)
     return '[[' .. page .. ']]'
     if not value then return nil end
 
    local result
 
    -- 外部链接:[https://example.com 显示文字]
    if value:match("^%[https?://") and
      value:sub(-1) == "]" then
        result = value
 
    -- 内部链接:[[页面]] 或 [[页面|显示文字]]
    elseif value:match("^%[%[.-%]%]$") then
        result = value
 
    -- 裸 URL
    elseif value:match("^https?://") then
        result = "[" .. value .. "]"
 
    -- 普通页面名称
    else
        result = "[[" .. value .. "]]"
    end
 
    -- 目标链接加粗,并使用中文引号
    return "「'''" .. result .. "'''」"
end
 
local function formatList(targets)
    local links = {}
 
    for _, target in ipairs(targets) do
        local formatted = formatLink(target)
        if formatted then
            table.insert(links, formatted)
        end
    end
 
    if #links == 0 then return '' end
     if #links == 1 then return links[1] end
    if #links == 2 then
        return links[1] .. '和' .. links[2]
    end
 
    local last = table.remove(links)
    return table.concat(links, '、') .. '和' .. last
end
end


function p.about(frame)
local function getPageType(args)
     local args = frame:getParent().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 currentTitle = mw.title.getCurrentTitle().text
    local defaultPage = currentTitle .. ' (消歧义)'
    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
    local hasOther = false


     while i <= 31 do
     while i <= maxArg do
         local description = trim(args[i])
         local description = trim(args[i])
         local target = trim(args[i + 1])
         local target = trim(args[i + 1])


         if description == '' and target == '' then
         if not description and not target then
             break
             break
         end
         end


         if target ~= '' then
        local targets = {}
             if description ~= '' then
 
                table.insert(
         if target then
                    output,
             table.insert(targets, target)
                    description .. ',请参阅' .. link(target) .. '。'
        end
                )
 
             else
        local nextIndex = i + 2
                 table.insert(
 
                    output,
        -- 多个链接使用“和”连接
                    '其他用法,请参阅' .. link(target) .. '。'
        while trim(args[nextIndex]) == '和' do
                )
            local nextTarget = trim(args[nextIndex + 1])
 
             if nextTarget then
                 table.insert(targets, nextTarget)
             end
             end
             i = i + 2
 
         else
             nextIndex = nextIndex + 2
             table.insert(
         end
                output,
 
                '其他用法,请参阅' .. link(description) .. '。'
        if #targets == 0 then
             )
             table.insert(targets, defaultPage)
             break
        end
 
        table.insert(
            parts,
            '关于' .. (description or '其他用法') ..
            ',请见' .. formatList(targets) .. '。'
        )
 
        hasOther = true
        i = nextIndex
    end
 
    if not hasOther and not extra then
        table.insert(
            parts,
            '关于其他用法,请见' ..
             formatLink(defaultPage) .. '。'
        )
    end
 
    if extra then
        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
    local root = mw.html.create('div')
         return ''
        :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
     end


     return frame:expandTemplate{
     root:tag('div')
         title = 'Note',
        :cssText(
         args = {'消歧义', content}
            '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
end


return p
return p

2026年11月15日 (日) 12:58的最新版本

此模块的文档可以在模块: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(value)
    value = trim(value)
    if not value then return nil end

    local result

    -- 外部链接:[https://example.com 显示文字]
    if value:match("^%[https?://") and
       value:sub(-1) == "]" then
        result = value

    -- 内部链接:[[页面]] 或 [[页面|显示文字]]
    elseif value:match("^%[%[.-%]%]$") then
        result = value

    -- 裸 URL
    elseif value:match("^https?://") then
        result = "[" .. value .. "]"

    -- 普通页面名称
    else
        result = "[[" .. value .. "]]"
    end

    -- 目标链接加粗,并使用中文引号
    return "「'''" .. result .. "'''」"
end

local function formatList(targets)
    local links = {}

    for _, target in ipairs(targets) do
        local formatted = formatLink(target)
        if formatted then
            table.insert(links, formatted)
        end
    end

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

    local last = table.remove(links)
    return table.concat(links, '、') .. '和' .. 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 currentTitle = mw.title.getCurrentTitle().text
    local defaultPage = currentTitle .. ' (消歧义)'

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

    local i = 3
    local hasOther = false

    while i <= maxArg do
        local description = trim(args[i])
        local target = trim(args[i + 1])

        if not description and not target then
            break
        end

        local targets = {}

        if target then
            table.insert(targets, target)
        end

        local nextIndex = i + 2

        -- 多个链接使用“和”连接
        while trim(args[nextIndex]) == '和' do
            local nextTarget = trim(args[nextIndex + 1])

            if nextTarget then
                table.insert(targets, nextTarget)
            end

            nextIndex = nextIndex + 2
        end

        if #targets == 0 then
            table.insert(targets, defaultPage)
        end

        table.insert(
            parts,
            '关于' .. (description or '其他用法') ..
            ',请见' .. formatList(targets) .. '。'
        )

        hasOther = true
        i = nextIndex
    end

    if not hasOther and not extra then
        table.insert(
            parts,
            '关于其他用法,请见' ..
            formatLink(defaultPage) .. '。'
        )
    end

    if extra then
        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)

    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