Documentation for this module may be created at Module:SummarySnippet/doc
local p = {}
function p.fromPage(frame)
local input = frame.args[1] or ""
-- Extract and clean up the title from [[Page]] or [[Page|Display]]
local raw = mw.ustring.match(input, "%[%[(.-)%]%]") or input
local titleText = mw.text.split(raw, "|")[1]
-- Resolve title object
local title = mw.title.new(titleText)
if not title then
return "Invalid page title: " .. titleText
end
-- Get content and return preview if it exists
if title.exists then
local content = title:getContent()
if content then
local preview = mw.ustring.sub(content, 1, 150)
return preview .. "..."
else
return "No content on: " .. title.fullText
end
else
return "Page does not exist: " .. titleText
end
end
return p