Module:sandbox2

local export = {}

function getFullPage local pageObject = mw.title.new("dog") return pageObject:getContent end

function export.show

local fullPage = getFullPage

local levelTwoHeadingCount = 0 local levelTwoHeadings = {}

for line, newlines in fullPage:gmatch('([^\n]*)(\n*)') do		local m = line:match('^== *%f[^ =](.*)%f[ =] *==$') if m then levelTwoHeadingCount = levelTwoHeadingCount + 1 levelTwoHeadings[levelTwoHeadingCount] = {title = m, length = newlines:len} elseif levelTwoHeadingCount > 0 then levelTwoHeadings[levelTwoHeadingCount].length = levelTwoHeadings[levelTwoHeadingCount].length + line:len + newlines:len end end fullPage = nil

return levelTwoHeadings[levelTwoHeadingCount-2].title

end

return export