Module:Sandbox/Perryprog/sandbox

Revision as of 23:11, 26 February 2021 by imported>Perryprog (Just testing out some Scribunto things.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Sandbox/Perryprog/sandbox/doc

local p = {};

local transcluder = require('Module:Transcluder')

local function referenceCount(referencesText)
	count = 0
	-- Seriously, no string.split method?
	for match in string.gmatch(referencesText, '<ref>') do
    	count = count + 1
	end
	return count
end

function p.main(frame)
	pageReferences = transcluder.get(frame.args[1], { only = 'references' })
	return referenceCount(pageReferences)
end

return p