Jump to content

Module:CitationAuto

Dagan Wikipedia

Documentation for this module may be created at Module:CitationAuto/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

    local title = "Unknown Title"
    local ref_name = "cite-" .. mw.md5(url)  -- Unique reference name based on URL

    local citation = string.format(
        '<ref name="%s">%s. "<a href="%s">%s</a>." Accessed %s.</ref>',
        ref_name, "Anonymous", url, title, os.date("%Y-%m-%d")
    )

    return citation
end

return p