Skip to main content

split_body_by_sections

Function split_body_by_sections 

Source
pub fn split_body_by_sections(body: &str) -> Vec<String>
Expand description

Splits a large body into sub-memory partitions at Markdown section boundaries (ATX headers), keeping each partition below the byte, chunk and token budgets (GAP-SG-04/07).

A body that already fits a single memory is returned unchanged as a single element. Otherwise the body is cut at ATX header lines, sections are greedily packed into partitions under crate::constants::AUTOSPLIT_PARTITION_MAX_BYTES, and any partition still over budget (e.g. one huge headerless section) is hard-sliced on char boundaries. Concatenating the returned partitions reproduces body exactly (lossless).