Module:Excerpt: Difference between revisions

Content deleted Content added
Add more= option
Handle redirects by transcluding the target
Line 1:
local p = {}
local mRedirect = require('Module:Redirect')
 
-- Entry point for Lua callers
Line 7 ⟶ 8:
local title = mw.title.new(pagename) -- Find the lead section of the named page
if not title then return "" end
local textredir = mRedirect.getTarget(title:getContent() or ""
if redir then title = mw.title.new(redir) end
 
local text = title:getContent() or ""
text = mw.ustring.gsub(text, "%c%s*==.*","") -- remove first heading and everything after it
text = mw.ustring.gsub(text, "<noinclude>.-</noinclude>", "") -- remove noinclude bits