Skip to main content

MarkdownCache

Struct MarkdownCache 

Source
pub struct MarkdownCache {
    pub blocks: Vec<Block>,
    pub heights: Vec<f32>,
    pub cum_y: Vec<f32>,
    pub total_height: f32,
    pub last_scroll_y: f32,
    /* private fields */
}
Expand description

Cached pre-parsed blocks, height estimates, and the source hash.

Fields§

§blocks: Vec<Block>§heights: Vec<f32>

Estimated pixel height for each top-level block (same len as blocks).

§cum_y: Vec<f32>

Cumulative Y offsets: cum_y[i] = sum of heights[0..i].

§total_height: f32

Total estimated height of all blocks.

§last_scroll_y: f32

Last rendered scroll-y offset (set by show_scrollable).

Implementations§

Source§

impl MarkdownCache

Source

pub fn clear(&mut self)

Invalidate the cache so the next render re-parses.

Source

pub fn ensure_parsed(&mut self, source: &str)

Source

pub fn ensure_heights( &mut self, body_size: f32, wrap_width: f32, style: &MarkdownStyle, )

Source

pub fn heading_y(&self, ordinal: usize) -> Option<f32>

Return the Y offset for the ordinalth non-empty heading block (0-based). Empty headings (no visible text) are skipped so the ordinal aligns with nav_outline::extract_headings which also excludes them.

Uses the pre-cached heading_block_indices for O(1) lookup.

Trait Implementations§

Source§

impl Default for MarkdownCache

Source§

fn default() -> MarkdownCache

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.