Module:Description2

From Call of Duty Esports Wiki
Jump to: navigation, search

Documentation for this module may be created at Module:Description2/doc

local util_args = require('Module:ArgsUtil')
local util_text = require('Module:TextUtil')
local REPLACE = {
	{ find = "%[[^%]]*%|", replace = "[" },
	{ find = "['%[%]]", replace = '' },
	{ find = "<div.-</div>", replace = '' },
	{ find = '<span class="no-desc2".-</span>', replace = '' },
	{ find = '  ', replace = ' ' },
}

local p = {}
function p.main(frame)
	-- strips links & markup characters from standard bio sentence or custom text to be saved in metadesc via description2 extension
	local args = util_args.merge()
	local desc = args[1]
	if not desc then
		return
	end
	frame:callParserFunction{
		name = '#description2',
		args = util_text.escapeCustom(desc, REPLACE)
	}
end
return p