Skip to main content

MarkdownParser

Struct MarkdownParser 

Source
pub struct MarkdownParser<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> MarkdownParser<'a>

Source

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

Source

pub fn content(&self) -> &'a str

Source

pub fn lines(&self) -> &[&'a str]

Source

pub fn line_count(&self) -> usize

Source

pub fn get_line(&self, line_num: usize) -> Option<&'a str>

Source

pub fn parse(&self) -> impl Iterator<Item = Event<'a>> + 'a

Source

pub fn parse_with_offsets( &self, ) -> impl Iterator<Item = (Event<'a>, Range<usize>)>

Source

pub fn offset_to_line(&self, offset: usize) -> usize

Source

pub fn offset_to_position(&self, offset: usize) -> (usize, usize)

Source

pub fn get_code_line_numbers(&self) -> HashSet<usize>

Returns a set of line numbers that are inside code blocks or inline code. This is useful for rules that should ignore code content.

Note: For inline code, this marks the entire line as code. For more precise detection, use get_code_ranges() instead.

Source

pub fn get_code_block_line_numbers(&self) -> HashSet<usize>

Returns a set of line numbers that are inside code BLOCKS only (not inline code). This is useful for rules that need to check list markers, URLs, etc. that might legitimately appear on lines with inline code. Lines are 1-indexed to match violation reporting.

Source

pub fn get_code_ranges(&self) -> Vec<Range<usize>>

Returns a vector of byte ranges that are inside code (blocks or inline). This is more precise than get_code_line_numbers() for inline code.

Source

pub fn line_offset_to_absolute( &self, line_num: usize, byte_offset_in_line: usize, ) -> usize

Converts a byte offset within a line to an absolute byte offset in the content. line_num is 1-indexed, byte_offset_in_line is 0-indexed from start of line.

Source

pub fn is_heading(&self, event: &Event<'_>) -> bool

Source

pub fn is_code_block(&self, event: &Event<'_>) -> bool

Source

pub fn is_list(&self, event: &Event<'_>) -> bool

Auto Trait Implementations§

§

impl<'a> Freeze for MarkdownParser<'a>

§

impl<'a> RefUnwindSafe for MarkdownParser<'a>

§

impl<'a> Send for MarkdownParser<'a>

§

impl<'a> Sync for MarkdownParser<'a>

§

impl<'a> Unpin for MarkdownParser<'a>

§

impl<'a> UnsafeUnpin for MarkdownParser<'a>

§

impl<'a> UnwindSafe for MarkdownParser<'a>

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> 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, 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.