pub struct MarkdownExtensions { /* private fields */ }Expand description
Registry for custom Markdown parsing and rendering.
Implementations§
Source§impl MarkdownExtensions
impl MarkdownExtensions
Sourcepub fn parser_revision(self, revision: u64) -> Self
pub fn parser_revision(self, revision: u64) -> Self
Change this revision when parser captures or plugin configuration change. Reusing it allows equivalent registrations rebuilt during rendering to retain the parsed document. Renderer-only changes do not need a new value.
Sourcepub fn frontmatter(self) -> Self
pub fn frontmatter(self) -> Self
Enable YAML frontmatter parsing.
Frontmatter is disabled by default because it is not part of CommonMark
or GFM. Register a block parser or MarkdownPlugin to render the
resulting mdast::Node::Yaml node.
Sourcepub fn mdx(self) -> Self
pub fn mdx(self) -> Self
Enable MDX JSX/expression constructs.
This disables raw HTML constructs because markdown-rs gives HTML
priority over MDX when both are enabled.
Sourcepub fn block_parser<F>(self, parser: F) -> Selfwhere
F: for<'a> Fn(&Node, &MarkdownParseContext<'a>) -> Option<MarkdownNode> + Send + Sync + 'static,
pub fn block_parser<F>(self, parser: F) -> Selfwhere
F: for<'a> Fn(&Node, &MarkdownParseContext<'a>) -> Option<MarkdownNode> + Send + Sync + 'static,
Register a parser for block-level Markdown AST nodes.
Sourcepub fn block_renderer<F, E>(
self,
name: impl Into<SharedString>,
renderer: F,
) -> Self
pub fn block_renderer<F, E>( self, name: impl Into<SharedString>, renderer: F, ) -> Self
Register a renderer for a custom block node name.
Sourcepub fn block_surface<F>(self, name: impl Into<SharedString>, render: F) -> Self
pub fn block_surface<F>(self, name: impl Into<SharedString>, render: F) -> Self
Draw a top-level blockquote that opens with the marker [!name] inside
a container.
> [!summary]
> Blocks of any kind, as many as you like.
>
> - They stay part of the document.This is the syntax of GitHub alerts, with names of your own, and other
renderers show it as a blockquote. Names match ASCII-case-insensitively,
so [!NOTE] opens a surface registered as note. The marker is alone on
the first line, and is not document text; the lines after it are the
first paragraph.
render runs each time the document renders and returns the container
with its background, shape, padding and text style, and any children to
show before the blocks, such as an icon and a title. The blocks are
appended to it and bring the view’s paragraph gap, so a gap on the
container adds to that. Read theme colors in render, so a theme change
needs no new parse. What the container shows itself is not document text.
Unless the container sets a width, it takes the row’s.
The blocks remain the document’s: selection, range highlights and
reveals go across and inside the container, and
rendered_text has them without
the marker. A select-all copies the source verbatim. A partial source
copy is quoted under the marker line, as a blockquote’s is quoted.
Only a blockquote at the top level of a Markdown view, with a registered
name, is a surface. A nested one stays a blockquote, and so does one with
text after the marker on its line, such as Obsidian’s > [!note] Title:
the container shows its own title. Surfaces do not nest. The marker is
markup, so escape text you don’t control, as with any other Markdown.
A surface is one row of a scrollable view, so keep it to what fits a few screens. While it is the last block of a streaming view, each append parses and measures all of it again, so streaming one costs time quadratic in its length. Until its marker line is complete, it shows as a blockquote.
Sourcepub fn plugin<P>(self, plugin: P) -> Selfwhere
P: MarkdownPlugin,
pub fn plugin<P>(self, plugin: P) -> Selfwhere
P: MarkdownPlugin,
Apply a reusable Markdown plugin.
Trait Implementations§
Source§impl Clone for MarkdownExtensions
impl Clone for MarkdownExtensions
Auto Trait Implementations§
impl !RefUnwindSafe for MarkdownExtensions
impl !UnwindSafe for MarkdownExtensions
impl Forget for MarkdownExtensions
impl Freeze for MarkdownExtensions
impl Send for MarkdownExtensions
impl Sync for MarkdownExtensions
impl Unpin for MarkdownExtensions
impl UnsafeUnpin for MarkdownExtensions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().