require('strict')local p =
local function multiFind(s, patterns, init) local i, j = mw.ustring.find(s, patterns[1], init) for n = 2, #patterns do local i2, j2 = mw.ustring.find(s, patterns[n], init) if i2 and (not i or i2 < i) then i, j = i2, j2 end end return i, jend
local function wrapAtSpace(s) return mw.ustring.gsub(s, '(%s+)', '
%1')endlocal function wrapAtSpaceSafely(s) local patterns = s = mw.ustring.gsub(s, '%[%[([^%]|]-%s[^%]|]-)%]%]', '%1') -- Pipe all links local t = local init while true do local i, j = multiFind(s, patterns, init) if not i then break end local pre = wrapAtSpace(mw.ustring.sub(s, init, i - 1)) -- What precedes the match table.insert(t, pre) table.insert(t, mw.ustring.sub(s, i, j)) -- The match init = j + 1 end local post = wrapAtSpace(mw.ustring.sub(s, init)) -- What follows the last match table.insert(t, post) return table.concat(t)end
local function checkNamespace(isDebug) return isDebug or require('Module:Category handler').mainend
local function renderCats(cats, isDebug) if not cats[1] or not checkNamespace(isDebug) then return end local t = for _, v in ipairs(cats) do table.insert(t, string.format('', isDebug and ':' or , v )) end return table.concat(t)end
local function resolveSynonym(s) return mw.loadData('Module:Lang/ISO 639 synonyms')[s] or send
local function getLangName(fullLangCode, link) return require('Module:Lang')._name_from_tagend
local function linkLang(label, target, link) return link
function p._main(args) local ret, cats =, local isDebug = args.debug
'