Lompat ke isi

Modul:Get short description

Ḍâri Wikipèḍia bhâsa Madhurâ, lombhung pangataowan mardhika
Rèvisi sajjhek 5 Oktober 2024 19.49 bi' Munajad.MH (kanḍhâ | dhurrun) (←Membuat halaman berisi '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 search...')
(bhidhâ) ← Rèvisi sabelluna | Rèvisi jângkènè (bhidhâ) | Rèvisi lebbi anyar → (bhidhâ)

Implements {{get short description}}.



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