Module:Sandbox/trappist the monk/get lead section

Revision as of 10:27, 22 April 2018 by imported>Trappist the monk (create;)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Sandbox/trappist the monk/get lead section/doc

p={}
function p.get_lead_section (frame)
	local title_object = mw.title.new (frame.args[1]);							-- get a title object for named article
	local content = title_object:getContent();									-- get the unparsed article content
	local text = mw.ustring.match (content, '(.-)==+');							-- get everything from start to first section header '=='

	return frame:preprocess (text);												-- return the preprocessed text;
end

return p;