Documentation for this module may be created at Module:Lead/doc
local p = {}
function p.lead(frame)
local title = frame.args[1]
if not title then
return "Error: No page title provided."
end
-- Create a new title object
local pageTitle = mw.title.new(title)
if not pageTitle then
return "Error: Invalid page title."
end
-- Transclude and expand templates from the page
local fullContent = frame:expandTemplate{ title = title }
-- Find the position of the first heading (== Heading ==)
local headingStart = string.find(fullContent, "\n==+[^=]")
local leadContent
if headingStart then
leadContent = string.sub(fullContent, 1, headingStart - 1)
else
leadContent = fullContent
end
return leadContent .. frame:preprocess("<div>{{Button|Full Rules Text|l=" .. title .. "}}</div>")
end
return p