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: a21e21a0784715db

Jump to content

Module:Get short description

From Wikipedia, the free encyclopedia

local p = {}

local function getContent(title)
	local success, titleObj = pcall(mw.title.new, title)
	if not success then return nil end
	return titleObj:getContent()
end

function p.main(frame, title)
	local title = frame.args[1]
    local wikitext = getContent(title)
	if wikitext == nil then return "" end
	wikitext = frame:preprocess(wikitext)
    local startIndex, endIndex = string.find(wikitext, "<div class=\"shortdescription nomobile noexcerpt noprint searchaux\" style=\"display:none\">")
    if startIndex == nil then
        return nil
    end
    local descriptionStart = endIndex + 1
    local descriptionEnd = string.find(wikitext, "</div>", descriptionStart)
    if descriptionEnd == nil then
        return nil
    end
    return string.sub(wikitext, descriptionStart, descriptionEnd - 1)
end

return p