Module:Peter Bowman/ref

Documentation for this module may be created at Module:Peter Bowman/ref/doc

local p = {
	main = function(frame)
		args = frame:getParent().args
		if not args then return 'no args' end
		
		local patt_ref = '\127UNIQ[^\127]+QINU\127'
		local patt_sep = '[^/]+'
		local patt_short = '<span class="wordshort".*</span>'
		
		local output = {}
		
		for k, arg in pairs(args) do			
			output[#output+1] = "args['" .. k ..  "'] = " .. arg
			--local stripped = mw.text.unstrip(arg)
			--output[#output+1] = "mw.text.unstrip() = " .. stripped
			local cut = (string.gsub(arg, patt_ref, ''))
			output[#output+1] = "string.gsub('" .. arg .. "', patt_ref, '') = " .. cut
			local no_short = (string.gsub(cut, patt_short, ''))
			output[#output+1] = "string.gsub('" .. cut .. "', patt_short, '') = " .. no_short
			
			for w in string.gfind(no_short, patt_sep) do
				output[#output+1] = "string.gfind(" .. cut .. ", patt_sep) = " .. w
			end
		end
		
		return table.concat(output, '\n')
	end}

return p