Module:MultiReplace/sandbox: Difference between revisions

Content deleted Content added
create
 
add unstrip option
 
(7 intermediate revisions by the same user not shown)
Line 1:
p = {}
 
local function p._mainMultiReplace(frameargs)
local args = frame:getParent().args
local input = args[1] or "{{{1}}}"
if args.unstrip == "yes" then input = mw.text.unstrip(input) end
local plain = args.plain == "yes"
 
Line 11 ⟶ 12:
local change = {pattern = args[i * 2], repl = args[i * 2 + 1]}
if not change.repl then
local err =return require('Module:Error').error{
return err.error( 'MultireplaceMultiReplace: Unpaired argument: <code>' .. (i * 2) .. ' = ' .. change.pattern .. '</code>')
}
end
changeList[i] = change
Line 45 ⟶ 47:
end
 
function p.main(frame, ...)
local args =
return _main(frame)
type(frame) ~= 'table' and {frame, ...} or
type(frame.args) ~= 'table' and frame or
frame.args[1] and frame.args or
local args = frame:getParent().args
return MultiReplace(args)
end