Toggle menu
9
205
64
18.8K
Kenshi Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
Revision as of 23:21, 19 February 2025 by Prd (talk | contribs) (Created page with "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\" st...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Subpages:

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