Module:Respell: Difference between revisions
Appearance
Content deleted Content added
Caleb Cooper (talk | contribs) Created page with "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..." |
Caleb Cooper (talk | contribs) No edit summary |
||
| Line 26: | Line 26: | ||
.. '</i>' |
.. '</i>' |
||
if args.link ~= 'no' then |
if args.link ~= 'no' then |
||
ret = '[[Help:Pronunciation respelling key|' .. ret .. ']]' |
ret = '[[wikipedia:Help:Pronunciation respelling key|' .. ret .. ']]' |
||
end |
end |
||
return ret |
return ret |
||
Latest revision as of 12:45, 19 October 2020
| This module is subject to page protection. It is a highly visible module in use by a very large number of pages, or is substituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it is protected from editing. |
This module implements {{Respell}}. Please see the template page for documentation.
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 = '[[wikipedia:Help:Pronunciation respelling key|' .. ret .. ']]'
end
return ret
end
function p.main(frame)
return p._main(frame:getParent().args)
end
return p