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.

Jump to content

Module:Sandbox/Andrybak

From Wikipedia, the free encyclopedia
local getArgs = require('Module:Arguments').getArgs

local p = {}

function p.documentationMakeExperimentBlurb(frame)
	local mDoc = require('Module:Documentation')
	local env = mDoc.getEnvironment(getArgs(frame))
	-- without `.. ''` a "2" is appended to the output, weird...
	return mDoc.makeExperimentBlurb({}, env) .. ''
end

local function map(f, tbl)
    local t = {}
    for k,v in pairs(tbl) do
        t[k] = f(v)
    end
    return t
end

function p.rfcShortcutsTest()
	local list = require('Module:List')
	local examples = {
		'WP:RFCXYZ',
		'WP:DFCXYZ',
		'WP:RFC XYZ',
		'WP:RFC ABC',
		'WP:R FCXYZ',
		'WP:RF CXYZ',
		'WP:RfcXYZ',
		'Help:RFCXYZ',
		'Help:R FCXYZ',
		'Help:RfcXYZ',
		'Help:RFCxyz',
		'Help:RFCX',
		'WP:RFC',
		'Help:RFC',
		'WP:PMID',
		'WP:Pmid',
		'WP:PMID XYZ',
		'WP:PMIDABC',
		'Help:PMID',
	}
	local function renderText(s)
		return '<code>' .. s .. ' → ' .. mw.uri.anchorEncode(s) .. '</code>'
	end
	local t = {}
	for i, s in ipairs(examples) do
		local visibleText = renderText(s)
		local span = mw.html.create('span')
		span:attr('id', mw.uri.anchorEncode(s))
		span:wikitext(visibleText .. ' <code>' .. tostring(span:getAttr('id')) .. '</code>')
		t[i] = tostring(span)
	end
	return list.bulleted(t)
end

return p