模組:Respell
外观
上述文档嵌入自Module:Respell/doc。 (编辑 | 历史) 编者可以在本模块的沙盒 (创建 | 镜像)和测试样例 (创建)页面进行实验。 本模块的子页面。 |
local p = {}
function p._main(args)
local ret = {}
for i, v in ipairs(args) do
v = mw.text.trim(v)
-- Compatibility: Ignore arguments that only contain an apostrophe
if v ~= '' and v ~= "'" then
if ret[#ret]
and not (ret[#ret]:find('_') or ret[#ret]:find('%-%)?$'))
and not (v:find('_') or v:find('^%(?%-'))
then
table.insert(ret, '-')
end
if v:find('^[%u%(%)]+$') then
v = '<span style="font-size:90%">' .. v .. '</span>'
end
table.insert(ret, v)
end
end
ret = '<i title="英語發音重拼">' ..
table.concat(ret):gsub('_', ' ')
:gsub(' %-', ' -⁠')
:gsub('^%-', '-⁠')
.. '</i>'
if args.link ~= 'no' then
ret = '[[Wikipedia:發音重拼|' .. ret .. ']]'
end
return ret
end
function p.main(frame)
return p._main(frame:getParent().args)
end
return p