Content deleted Content added
Petr Matas (talk | contribs) ←Created page with 'p = {} function p.main(frame) local args = frame:getParent().args local input = args[1] local plain = args.plain == "yes" local i = 1 local changeList = {...' |
Per edit request |
||
(24 intermediate revisions by 3 users not shown) | |||
Line 1:
local p = {}
local function
local
local input = args[1]▼
local plain = args.plain == "yes"
Line 11 ⟶ 10:
local change = {pattern = args[i * 2], repl = args[i * 2 + 1]}
if not change.repl then
return
▲ args = { 'Multireplace: Unpaired argument: <code>' + (i * 2 - 1) + ' = ' + change.repl + '</code>' }
}
end
changeList[i] = change
i = i + 1
end
Line 29 ⟶ 28:
for _, change in ipairs(changeList) do
local start, stop = mw.ustring.find(input, change.pattern, pos, plain)
if start and (start < bestStart) then
bestStart = start
bestStop = stop
Line 35 ⟶ 34:
end
end
result = result
if
local fragment = mw.ustring.sub(input, bestStart, bestStop)
result = result
mw.ustring.gsub(fragment, end
pos = bestStop + 1
end
return result
end
function p.main(frame, ...)
type(frame) ~= 'table' and {frame, ...} or
type(frame.args) ~= 'table' and frame or
frame.args[1] and frame.args or
frame:getParent().args
return MultiReplace(args)
end
|