Module:Respell: Difference between revisions
Jump to navigation
Jump to search
Ozycaevias (talk | contribs) m (1 revision imported) |
mNo edit summary |
||
Line 26: | Line 26: | ||
:gsub('^%-', '-⁠') | :gsub('^%-', '-⁠') | ||
.. '</i>' | .. '</i>' | ||
ret = link and '[[Help:Pronunciation respelling key|' .. ret .. ']]' or ret | ret = link and '[[wikipedia:Help:Pronunciation respelling key|' .. ret .. ']]' or ret | ||
return ret | return ret | ||
end | end |
Latest revision as of 20:53, 5 March 2019
Documentation for this module may be created at Module:Respell/doc
local p = {}
function p._main(args)
local ret = {}
local link
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
-- For documentation: Blank parameter at the end suppresses the link
if not args[i + 1] and v ~= '' then link = true end
end
ret = '<i title="English pronunciation respelling">' ..
table.concat(ret):gsub('_', ' ')
:gsub(' %-', ' -⁠') -- Avoid dangling hyphens
:gsub('^%-', '-⁠')
.. '</i>'
ret = link and '[[wikipedia:Help:Pronunciation respelling key|' .. ret .. ']]' or ret
return ret
end
function p.main(frame)
return p._main(frame:getParent().args)
end
return p