Module:Ref info
Appearance
-- This module counts the number of times that various reference tags and cs1|2 templates appear.
-- {{#invoke:ref_count|ref_count}}
local p = {}
function p.ref_count(frame)
local text = mw.title.getCurrentTitle():getContent(); -- the content of the current page
local ref_count; -- count of <ref>...</ref> tags
local named_ref_count; -- count of <ref name=...>...</ref> tags
local self_closed_ref_count -- count of <ref name=.../> tags
local cs1_count;
local cs2_count;
local temp;
local temp, ref_count = mw.ustring.gsub(text, '(<ref>.+</ref>', '%1'); -- count unnamed refs
local temp, named_ref_count = mw.ustring.gsub(text, '(<ref%s*name%s*=.+>.+</ref>', '%1'); -- count named refs
local temp, self_closed_ref_count = mw.ustring.gsub(text, '(<ref%s*name%s*=.+/>', '%1'); -- count named refs
return string.format ('unnamed refs = %s\nnamed refs = %s\nself closed = %s', ref_count, named_ref_count, self_closed_ref_count);
end
return p