The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 9: | Line 9: | ||
-- Check if the page content is available | -- Check if the page content is available | ||
if not wikitext then | if not wikitext then | ||
return "Error: Unable to fetch content for page '" .. pageTitle .. "'." | |||
end | end | ||
Line 15: | Line 15: | ||
PA = {}, | PA = {}, | ||
MD = {}, | MD = {}, | ||
Online = {} | |||
Online | }local function processRow(row) | ||
} | |||
local function processRow(row) | |||
-- Extract everything up to the first "]]" | -- Extract everything up to the first "]]" | ||
local campaignWithLink = row:match("^.-]]") | local campaignWithLink = row:match("^.-]]") | ||
-- Extract the location, which is the last element before the end of the row | |||
local location = row:match("[^\n]+$") | local location = row:match("[^\n]+$") | ||
if campaignWithLink and location then | if campaignWithLink and location then | ||
-- Trim the location string | |||
--location = mw.text.trim(location) | |||
location = location:gsub("^|%s*'''", ""):gsub("'''%s*$", "") | |||
campaignWithLink = campaignWithLink:gsub("^|", ""):gsub("'''%s*$", ""):gsub("'''", "") | |||
-- Add the campaign to the relevant location list | -- Add the campaign to the relevant location list | ||
if location:find("PA") then | if location:find("PA") then | ||
table.insert(campaigns.PA, campaignWithLink) | table.insert(campaigns.PA, campaignWithLink) | ||
elseif location:find("MD") then | |||
table.insert(campaigns.MD, campaignWithLink) | table.insert(campaigns.MD, campaignWithLink) | ||
elseif location:find("Online") then | |||
table.insert(campaigns.Online, campaignWithLink) | table.insert(campaigns.Online, campaignWithLink) | ||
end | end | ||
end | end | ||
end | end |