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
impl DocumentStructure
Sourcepub fn new(content: &str) -> Self
pub fn new(content: &str) -> Self
Create a new DocumentStructure by analyzing the document content
Sourcepub fn is_in_code_block(&self, line_num: usize) -> bool
pub fn is_in_code_block(&self, line_num: usize) -> bool
Check if a particular line is inside a code block
Sourcepub fn is_in_front_matter(&self, line_num: usize) -> bool
pub fn is_in_front_matter(&self, line_num: usize) -> bool
Check if a line is in front matter
Sourcepub fn count_trailing_spaces(line: &str) -> usize
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.
Sourcepub fn has_trailing_spaces(line: &str) -> bool
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.
Sourcepub fn get_list_start_indices(&self) -> Vec<usize>
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
Sourcepub fn get_list_end_indices(&self) -> Vec<usize>
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
Sourcepub fn is_in_code_span(&self, line_num: usize, col: usize) -> bool
pub fn is_in_code_span(&self, line_num: usize, col: usize) -> bool
Check if a position is inside a code span
Sourcepub fn is_in_blockquote(&self, line_num: usize) -> bool
pub fn is_in_blockquote(&self, line_num: usize) -> bool
Check if a line is inside a blockquote
Sourcepub fn get_list_item_at_line(&self, line_num: usize) -> Option<&ListItem>
pub fn get_list_item_at_line(&self, line_num: usize) -> Option<&ListItem>
Get detailed information about a list item at a specific line
Sourcepub fn get_list_items_by_type(
&self,
marker_type: ListMarkerType,
) -> Vec<&ListItem>
pub fn get_list_items_by_type( &self, marker_type: ListMarkerType, ) -> Vec<&ListItem>
Get all list items with a specific marker type
Sourcepub fn get_empty_links(&self) -> Vec<&Link>
pub fn get_empty_links(&self) -> Vec<&Link>
Get all links with empty text or URLs
Sourcepub fn get_images_without_alt_text(&self) -> Vec<&Image>
pub fn get_images_without_alt_text(&self) -> Vec<&Image>
Get all images with empty alt text
Sourcepub fn is_in_html_block(&self, line_num: usize) -> bool
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
impl Clone for DocumentStructure
Source§fn clone(&self) -> DocumentStructure
fn clone(&self) -> DocumentStructure
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for DocumentStructure
impl RefUnwindSafe for DocumentStructure
impl Send for DocumentStructure
impl Sync for DocumentStructure
impl Unpin for DocumentStructure
impl UnwindSafe for DocumentStructure
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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