The getSectionCount method returns the number of sections in a document.
getSectionCount
getSectionCount()
(Number). The number of sections.
local sectionCount = document:getSectionCount()