Content deleted Content added
Module to extract the lead from an article. Unlike #lsth, it removes infoboxes, hatnotes, etc. |
Fix comments; return blank string on certain errors |
||
Line 4:
-- Returns a string value: text of the lead of a page
function p._lead(pagename)
if not pagename then return "" end
title=mw.title.new(pagename) -- Find the lead section of the named page
if not title then return "" end
text=title.getContent(title) or ""▼
▲ text=title.getContent(title)
text=mw.ustring.gsub(text,"%c%s*==.*","") -- remove first heading and everything after it
text=mw.ustring.gsub(text,"<noinclude>.-</noinclude>","") -- remove noinclude bits
Line 15 ⟶ 13:
text=mw.ustring.gsub(text,"<ref.->.-</ref>","") -- remove refs
text=mw.ustring.match(text,"%C*'''.*") or text -- start at the first line with bold text, if any
return text
end
Line 23 ⟶ 21:
local args = frame.args -- from calling module
local pargs = frame:getParent().args -- from template
return frame:preprocess(p._lead(args[1] or pargs[1]))
end
|