pub fn paragraph_ranges(text: &str) -> impl Iterator<Item = Range<usize>> + '_Expand description
Returns the byte ranges of the source text’s logical paragraphs.
This splits the original string on line-ending boundaries (\n, \r\n, or \r)
and yields the content ranges between those separators. The returned ranges do not
include the line-ending bytes themselves.
This is a source-text helper, not a layout helper:
- use this when you need width-independent paragraph/logical-line ranges from the raw text buffer
- do not use this when you need wrapped or shaped visual lines from Parley layout
In other words, this answers “how is the input text structurally split?” rather than “how did the text lay out on screen?”.
Typical uses:
- editor/document logic that works in terms of source paragraphs
- fallback handling for single-paragraph text
- debug or inspection code that wants the original paragraph segmentation
Prefer TextLayout/Parley queries when you care about:
- wrapping
- alignment
- hit testing
- visual line geometry