Module:Get short description
Appearance
Implements {{get short description}}.
local p = {}
function p.main(frame)
local page = frame.args.page or mw.title.getCurrentTitle().fullText
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 'No page given'
end
local content = page:getContent()
if not content then
--page does not exist
return "PDNE"
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