Completes processing of the input and returns the parsed document.
pub fn endInput(p: *Parser) Allocator.Error!Document
pub fn endInput(p: *Parser) Allocator.Error!Document {
while (p.pending_blocks.items.len > 0) {
try p.closeLastBlock();
}
// There should be no inline content pending after closing the last open
// block.
assert(p.scratch_string.items.len == 0);
const children = try p.addExtraChildren(@ptrCast(p.scratch_extra.items));
p.nodes.items(.data)[0] = .{ .container = .{ .children = children } };
p.scratch_string.items.len = 0;
p.scratch_extra.items.len = 0;
try p.extra.shrinkToLen(p.allocator);
try p.string_bytes.shrinkToLen(p.allocator);
return .{
.nodes = p.nodes.toOwnedSlice(),
.extra = p.extra.toOwnedSliceAssert(),
.string_bytes = p.string_bytes.toOwnedSliceAssert(),
};
}