Jump to content

Module:Get short description

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Qwerfjkl (talk | contribs) at 14:56, 14 August 2022 (works [Bawl!]). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local p = {}
function p.main(frame)
	local page = frame.args.page or mw.title.getCurrentTitle().fullText
	local nomatch = frame.args.nomatch or ""
--args: 1 - ustring pattern, 2 - value if present, 3 - value if absent, 
--      page - page to test if not this page


	page = mw.title.new(page)
	if not page then
		--bad title
		return 'No page given'
	end
	local content = page:getContent()

	if not content then
		--page does not exist
		return "PDNE"
	end
	content = frame:preprocess(content) -- expand content

	return mw.ustring.match(content, '<div class="shortdescription nomobile noexcerpt noprint searchaux" style="display:none">([^<]+)') or nomatch
end

return p