跳到正文

Markdown

以保留模式渲染 Markdown,并支持用于流式内容的增量模式。

正在加载交互演示…

#导入

cargo add quickgui --features markdown
use quickgui::Markdown;

#用法

let mut markdown = Markdown::with_text("Build **native** interfaces.");
markdown.element("note").w(290.0)

#API 参考

展开条目查看说明和完整签名。短横线表示声明中未记录默认值。

Markdown

查看源码
pub fn new() -> Self
with_textpub fn with_text(text: &str) -> Self—

Configures with text for this part.

pub fn with_text(text: &str) -> Self
查看源码
textpub fn text(&self) -> &str—

Configures text for this part.

pub fn text(&self) -> &str
查看源码
block_countpub fn block_count(&self) -> usize—

Configures block count for this part.

pub fn block_count(&self) -> usize
查看源码
is_streamingpub const fn is_streaming(&self) -> bool—

Configures is streaming for this part.

pub const fn is_streaming(&self) -> bool
查看源码
is_truncatedpub const fn is_truncated(&self) -> bool—

Configures is truncated for this part.

pub const fn is_truncated(&self) -> bool
查看源码
stylepub const fn style(&self) -> MarkdownStyle—

Configures style for this part.

pub const fn style(&self) -> MarkdownStyle
查看源码
set_stylepub fn set_style(&mut self, style: MarkdownStyle) -> bool—

Configures set style for this part.

pub fn set_style(&mut self, style: MarkdownStyle) -> bool
查看源码
set_streamingpub fn set_streaming(&mut self, streaming: bool) -> bool—

Configures set streaming for this part.

pub fn set_streaming(&mut self, streaming: bool) -> bool
查看源码
set_textpub fn set_text(&mut self, text: &str) -> MarkdownUpdate—

Point the retained document at new controlled source. Append-only changes reuse the settled prefix. Rewrites and link reference definitions fall back to a bounded full parse. Input beyond [`MAX_MARKDOWN_SOURCE_BYTES`] is truncated at a UTF-8 boundary.

pub fn set_text(&mut self, text: &str) -> MarkdownUpdate
查看源码

Markdown::element

查看源码
pub fn element(&mut self, id: impl Into<ElementId>) -> Element

Render the document as ordinary native QuickGUI elements.

Markdown::element_with_code_blocks

查看源码
pub fn element_with_code_blocks<R>( &mut self, id: impl Into<ElementId>, mut renderer: R, ) -> Element where R: for<'source> FnMut(MarkdownCodeBlock<'source>) -> Element,

Render code blocks with a caller-supplied component factory. Parsing remains owned by this retained Markdown model; the callback only replaces the element for each parsed code block. Keep any component state used by the callback in the owning view and key it by [`MarkdownCodeBlock::element_id`].

Markdown::element_with_highlighted_code_blocks

查看源码
pub fn element_with_highlighted_code_blocks( &mut self, id: impl Into<ElementId>, style: CodeBlockStyle, max_height: f32, ) -> Element

Render parsed code blocks through retained [`CodeBlock`] components. This convenience is available when both `markdown` and `editor` are enabled. Each parsed block keeps independent virtual-scroll state. `max_height` is sanitized to a finite value; shorter blocks use their natural logical-line height.