Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Lead: Difference between revisions

From Teriock
Content deleted Content added
No edit summary
No edit summary
Line 21: Line 21:


-- Return the parsed wikitext
-- Return the parsed wikitext
return 'START\n\n' .. frame:preprocess(content) .. '\n\nEND'
-- return frame:preprocess(content)
return content
end
end



Revision as of 20:17, 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 frame:preprocess(content)
    return content
end

return p