More actions
Content deleted Content added
Created page with "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==+[^..." |
No edit summary |
||
Line 21: | Line 21: | ||
-- Return the parsed wikitext |
-- Return the parsed wikitext |
||
return frame:preprocess(content) |
return 'START\n\n' .. frame:preprocess(content) .. '\n\nEND' |
||
end |
end |
||
Revision as of 20:15, 29 March 2025
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 'START\n\n' .. frame:preprocess(content) .. '\n\nEND'
end
return p