欢迎来到奇葩栖息地!欢迎加入Discord服务器:XfrfHCzfbW欢迎加入QQ频道:r01m9y3iz6请先至特殊:参数设置验证邮箱后再进行编辑。特殊:参数设置挑选自己想要使用的小工具!不会编辑?请至这里学习Wikitext语法。

模块:Zhchar:修订间差异

来自奇葩栖息地
添加的内容 删除的内容
(//Edit via InPageEdit)
(//Edit via InPageEdit)
第1行: 第1行:
local p = {}
local p = {}
p.zhchar = function( f )
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
end
local zhchar = {}
for _, key in ipairs( args ) do
key = mw.text.trim( key )
if key ~= '+' and key:find( '%+' ) then
local combozhchar = {}
for comboKey in mw.text.gsplit( key, '%s*%+%s*' ) do
table.insert( combozhchar, p.key( comboKey ) )
end
table.insert( zhchar, table.concat( combozhchar, ' + ' ) )
else
table.insert( zhchar, p.key( key ) )
end
end
return table.concat( zhchar )
end


p.key = function( key )
p.zhchar = function(frame)
local args = frame
if key == '' then
if frame == mw.getCurrentFrame() then
return ''
args = frame:getParent().args
end
end


local zhchar = {}
local symbols = mw.loadData( 'Module:Zhchar/Symbols' )
local rareCharPattern = '{{RareChar|%s*([^|}]+)%s*|%s*([^|}]+)%s*}}'
local rareCharReplacement = function( rareChar, rareCharArgs )
return mw.getCurrentFrame():expandTemplate{ title = 'RareChar', args = { rareChar, rareCharArgs } }
end


for _, key in ipairs(args) do
local replacedKey = key:gsub(rareCharPattern, rareCharReplacement)
key = mw.text.trim(key)
if key ~= '+' and key:find('%+') then
return ( symbols[replacedKey] or replacedKey )
local combozhchar = {}
for comboKey in mw.text.gsplit(key, '%s*%+%s*') do
table.insert(combozhchar, p.key(comboKey))
end
table.insert(zhchar, table.concat(combozhchar, ' + '))
else
table.insert(zhchar, p.key(key))
end
end

return mw.text.unstrip(table.concat(zhchar))
end
end

p.key = function(key)
if key == '' then
return ''
end

local symbols = mw.loadData('Module:Zhchar/Symbols')
return mw.text.unstrip(symbols[key] or key)
end

return p
return p

2024年3月17日 (日) 10:05的版本

[创建 | 历史 | 清除缓存]文档页面
此模块没有文档页面。如果你知道此模块的使用方法,请帮助为其创建文档页面。
local p = {}

p.zhchar = function(frame)
    local args = frame
    if frame == mw.getCurrentFrame() then
        args = frame:getParent().args
    end

    local zhchar = {}

    for _, key in ipairs(args) do
        key = mw.text.trim(key)
        if key ~= '+' and key:find('%+') then
            local combozhchar = {}
            for comboKey in mw.text.gsplit(key, '%s*%+%s*') do
                table.insert(combozhchar, p.key(comboKey))
            end
            table.insert(zhchar, table.concat(combozhchar, ' + '))
        else
            table.insert(zhchar, p.key(key))
        end
    end

    return mw.text.unstrip(table.concat(zhchar))
end

p.key = function(key)
    if key == '' then
        return ''
    end

    local symbols = mw.loadData('Module:Zhchar/Symbols')
    return mw.text.unstrip(symbols[key] or key)
end

return p