Content deleted Content added
performance enhancement |
|||
Line 94:
-- Remove the colon if the link is using the [[Help:Colon trick]].
-- result = "[[" .. result:match("%[%[:(.*%]%])")
if result:sub(3,3) == ':' then
end
Line 156 ⟶ 159:
error("Attempt to de-link non-string input.", 2)
end
-- unneccessary check
-- error('Invalid pattern detected. Patterns must begin with "^".', 2)
▲ end
-- end
-- Iterate over the text string, and replace any matched text. using the
-- delink function.
local result = ""
local sb = text:find('%[')
while text ~= "" do▼
local n
text = mw.ustring.sub(text, sb, -1)
-- Replace text using one iteration of gsub.
text, n = mw.ustring.gsub(text, pattern, delinkFunction, 1)
sb = text:find('%[', 2)
▲ result = result .. mw.ustring.sub(text, 1, 1)
▲ text = mw.ustring.sub(text, 2, -1)
end
result = result .. text
return result
end
Line 184 ⟶ 190:
end
if text:match("%[") then -- does the text contain a square bracket?
-- De-link wikilinks and return the label portion of the wikilink.
text = delinkLinkClass(text, "^%[%[.-%]%]", getDelinkedLabel)
elseif args.wikilinks == "target" then
-- De-link wikilinks and return the target portions of the wikilink. text = delinkLinkClass(text, "^%[%[.-%]%]", getDelinkedTarget)
text = delinkLinkClass(text, "^%[.-%]", delinkURL) -- De-link URLs.
end
end
if args.whitespace ~= "no" then
-- Replace single new lines with a single space, but leave double new lines
|