Module:Bad links

local p = {}

local bad_links = { 'mojito', 'gruy[èe]re', 'sushi', 'pilser', 'frappuccino', 'wolverine', 'maserati', 'green', -- green tea 'ak[%-]?47', 'pok[eé]mon', 'dragon' }

function p.main(frame) local args = frame:getParent.args

return p._main(args[1] or '') end

function p._main(args) local result = {}

local split_text = mw.text.split(args,' ')

local onLink = false local found_match

for _, inner in ipairs(split_text) do		found_match = false local replacement = inner

if inner:match('^([%[{])%1') then onLink = true end

if not onLink then local lower = mw.ustring.lower(replacement) for _, bad_link in ipairs(bad_links) do 				if mw.ustring.find(lower,bad_link) then found_match = true break end end if found_match then replacement = mw.text.split(inner,'')

table.insert(replacement,2,' ') replacement = table.concat(replacement,'') end end

if inner:match('([%]}])%1$') then onLink = false end

table.insert(result,replacement) end

result = table.concat(result,' ')

return result end

function p.lite(frame) local args = frame:getParent.args

return p._lite(args[1] or '') end

function p._lite(txt) local replacement = mw.text.split(txt,'')

table.insert(replacement,2,' ') replacement = table.concat(replacement,'')

return replacement end

return p