Skip to main content

MarkdownTree

Struct MarkdownTree 

Source
pub struct MarkdownTree { /* private fields */ }
Expand description

Wraps a tree-sitter parser configured for markdown. Supports incremental re-parsing after edits.

Implementations§

Source§

impl MarkdownTree

Source

pub fn new(source: &str) -> Self

Create a new markdown parser and parse the given source.

Source

pub fn source(&self) -> &str

Get the current source text.

Source

pub fn tree(&self) -> Option<&Tree>

Get the current parse tree, if available.

Source

pub fn set_source(&mut self, source: &str)

Replace the entire source and re-parse from scratch.

Source

pub fn edit( &mut self, start_byte: usize, old_end_byte: usize, new_text: &str, start_point: Point, old_end_point: Point, )

Apply an edit and incrementally re-parse.

start_byte / old_end_byte / new_end_byte describe the edit in byte offsets. Points describe the same edit in row/column coordinates.

§Panics

Panics if start_byte or old_end_byte are not on UTF-8 char boundaries.

Source

pub fn sexp(&self) -> Option<String>

Get the S-expression representation of the parse tree (for debugging).

Source

pub fn walk_blocks<F>(&self, visitor: F)
where F: FnMut(BlockInfo),

Walk the top-level blocks of the document, calling the visitor for each.

Source

pub fn block_at_byte(&self, byte_offset: usize) -> Option<BlockInfo>

Find the block node at the given byte offset.

Source

pub fn node_at_byte(&self, byte_offset: usize) -> Option<NodeInfo>

Find the innermost node at the given byte offset.

Auto Trait Implementations§

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