Skip to main content

compute_markdown_folds

Function compute_markdown_folds 

Source
pub fn compute_markdown_folds(buffer: &Buffer) -> Vec<Fold>
Expand description

Markdown heading-based fold provider (DESIGN.md §15:18, docs/user/folding.md). Walks the buffer for ATX headings (^#+\s) and emits one fold per heading whose body has at least one row. Heading depth (the number of #s) determines nesting: a ## H2 ends at the next same-or-shallower heading (# H1 or another ## H2 or end-of-buffer).

Code-fence aware: ^```` lines toggle a "in fenced block" state; #`-prefixed lines inside a fenced block are not headings. The fence itself is included in whichever fold contains it.

Lines inside fenced code blocks of the form ~~~ are also excluded from heading detection, mirroring CommonMark §4.5.