Module:CitationAuto1
Wuwu
Documentation for this module may be created at Module:CitationAuto1/doc
local p = {}
function p.cite(frame)
local url = frame.args[1]
if not url or url == "" then
return "Error: Please provide a valid URL."
end
-- Extract possible title from URL structure (works for Wikimedia pages)
local title = string.match(url, "/wiki/([^#?]*)") or "Unknown Title"
title = mw.uri.decode(title)
-- Formatting the citation
local citation = mw.html.create("span")
:addClass("citation")
:wikitext(string.format('"%s." Accessed %s.', title, os.date("%Y-%m-%d")))
:wikitext(string.format(' <a href="%s">[Source]</a>', url))
return tostring(citation)
end
return p