Module:CiteConversionTest
Appearance
c = {}
function c.test( frame )
local target = frame.args[1] or frame.args.target;
local tt = mw.title.new( target );
local content = tt:getContent();
local result = '';
local template;
local i = 1;
for template in string.gmatch( content, '%b{}' ) do
local mode, param;
mode, param = string.match( template, '{{%s*cite (%w*)%s*|([^}]*)}}' );
if mode ~= nil and mode ~= 'quick' then
result = result .. '\n{{cite compare|mode=' .. mode .. " | " .. param .. "}}\n";
i = i + 1;
end
mode, param = string.match( template, '{{%s*cite quick%s*|%s*(%w*)%s*|([^}]*)}}' );
if mode ~= nil then
result = result .. '\n{{cite compare|mode=' .. mode .. " | " .. param .. "}}\n";
i = i + 1;
end
if i > 90 then break; end --prevent time outs
end
return frame:preprocess(result);
end
function c.gather( frame )
local typ = frame.args[1] or frame.args.mode;
local start = frame.args[2] or frame.args.start;
local tt = mw.title.new( start );
local content = tt:getContent();
targets = {};
for w in string.gmatch( content, '%[%[(%w-)%]%]' ) do
targets[w] = true;
end
local result = '';
local cnt = 0;
for k in pairs( targets ) do
local tt = mw.title.new( k );
cnt = cnt + 1;
if cnt > 50 then break; end
if tt ~= nil then
local content = tt:getContent();
local template;
local i = 1;
result = result .. string.len( content ) .. ' ';
for template in string.gmatch( content, '%b{}' ) do
local param;
param = string.match( template, '{{%s*cite ' .. typ .. '%s*|([^}]*)}}' );
if param ~= nil then
result = result .. '\n{{cite compare|mode=' .. typ .. " | " .. param .. "}}\n";
i = i + 1;
end
param = string.match( template, '{{%s*cite quick%s*|%s*' .. typ .. '%s*|([^}]*)}}' );
if param ~= nil then
result = result .. '\n{{cite compare|mode=' .. typ .. " | " .. param .. "}}\n";
i = i + 1;
end
end
end
end
return result;
end
return c;