Module:Consecutive links: Difference between revisions

From Caves of Qud Wiki
Jump to navigation Jump to search
m (add support for prefix and postfix)
m (avoid double linking ([[[[<link>]]]]) if links are passed to this module)
Line 7: Line 7:
local postfix = frame.args[5]
local postfix = frame.args[5]
local b = string.gsub(frame.args[1], "%s*" .. separator .. "%s*", "]]" .. replacer .. "[[")
local b = string.gsub(frame.args[1], "%s*" .. separator .. "%s*", "]]" .. replacer .. "[[")
return prefix .. "[[" .. b .. "]]" .. postfix
b = "[[" .. b .. "]]"
b = string.gsub(string.gsub(b,"[[[[","[["),"]]]]","]]")
return prefix .. b .. postfix
end
end
return p
return p

Revision as of 15:48, 12 August 2019


local p = {}

function p.parse(frame)
local separator = frame.args[2]
local replacer = frame.args[3]
local prefix = frame.args[4]
local postfix = frame.args[5]
local b = string.gsub(frame.args[1], "%s*" .. separator .. "%s*", "]]" .. replacer .. "[[")
b = "[[" .. b .. "]]"
b = string.gsub(string.gsub(b,"[[[[","[["),"]]]]","]]")
return prefix .. b .. postfix
end
return p