Module:Get short description
Appearance
Implements {{get short description}}.
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 '<strong class="error">No page given</strong>'
end
local content = page:getContent()
if not content then
--page does not exist
return '<strong class="error">"'..title..'" does not exist</strong>'
end
content = frame:preprocess(content) -- expand 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