LintContext

Struct LintContext 

Source
pub struct LintContext<'a> {
    pub content: &'a str,
    pub line_offsets: Vec<usize>,
    pub code_blocks: Vec<(usize, usize)>,
    pub lines: Vec<LineInfo>,
    pub links: Vec<ParsedLink>,
    pub images: Vec<ParsedImage>,
    pub reference_defs: Vec<ReferenceDef>,
    pub list_blocks: Vec<ListBlock>,
    pub char_frequency: CharFrequency,
    pub flavor: MarkdownFlavor,
    /* private fields */
}

Fields§

§content: &'a str§line_offsets: Vec<usize>§code_blocks: Vec<(usize, usize)>§lines: Vec<LineInfo>§links: Vec<ParsedLink>§images: Vec<ParsedImage>§reference_defs: Vec<ReferenceDef>§list_blocks: Vec<ListBlock>§char_frequency: CharFrequency§flavor: MarkdownFlavor

Implementations§

Source§

impl<'a> LintContext<'a>

Source

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

Source

pub fn get_ast(&self) -> Arc<Node>

Get AST - uses global cache for deduplication

Source

pub fn code_spans(&self) -> Arc<Vec<CodeSpan>>

Get code spans - computed lazily on first access

Source

pub fn html_tags(&self) -> Arc<Vec<HtmlTag>>

Get HTML tags - computed lazily on first access

Source

pub fn emphasis_spans(&self) -> Arc<Vec<EmphasisSpan>>

Get emphasis spans - computed lazily on first access

Source

pub fn table_rows(&self) -> Arc<Vec<TableRow>>

Get table rows - computed lazily on first access

Source

pub fn bare_urls(&self) -> Arc<Vec<BareUrl>>

Get bare URLs - computed lazily on first access

Source

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

Map a byte offset to (line, column)

Source

pub fn is_in_code_block_or_span(&self, pos: usize) -> bool

Check if a position is within a code block or code span

Source

pub fn line_info(&self, line_num: usize) -> Option<&LineInfo>

Get line information by line number (1-indexed)

Source

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

Get byte offset for a line number (1-indexed)

Source

pub fn get_reference_url(&self, ref_id: &str) -> Option<&str>

Get URL for a reference link/image by its ID

Get links on a specific line

Source

pub fn images_on_line(&self, line_num: usize) -> Vec<&ParsedImage>

Get images on a specific line

Source

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

Check if a line is part of a list block

Source

pub fn list_block_for_line(&self, line_num: usize) -> Option<&ListBlock>

Get the list block containing a specific line

Source

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

Check if a line is within a code block

Source

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

Check if a line is within front matter

Source

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

Check if a line is within an HTML block

Source

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

Check if a line and column is within a code span

Source

pub fn has_char(&self, ch: char) -> bool

Check if content has any instances of a specific character (fast)

Source

pub fn char_count(&self, ch: char) -> usize

Get count of a specific character (fast)

Source

pub fn likely_has_headings(&self) -> bool

Check if content likely contains headings (fast)

Source

pub fn likely_has_lists(&self) -> bool

Check if content likely contains lists (fast)

Source

pub fn likely_has_emphasis(&self) -> bool

Check if content likely contains emphasis (fast)

Source

pub fn likely_has_tables(&self) -> bool

Check if content likely contains tables (fast)

Source

pub fn likely_has_blockquotes(&self) -> bool

Check if content likely contains blockquotes (fast)

Source

pub fn likely_has_code(&self) -> bool

Check if content likely contains code (fast)

Check if content likely contains links or images (fast)

Source

pub fn likely_has_html(&self) -> bool

Check if content likely contains HTML (fast)

Source

pub fn html_tags_on_line(&self, line_num: usize) -> Vec<HtmlTag>

Get HTML tags on a specific line

Source

pub fn emphasis_spans_on_line(&self, line_num: usize) -> Vec<EmphasisSpan>

Get emphasis spans on a specific line

Source

pub fn table_rows_on_line(&self, line_num: usize) -> Vec<TableRow>

Get table rows on a specific line

Source

pub fn bare_urls_on_line(&self, line_num: usize) -> Vec<BareUrl>

Get bare URLs on a specific line

Auto Trait Implementations§

§

impl<'a> !Freeze for LintContext<'a>

§

impl<'a> RefUnwindSafe for LintContext<'a>

§

impl<'a> Send for LintContext<'a>

§

impl<'a> Sync for LintContext<'a>

§

impl<'a> Unpin for LintContext<'a>

§

impl<'a> UnwindSafe for LintContext<'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> 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, 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,