Skip to main content

TextRun

Struct TextRun 

Source
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>

Source

pub fn node_range(&self) -> Range<usize> ⓘ

The selected nodes’ range within the sibling slice passed to text_runs.

Source

pub fn segments(&self) -> impl Iterator<Item = TextSegment<'arena>> + '_

Returns each text value with the source span of its original node.

Source

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.

Source

pub fn value(&self) -> Cow<'arena, str>

Returns the coalesced text, borrowing for a one-node run.

Source

pub fn source_span(&self) -> Span

Returns the bounding non-empty source span of all text in the run.

Source

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.

Auto Trait Implementations§

§

impl<'nodes, 'arena> !RefUnwindSafe for TextRun<'nodes, 'arena>

§

impl<'nodes, 'arena> !Send for TextRun<'nodes, 'arena>

§

impl<'nodes, 'arena> !Sync for TextRun<'nodes, 'arena>

§

impl<'nodes, 'arena> !UnwindSafe for TextRun<'nodes, 'arena>

§

impl<'nodes, 'arena> Forget for TextRun<'nodes, 'arena>

§

impl<'nodes, 'arena> Freeze for TextRun<'nodes, 'arena>

§

impl<'nodes, 'arena> Move for TextRun<'nodes, 'arena>

§

impl<'nodes, 'arena> Unpin for TextRun<'nodes, 'arena>

§

impl<'nodes, 'arena> UnsafeUnpin for TextRun<'nodes, 'arena>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.