Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a26aa7a73b841de6

Jump to content

Module:Get entries from dab

From Wikipedia, the free encyclopedia

-- this module implements [[template:get entries from dab]]
local p = {}

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame)
	local page_name = args[1] or ''
	local page_content = ''
	local entries = {}
	if page_name ~= '' then
		local title = mw.title.new(page_name)
		if title then
			if title.redirectTarget then title = title.redirectTarget end
			page_content = title:getContent()
		end
		page_content = mw.ustring.gsub(page_content, '[\r\n]==*%s*[Ss]ee also.*', '')
		page_content = mw.ustring.gsub(page_content, '([\r\n]%*)([^%s])', '%1 %2')
	end
	local k = 2
	args[2] = (args[2] or '') == '' and '.' or args[2]
	
	while (args[k] or '') ~= '' do
		local pattern = args[k]
		if pattern ~= '.' then
			for s in mw.ustring.gmatch(page_content, '[\r\n]%*[^\r\n]*[%s%[]' .. pattern .. '[%s%|%],][^\r\n]*') do
				table.insert(entries, s)
			end
		else
			for s in mw.ustring.gmatch(page_content, '[\r\n]%*[^\r\n]*') do
				table.insert(entries, s)
			end
		end
		k = k + 1
	end
	return frame:preprocess(table.concat(entries, '\n'))
end

return p