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:34, 16 October 2022 ([Factotum]). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local getArgs = require('Module:Arguments').getArgs
local p = {}

function p.main(frame)
	local args = getArgs(frame)
	local title = args.page
	local nomatch = args.nomatch or ""
	page = mw.title.new(title)
	if page then
	  local content = page:getContent() or ''
	else
		page = ''
	end
	content = frame:preprocess(content) -- expand content
	return p._main(content)
end


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


return p