MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / find_paragraph_break

Function find_paragraph_break

nodedb-query/src/chunk_text.rs:251–263  ·  view source on GitHub ↗

Find the byte position of the next paragraph break (\n\n or \r\n\r\n).

(text: &str)

Source from the content-addressed store, hash-verified

249
250/// Find the byte position of the next paragraph break (\n\n or \r\n\r\n).
251fn find_paragraph_break(text: &str) -> Option<usize> {
252 // Check \r\n\r\n first (longer match).
253 if let Some(pos) = text.find("\r\n\r\n") {
254 let nn_pos = text.find("\n\n");
255 // Return whichever comes first.
256 match nn_pos {
257 Some(nn) if nn < pos => Some(nn),
258 _ => Some(pos),
259 }
260 } else {
261 text.find("\n\n")
262 }
263}
264
265/// Build chunks from pre-split segments, respecting chunk_size and overlap.
266///

Callers 1

split_paragraphsFunction · 0.85

Calls 1

findMethod · 0.45

Tested by

no test coverage detected