Module:Get short description
Appearance
Implements {{get short description}}.
local p = {}
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('<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">'..page..' 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