欢迎来到奇葩栖息地!欢迎加入Discord服务器:XfrfHCzfbW。请先至特殊:参数设置验证邮箱后再进行编辑。在特殊:参数设置挑选自己想要使用的小工具!不会编辑?请至这里学习Wikitext语法。
模块:Zhchar:修订间差异
来自奇葩栖息地
添加的内容 删除的内容
SkyEye FAST(讨论 | 贡献) (//Edit via InPageEdit) |
SkyEye FAST(讨论 | 贡献) (//Edit via InPageEdit) |
||
第20行: | 第20行: | ||
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 |
end |
||
第27行: | 第32行: | ||
return '' |
return '' |
||
end |
end |
||
⚫ | |||
local symbols = mw.loadData( 'Module:Zhchar/Symbols' ) |
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 |
|||
local replacedKey = key:gsub(rareCharPattern, rareCharReplacement) |
|||
⚫ | |||
end |
end |
||
return p |
return p |
2024年3月17日 (日) 09:59的版本
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
p.key = function( key )
if key == '' then
return ''
end
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
local replacedKey = key:gsub(rareCharPattern, rareCharReplacement)
return ( symbols[replacedKey] or replacedKey )
end
return p