Jump to content

Module:misc

E Victionario

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

-- Module:misc
-- 2016-05-31 -- V1 --
-- {{#invoke:misc|remove_links|{{{1|}}}}}
-- {{#invoke:misc|escape_wiki|{{{1|}}}}}

local export = {}

-- Strips all square brackets out or replaces them.
function export.remove_links(text)
	if type(text) == "table" then text = text.args[1] end; if not text then text = "" end
	
	text = text:gsub("%[%[Category:[^|%]]-|?[^|%]]-%]%]", "")
	text = text:gsub("%[%[[^|%]]-|", "")
	text = text:gsub("%[%[", "")
	text = text:gsub("%]%]", "")

	return text
end

function export.escape_wiki(frame)
	return mw.text.nowiki(frame.args[1] or "")
end

return export