Module:Consecutive links

From Caves of Qud Wiki
Revision as of 17:10, 16 November 2019 by Teamtoto (talk | contribs)
Jump to navigation Jump to search

local p = {}

function p.parse(args, brackets)
if args.args ~= nil then
  args = args.args
end
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.. brackets[3])
return prefix .. brackets[1] .. linkprefix.. brackets[3] .. 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