Jump to content

Module:Find sources/autodoc

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mr. Stradivarius (talk | contribs) at 13:45, 26 September 2014 (write a function to get all page names with a certain prefix, to avoid making users manually add new template config pagenames and link config pagenames to some data module). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

local p = {}

function p.getPrefixPagenames(prefix)
	local specialText = string.format('{{Special:PrefixIndex/%s}}', prefix)
	specialText = mw.getCurrentFrame():preprocess(specialText)
	specialText = mw.text.unstrip(specialText)
	local pagenames = {}
	for s in string.gmatch(specialText, '<a href="[^"]*" title="([^"]*)"[^>]*>[^<]*</a>') do
		pagenames[#pagenames + 1] = mw.text.decode(s)
	end
	return pagenames
end

return p