Module:CiteTweet
This module is invoked by Template:Cite tweet to parse post authors.
local p = {}
function p.main(frame)
local args = frame:getParent().args
local url = args.url or args[1] or ""
local author = args.author or ""
local date = args.date or ""
-- Validate URL
if url == "" then
return '<span style="color:red;">Error: URL required</span>'
end
-- Parse author from URL if not provided
if author == "" then
author = url:match("x%.com/([^/]+)/status/") or url:match("twitter%.com/([^/]+)/status/")
if not author then
return '<span style="color:red;">Error: Could not parse username from URL. Please provide author parameter.</span>'
end
end
-- Build output
local output = url .. ", [https://www.x.com/" .. author .. " @" .. author .. "] Twitter post"
if date ~= "" then
output = output .. ", " .. date
end
output = output .. "."
return output
end
return p