pub struct Document {
pub content: String,
pub path: PathBuf,
pub lines: Vec<String>,
}Expand description
Represents a parsed markdown document with position information
Fields§
§content: StringThe original markdown content
path: PathBufPath to the source file
lines: Vec<String>Lines split for line-based rule processing
Implementations§
Source§impl Document
impl Document
Sourcepub fn new(content: String, path: PathBuf) -> Result<Self>
pub fn new(content: String, path: PathBuf) -> Result<Self>
Parse a markdown document from content and path
Sourcepub fn parse_ast<'a>(&self, arena: &'a Arena<AstNode<'a>>) -> &'a AstNode<'a>
pub fn parse_ast<'a>(&self, arena: &'a Arena<AstNode<'a>>) -> &'a AstNode<'a>
Parse the content into a comrak AST
Sourcepub fn parse_ast_with_context<'a>(
&self,
arena: &'a Arena<AstNode<'a>>,
) -> Result<&'a AstNode<'a>>
pub fn parse_ast_with_context<'a>( &self, arena: &'a Arena<AstNode<'a>>, ) -> Result<&'a AstNode<'a>>
Parse AST with error context
Sourcepub fn line_number_at_offset(&self, offset: usize) -> usize
pub fn line_number_at_offset(&self, offset: usize) -> usize
Get the line number (1-based) for a given byte offset
Sourcepub fn column_number_at_offset(&self, offset: usize) -> usize
pub fn column_number_at_offset(&self, offset: usize) -> usize
Get the column number (1-based) for a given byte offset
Sourcepub fn headings<'a>(&self, ast: &'a AstNode<'a>) -> Vec<&'a AstNode<'a>> ⓘ
pub fn headings<'a>(&self, ast: &'a AstNode<'a>) -> Vec<&'a AstNode<'a>> ⓘ
Get all heading nodes from the AST
Sourcepub fn headings_with_context<'a>(
&self,
ast: &'a AstNode<'a>,
) -> Result<Vec<&'a AstNode<'a>>>
pub fn headings_with_context<'a>( &self, ast: &'a AstNode<'a>, ) -> Result<Vec<&'a AstNode<'a>>>
Get all heading nodes with error context
Sourcepub fn code_blocks<'a>(&self, ast: &'a AstNode<'a>) -> Vec<&'a AstNode<'a>> ⓘ
pub fn code_blocks<'a>(&self, ast: &'a AstNode<'a>) -> Vec<&'a AstNode<'a>> ⓘ
Get all code block nodes from the AST
Sourcepub fn code_blocks_with_context<'a>(
&self,
ast: &'a AstNode<'a>,
) -> Result<Vec<&'a AstNode<'a>>>
pub fn code_blocks_with_context<'a>( &self, ast: &'a AstNode<'a>, ) -> Result<Vec<&'a AstNode<'a>>>
Get all code block nodes with error context
Sourcepub fn heading_level<'a>(node: &'a AstNode<'a>) -> Option<u32>
pub fn heading_level<'a>(node: &'a AstNode<'a>) -> Option<u32>
Get the heading level for a heading node
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnwindSafe for Document
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
Mutably borrows from an owned value. Read more