Created page with "local p = {} --- Remove duplicate links and return the singular ones function p.main(frame) local input = frame.args[1] or "" local links = {} input:gsub("%[%[([^%]]*)%]%]", function(link) link = "" .. link .. "" -- :gsub removes the double brackets table.insert(links, link) end) local duplicateTracker = {} for _, link in pairs(links) do if not duplicateTracker[link] then duplicateTracker[link] = 0..." |
No edit summary Tag: Manual revert |
(One intermediate revision by the same user not shown) | |
(No difference)
|
Latest revision as of 03:06, 10 November 2023
This documentation is transcluded from Module:Remove Duplicate Links/doc. Changes can be proposed in the talk page.
This module is unused.
This module is neither invoked by a template nor required/loaded by another module. If this is in error, make sure to add
{{Documentation}}
/{{No documentation}}
to the calling template's or parent's module documentation.Function list |
---|
local p = {}
--- Remove duplicate links and return the singular ones
function p.main(frame)
local input = frame.args[1] or ""
local links = {}
input:gsub("%[%[([^%]]*)%]%]", function(link)
link = "[[" .. link .. "]]" -- :gsub removes the double brackets
table.insert(links, link)
end)
local duplicateTracker = {}
for _, link in pairs(links) do
if not duplicateTracker[link] then
duplicateTracker[link] = 0
end
duplicateTracker[link] = duplicateTracker[link] + 1
end
local output = ""
for link, duplicates in pairs(duplicateTracker) do
if duplicates == 1 then
output = output .. link
end
end
return output
end
return p