Module:CodeClean
From A KoL Wiki
Documentation for this module may be created at Module:CodeClean/doc
local p = {}
local include = "[Ii][Nn][Cc][Ll][Uu][Dd][Ee]"
local no = "[Nn][Oo]"
local only = "[Oo][Nn][Ll][Yy]"
local lt, gt = "<", ">"
function p.main(frame)
local text = frame.args[1] or ""
-- Remove all <noinclude>...</noninclude>
local r = text:gsub(lt .. no .. include .. gt .. ".-" .. lt .. "/" .. no .. include .. gt, "")
-- Truncate string at any unterminated <noinclude> tag
r = r:gsub(lt .. no .. include .. gt .. ".*", "")
-- Strip presence of <includeonly> and <onlyinclude> tags including their closing tags
r = r:gsub(lt .. include .. only ..gt, "")
r = r:gsub(lt .. "/" .. include .. only .. gt, "")
r = r:gsub(lt .. only .. include ..gt, "")
r = r:gsub(lt .. "/" .. only .. include .. gt, "")
end
return p