Difference between revisions of "Module:Respell/sandbox"
Jump to navigation
Jump to search
blackwiki>Nardog |
blackwiki>Nardog |
||
| Line 7: | Line 7: | ||
-- Compatibility: Ignore arguments that only contain an apostrophe | -- Compatibility: Ignore arguments that only contain an apostrophe | ||
if v ~= '' and v ~= "'" then | if v ~= '' and v ~= "'" then | ||
| − | if ret[#ret] and not ( | + | if ret[#ret] |
| − | + | and not (ret[#ret]:find('_') or ret[#ret]:find('%-%)?$')) | |
| − | + | and not (v:find('_') or v:find('^%(?%-')) | |
| − | |||
| − | |||
| − | and not (v:find('_ | ||
then | then | ||
table.insert(ret, '-') | table.insert(ret, '-') | ||
Revision as of 17:08, 14 August 2019
Documentation for this module may be created at Module:Respell/sandbox/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="English pronunciation respelling">' ..
table.concat(ret):gsub('_', ' ')
-- Avoid dangling hyphens
:gsub(' %-', ' -⁠')
:gsub('^%-', '-⁠')
.. '</i>'
if args.link ~= 'no' then
ret = '[[Help:Pronunciation respelling key|' .. ret .. ']]'
end
return ret
end
function p.main(frame)
return p._main(frame:getParent().args)
end
return p