local p =
local find = mw.ustring.findlocal gmatch = mw.ustring.gmatchlocal gsub = mw.ustring.gsublocal sub = mw.ustring.sublocal trim = mw.text.trim
local function multiFind(s, t) local i, j = find(s, t[1]) for n = 2, #t do local i2, j2 = find(s, t[n]) if i2 and (not i or i2 < i) then i, j = i2, j2 end end return i, jend
local function wrapSpaces(s) return gsub(s, '(%s+)', '
%1')endlocal function escAndRep(s) local patterns = s = gsub(s, '%[%[([^%]|]-%s[^%]|]-)%]%]', '%1') -- Pipe unpiped links local i, j = multiFind(s, patterns) if i then -- Match found local remaining, escaped =, repeat table.insert(remaining, sub(s, 1, i - 1)) -- What precedes the match table.insert(escaped, sub(s, i, j)) -- The match s = sub(s, j + 1) -- Truncate i, j = multiFind(s, patterns) until not i table.insert(remaining, s) -- What follows the last match s = for k, v in ipairs(remaining) do v = wrapSpaces(v) table.insert(s, v) table.insert(s, escaped[k]) end s = table.concat(s) else s = wrapSpaces(s) end return send
function p._main(s, wrap, tooltip, class) local span = mw.html.create('span') :attr('lang', 'und-Latn-fonipa') :addClass('IPA') :addClass(class) -- wrap=all: Do nothing -- wrap=none: Never break -- Otherwise: Break at spaces only if wrap ~= 'all' then span:addClass('nowrap') if wrap ~= 'none' then s = escAndRep(s) end end if tooltip ~= then -- tooltip is added unless blank span:attr('title', tooltip or 'Representation in the International Phonetic Alphabet (IPA)') end return tostring(span:wikitext(s))end
function p.main(frame) -- local args = frame:getParent.args local args = frame.args[1] and frame.args or frame:getParent.args local s = args[1] and trim(args[1]) or return s
function p._lang(args) local ret = local cats =
-- Label do local label = args.label local lang = args.lang and args.lang ~= and args.lang local defaultlabel = args.defaultlabel and args.defaultlabel ~= and args.defaultlabel or lang and lang .. ' pronunciation:' if not label then local labelcode = args.labelcode and args.labelcode:lower if labelcode then local function returnLabel if labelcode
k then return v end end if labelcode
t[i] then return t[#t] .. ' pronunciation:' end if labelcode
function p.lang(frame) local args = frame.args local parentArgs = frame:getParent.args for k, v in pairs(parentArgs) do if type(k)
and or p._lang(args)end
return p