模块:Zhchar:修订间差异

删除330字节 、​ 2024年3月17日 (星期日)
//Edit via InPageEdit
(//Edit via InPageEdit)
(//Edit via InPageEdit)
 
(未显示同一用户的4个中间版本)
第1行:
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
-- 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 == '' thenmw.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
 
local result = return table.concat( zhchar )
end
 
p.key = mw.text.trimfunction( 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.getCurrentFrame():expandTemplate{ title = 'RareChar', args = { 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 resultvalue
end
 
2,007

个编辑