Module:Excerpt

local p = {}

-- Entry point for Lua callers -- Returns a string value: text of the lead of a page function p._lead(pagename) -- Find the lead section of the named page -- %b{} removes any leading -- If the page exists, protected or not, this is some other value -- Note: this check does NOT record a wikilink or transclusion from the calling page to pagename title=mw.title.new(pagename) text=title.getContent(title) text=mw.ustring.gsub(text,"%c%s*==.*","") -- remove first heading and everything after it	text=mw.ustring.gsub(text," .- ","") -- remove noinclude bits text=mw.ustring.gsub(text,"^%A*%b{}%s*","") -- remove infoboxes, hatnotes, tags, etc. from the front text=mw.ustring.gsub(text,".- ","") -- remove refs text=mw.ustring.match(text,"%C*'''.*") or text -- start at the first line with bold text, if any return text; end

-- Entry point for template callers using #invoke: function p.lead(frame) -- args = { 1 = page name } 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

return p