pub struct TextRun<'nodes, 'arena> { /* private fields */ }Expand description
A maximal sequence of adjacent Text nodes in one sibling list.
Runs do not cross formatting nodes. A pass that wants context across emphasis or links must traverse those children in order and maintain its own context; it should still use these runs for matching within each child list. Non-text nodes are left to the caller’s protected-content policy.
Implementations§
Source§impl<'nodes, 'arena> TextRun<'nodes, 'arena>
impl<'nodes, 'arena> TextRun<'nodes, 'arena>
Sourcepub fn node_range(&self) -> Range<usize> ⓘ
pub fn node_range(&self) -> Range<usize> ⓘ
The selected nodes’ range within the sibling slice passed to text_runs.
Sourcepub fn segments(&self) -> impl Iterator<Item = TextSegment<'arena>> + '_
pub fn segments(&self) -> impl Iterator<Item = TextSegment<'arena>> + '_
Returns each text value with the source span of its original node.
Sourcepub fn protected_url_ranges(
&self,
context: &TransformContext<'_>,
) -> Vec<Range<usize>>
pub fn protected_url_ranges( &self, context: &TransformContext<'_>, ) -> Vec<Range<usize>>
Finds protected URL ranges using the renderer options in context.
Each original text segment is scanned independently, then its ranges are offset into the coalesced run. This mirrors HTML rendering, where autolinks do not cross AST text-node boundaries. If URL autolinking is disabled or no prefixes are configured, this returns no ranges.
Sourcepub fn value(&self) -> Cow<'arena, str>
pub fn value(&self) -> Cow<'arena, str>
Returns the coalesced text, borrowing for a one-node run.
Sourcepub fn source_span(&self) -> Span
pub fn source_span(&self) -> Span
Returns the bounding non-empty source span of all text in the run.
Sourcepub fn span_for_bytes(
&self,
range: Range<usize>,
) -> Result<Span, TextReplacementError>
pub fn span_for_bytes( &self, range: Range<usize>, ) -> Result<Span, TextReplacementError>
Returns the bounding source span of text touched by a byte range.
Insertions (empty ranges) map to Span::empty.