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>)>

Like parse_with_offsets, but resolves otherwise-broken reference links (undefined labels) by flagging their LinkType as the corresponding *Unknown variant instead of silently dropping the event as plain text. Used by rules that need to detect undefined reference links/images.

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 the 1-indexed line numbers inside code blocks or inline code. Result is precomputed in new() — O(1) to access.

Source

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

Returns the 1-indexed line numbers inside code blocks only (not inline spans). Result is precomputed in new() — O(1) to access.

Source

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

Returns byte ranges (into the original content) for all code blocks and inline code spans. Result is precomputed in new() — O(1) to access.

Source

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

Returns the 1-indexed line numbers that form link reference definitions ([label]: url). Result is precomputed in new() — O(1) to access.

Source

pub fn get_ref_defs(&self) -> &HashMap<String, usize>

Returns a map of normalised (lowercase) label → 1-indexed line number for every link reference definition in the document.

Source

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

Converts a (1-indexed) line number and 0-indexed byte offset within that line to an absolute byte offset in the content.

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.