FANDOM


-- Table constructor
 
local p = {}
 
local function rowPositions(wikitable)
    local positions = {}
    local index = 1
 
    for pos = 1, string.len(wikitable) - 1 do
        if string.sub(wikitable, pos, pos + 1) == "|-" then
            positions[index] = pos
            index = index + 1
        end
    end
 
    positions[index] = string.len(wikitable) - 1
 
    return positions
end
 
function p.partial(frame)
    local wikitable = frame.args[1]
    local rows = table.getn(rowPositions(wikitable)) - 1
    local firstRow = math.max(frame.args[2], 1) or 1
    local lastRow = math.min(frame.args[3], rows) or rows
    local header = string.sub(wikitable, 1, rowPositions[1] - 1)
    local body = string.sub(
        wikitable, rowPositions[firstRow], rowPositions[lastRow + 1]
        )
    return header .. body .. "}"
end
 
return p
 
--[[Category:Modules]]
Community content is available under CC-BY-SA unless otherwise noted.