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

模块:Zhchar:修订间差异

来自奇葩栖息地
添加的内容 删除的内容
(//Edit via InPageEdit)
(//Edit via InPageEdit)
 
(未显示同一用户的3个中间版本)
第1行: 第1行:
local p = {}
local p = {}
p.zhchar = function( f )
p.zhchar = function(f)
local args = f
local args = f
if f == mw.getCurrentFrame() then
if f == mw.getCurrentFrame() then
args = f:getParent().args
args = f:getParent().args
end
end
local zhchar = {}
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
-- Process the returned content to expand Rarechar templates
local result = table.concat( zhchar )
result = mw.text.unstripNoWiki(result) -- Ensure no wiki parsing occurs
result = mw.text.expandTemplate(result) -- Expand templates
return result
end


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

return table.concat(zhchar)
end


p.key = function(key, f)
local symbols = mw.loadData( 'Module:Zhchar/Symbols' )
if key == '' then
local rareCharPattern = '{{RareChar|%s*([^|}]+)%s*|%s*([^|}]+)%s*}}'
return ''
local rareCharReplacement = function( rareChar, rareCharArgs )
end
return mw.text.trim(mw.getCurrentFrame():preprocess('{{RareChar|' .. rareChar .. '|' .. rareCharArgs .. '}}'))
end


local symbols = mw.loadData('Module:Zhchar/Symbols')
local replacedKey = key:gsub(rareCharPattern, rareCharReplacement)
local value = symbols[key] or key
if mw.ustring.match(value, '{{RareChar') then
return ( symbols[replacedKey] or replacedKey )
value = f:preprocess(value)
end
return value
end
end



2024年3月17日 (日) 10:11的最新版本

[创建 | 历史 | 清除缓存]文档页面
此模块没有文档页面。如果你知道此模块的使用方法,请帮助为其创建文档页面。
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, f))
            end
            table.insert(zhchar, table.concat(combozhchar, ' + '))
        else
            table.insert(zhchar, p.key(key, f))
        end
    end

    return table.concat(zhchar)
end

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

    local symbols = mw.loadData('Module:Zhchar/Symbols')
    local value = symbols[key] or key
    if mw.ustring.match(value, '{{RareChar') then
        value = f:preprocess(value)
    end
    return value
end

return p