Paragraph-first chunker with blank logical line → logical line → hardcut
fallback. The canonical line authority treats LF, CRLF, CR, U+2028, and
U+2029 as terminators. Returned chunk text is always an exact source slice
or exact concatenation across the source's own unchanged terminators; no
newline spelling is synthesized. Each chunk carries 1-based line offsets so
callers can quote precise locations.
v2.1.0: also attaches a heading breadcrumb to each chunk (the H1>H2>H3
path in effect at chunk start). Preserves Obsidian markdown structure
for downstream retrievers without a custom parser. ATX headings only —
fenced code blocks (where # is shell prompt, not heading) are skipped.
Parameters
content: string
Markdown content to split.
maxChars: number = MAX_CHUNK_CHARS
Positive safe-integer UTF-16-unit target per chunk.
Returns ContentChunk[]
Non-empty chunks with source-line and breadcrumb metadata.
Paragraph-first chunker with
blank logical line → logical line → hardcutfallback. The canonical line authority treats LF, CRLF, CR, U+2028, and U+2029 as terminators. Returned chunk text is always an exact source slice or exact concatenation across the source's own unchanged terminators; no newline spelling is synthesized. Each chunk carries 1-based line offsets so callers can quote precise locations.v2.1.0: also attaches a heading breadcrumb to each chunk (the H1>H2>H3 path in effect at chunk start). Preserves Obsidian markdown structure for downstream retrievers without a custom parser. ATX headings only — fenced code blocks (where
#is shell prompt, not heading) are skipped.