Skip to content

MarkdownRenderer

MarkdownRenderer 负责 markdown 叙事层渲染。

它适合:

  • 静态 markdown
  • 一次性生成结果
  • 长文阅读
  • 不需要 runtime 的展示页

最小用法

vue
<MarkdownRenderer :source="source" />

主要 props

Prop类型默认值说明
sourcestring必填当前 markdown 内容
lineHeightnumber26文本行高
fontstring内置默认字体pretext 文本布局用的字体描述
thoughtTitlestring'Thought Process':::thought 默认标题
allowUnsafeHtmlbooleanfalse是否允许不安全 HTML
aguiComponentsAguiComponentMap{}:::vue-component 可用组件表
builtinComponentsMarkdownBuiltinComponentOverrides{}覆写内置 markdown block 组件
pluginsMarkdownEnginePlugin[][]额外 markdown-it 插件
performanceMarkdownRendererPerformanceOptions{}长文和窗口化性能配置

performance

最常用的几个字段:

字段说明
textSlabChars把超长文本块切成更小片段
virtualize是否开启长文窗口化
virtualizeMargin视口上下预热范围

@telemetry

MarkdownRenderer 会发出 telemetry 事件。

vue
<MarkdownRenderer
  :source="source"
  @telemetry="snapshot => {
    console.log(snapshot.mountedBlockCount);
  }"
/>

你最常看的字段通常是:

  • parsedBlockCount
  • renderableBlockCount
  • mountedBlockCount
  • virtualized
  • viewportSyncPasses

默认支持的 block

  • text
  • html
  • code
  • mermaid
  • math
  • thought
  • agui
  • artifact
  • approval
  • handoff

如果要换外观,优先改 builtinComponents

Released under the MIT License.