Module:Consecutive links

From Caves of Qud Wiki
Revision as of 16:53, 16 November 2019 by Teamtoto (talk | contribs) (A bit of changing: can call consecutivetemplates to replace bracket types with curly bois)
Jump to navigation Jump to search

local p = {}

function p.parse(args, brackets)
local separator = args[2]
local replacer = args[3]
local prefix = args[4]
local postfix = args[5]
local linkprefix = args[6]
local linkpostfix = args[7]
local brackets = brackets or {'[[', ']]'}

local b = string.gsub(args[1], "%s*" .. separator .. "%s*", linkpostfix .. brackets[2] .. replacer .. brackets[1] .. linkprefix)
return prefix .. brackets[1] .. linkprefix .. b .. linkpostfix ..brackets[2] .. postfix
end

function p.consecutivelinks(frame)
return p.parse(frame.args, {'[[', ']]'})
end

function p.consecutivetemplates(frame)
return p.parse(frame.args, {'{{', '}}'})
end

return p