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
-- Fetch the raw wikitext of the page
local content = mw.title.new(title):getContent()
if not content then
return "Error: Could not fetch content for page '" .. title .. "'."
end
-- Find position of the first heading (e.g., '== Something ==')
local heading_start = string.find(content, "\n==+[^=]")
if heading_start then
-- Extract only up to the heading (excluding it)
content = string.sub(content, 1, heading_start - 1)
end
-- Return the parsed wikitext
return frame:preprocess(content)
end
return p