DocumentStructure

Struct DocumentStructure 

Source
pub struct DocumentStructure {
Show 23 fields pub code_blocks: Vec<CodeBlock>, pub has_code_blocks: bool, pub heading_lines: Vec<usize>, pub heading_levels: Vec<usize>, pub heading_regions: Vec<(usize, usize)>, pub list_lines: Vec<usize>, pub has_front_matter: bool, pub front_matter_range: Option<(usize, usize)>, pub has_urls: bool, pub has_html: bool, pub in_code_block: Vec<bool>, pub fenced_code_block_starts: Vec<usize>, pub fenced_code_block_ends: Vec<usize>, pub first_heading_style: Option<HeadingStyle>, pub code_spans: Vec<CodeSpan>, pub in_code_span: Vec<Vec<bool>>, pub links: Vec<Link>, pub images: Vec<Image>, pub list_items: Vec<ListItem>, pub blockquotes: Vec<BlockquoteRange>, pub in_blockquote: Vec<bool>, pub in_html_block: Vec<bool>, pub horizontal_rule_lines: Vec<usize>,
}
Expand description

A struct that contains pre-computed information about a markdown document structure to avoid redundant parsing of the same elements by multiple rules.

Fields§

§code_blocks: Vec<CodeBlock>

Information about code block regions

§has_code_blocks: bool

Whether the document contains code blocks

§heading_lines: Vec<usize>

Line numbers of headings (1-indexed)

§heading_levels: Vec<usize>

Heading levels (1-6) for each heading

§heading_regions: Vec<(usize, usize)>

Heading regions (start_line, end_line) for each heading (ATX: start==end, Setext: start=content, end=marker)

§list_lines: Vec<usize>

Line numbers of list items (1-indexed)

§has_front_matter: bool

Whether the document contains front matter

§front_matter_range: Option<(usize, usize)>

Line range of front matter (1-indexed, inclusive)

§has_urls: bool

Whether the document contains URLs

§has_html: bool

Whether the document contains inline HTML

§in_code_block: Vec<bool>

Bitmap of code block regions for fast lookups

§fenced_code_block_starts: Vec<usize>

Line numbers of fenced code block starts (1-indexed)

§fenced_code_block_ends: Vec<usize>

Line numbers of fenced code block ends (1-indexed)

§first_heading_style: Option<HeadingStyle>

Style of the first heading found in the document (for consistent style rules)

§code_spans: Vec<CodeSpan>

OPTIMIZATION 1: Detailed information about inline code spans

§in_code_span: Vec<Vec<bool>>

OPTIMIZATION 1: Bitmap indicating which line-column positions are within code spans

§links: Vec<Link>

OPTIMIZATION 2: Collection of links in the document

§images: Vec<Image>

OPTIMIZATION 2: Collection of images in the document

§list_items: Vec<ListItem>

OPTIMIZATION 3: Detailed information about list items

§blockquotes: Vec<BlockquoteRange>

OPTIMIZATION 4: Blockquotes in the document

§in_blockquote: Vec<bool>

OPTIMIZATION 4: Bitmap indicating which lines are inside blockquotes

§in_html_block: Vec<bool>

Bitmap indicating which lines are inside HTML blocks

§horizontal_rule_lines: Vec<usize>

Line numbers of horizontal rules (1-indexed)

Implementations§

Source§

impl DocumentStructure

Source

pub fn new(content: &str) -> Self

Create a new DocumentStructure by analyzing the document content

Source

pub fn is_in_code_block(&self, line_num: usize) -> bool

Check if a particular line is inside a code block

Source

pub fn is_in_front_matter(&self, line_num: usize) -> bool

Check if a line is in front matter

Source

pub fn count_trailing_spaces(line: &str) -> usize

Count the number of trailing spaces in a line

This function returns the number of trailing spaces in a line, ignoring newlines but counting spaces before newlines.

Source

pub fn has_trailing_spaces(line: &str) -> bool

Check if a line has trailing whitespace

This function returns true if the line has trailing spaces, false otherwise.

Source

pub fn get_list_start_indices(&self) -> Vec<usize>

Get a list of list start indices This method analyzes the list_lines to find where lists begin

Source

pub fn get_list_end_indices(&self) -> Vec<usize>

Get a list of list end indices This method analyzes the list_lines to find where lists end

Source

pub fn is_in_code_span(&self, line_num: usize, col: usize) -> bool

Check if a position is inside a code span

Source

pub fn is_in_blockquote(&self, line_num: usize) -> bool

Check if a line is inside a blockquote

Source

pub fn get_list_item_at_line(&self, line_num: usize) -> Option<&ListItem>

Get detailed information about a list item at a specific line

Source

pub fn get_list_items_by_type( &self, marker_type: ListMarkerType, ) -> Vec<&ListItem>

Get all list items with a specific marker type

Get all links with empty text or URLs

Source

pub fn get_images_without_alt_text(&self) -> Vec<&Image>

Get all images with empty alt text

Source

pub fn is_in_html_block(&self, line_num: usize) -> bool

Check if a line is inside an HTML block

Trait Implementations§

Source§

impl Clone for DocumentStructure

Source§

fn clone(&self) -> DocumentStructure

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DocumentStructure

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,