Skip to main content

MarkdownPlugin

Trait MarkdownPlugin 

Source
pub trait MarkdownPlugin:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &str;
    fn parse(
        &self,
        node: &Node,
        cx: &MarkdownParseContext<'_>,
    ) -> Option<MarkdownNode>;

    // Provided methods
    fn is_block(&self) -> bool { ... }
    fn render(
        &self,
        node: &MarkdownNode,
        _window: &mut Window,
        _cx: &mut App,
    ) -> impl IntoElement { ... }
    fn render_inline(
        &self,
        node: &MarkdownNode,
        _context: &InlineRenderContext,
        window: &mut Window,
        cx: &mut App,
    ) -> Option<InlineElement> { ... }
}
Expand description

A reusable Markdown extension that parses and renders one custom node.

Required Methods§

Source

fn name(&self) -> &str

Stable name for nodes produced by this plugin.

Source

fn parse( &self, node: &Node, cx: &MarkdownParseContext<'_>, ) -> Option<MarkdownNode>

Convert an mdast node into a custom Markdown node.

Provided Methods§

Source

fn is_block(&self) -> bool

Whether this plugin produces block-level nodes.

Plugins are inline by default. Block plugins should return true.

Source

fn render( &self, node: &MarkdownNode, _window: &mut Window, _cx: &mut App, ) -> impl IntoElement

Render a custom Markdown node produced by this plugin.

Source

fn render_inline( &self, node: &MarkdownNode, _context: &InlineRenderContext, window: &mut Window, cx: &mut App, ) -> Option<InlineElement>

Render an inline node using the existing render implementation. Override this only when inherited layout context or an explicit baseline is needed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§