模块:Zhchar:修订间差异

删除108字节 、​ 2024年3月17日 (星期日)
//Edit via InPageEdit
(//Edit via InPageEdit)
(//Edit via InPageEdit)
 
(未显示同一用户的2个中间版本)
第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
return table.concat( zhchar )
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
 
return table.concat( zhchar )
local symbols = mw.loadData( 'Module:Zhchar/Symbols' )
end
local rareCharPattern = '{{RareChar|%s*([^|}]+)%s*|%s*([^|}]+)%s*}}'
local rareCharReplacement = function( rareChar, rareCharArgs )
return mw.getCurrentFrame():expandTemplate{ title = 'RareChar', args = { rareChar, rareCharArgs } }
end
 
p.key = mw.text.trimfunction( key, f)
local replacedKey = key:gsub(rareCharPattern, rareCharReplacement)
if key == '' then
return ''
return ( symbols[replacedKey] or replacedKey )
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
2,007

个编辑