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 15:49, 14 August 2022 ([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 title = frame.args.page
	local nomatch = frame.args.nomatch or ""
	page = mw.title.new(title)
	if not page then
		--bad title
		return showerror('<strong class="error">No page given</strong>')
	end
	local content = page:getContent()

	if not content then
		--page does not exist
		return showerror('<strong class="error">'..title..' does not exist</strong>')
	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