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:30, 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 showerror(text)
	 return frame:preprocess( "{{Error|" .. "}}")
	 end
function p.main(frame)
	local page = frame.args.page
	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 showerror('No page given')
	end
	local content = page:getContent()

	if not content then
		--page does not exist
		return showerror("Page does not exist")
	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