Skip to main content

Module markdown

Module markdown 

Source
Expand description

Markdown 渲染与 HTML 清理。 Markdown 渲染与目录生成。

使用 pulldown-cmark 解析 Markdown,两遍遍历事件:第一遍收集标题与脚注引用, 第二遍分派输出。标题/TOC 见 heading,脚注见 footnote,围栏代码块见 code_block(Mermaid 图表见 mermaid),图片与表格后处理见 post_process; 最终经 sanitizer 清理 HTML,再把图表占位符换成服务端渲染的 SVG。 仅在 feature = "server" 时执行实际渲染。

Modules§

code_block 🔒
围栏代码块:runnable 标记解析与 <pre><code> 输出(syntect 高亮 / 可运行;mermaid 交给 super::mermaid)。
footnote 🔒
脚注:label → 锚点 id 与引用/定义/回链 HTML 片段。
heading 🔒
标题:层级映射、锚点 slug 与目录(TOC)HTML。
mermaid 🔒
Mermaid 服务端渲染(merman,Mermaid 12.1 的 Rust 实现)。
post_process 🔒
渲染后处理:/uploads/ 图片 blur-up 包裹与表格横向滚动容器。

Structs§

RenderedContent
Markdown 渲染结果。

Functions§

clean_html 🔒
对外暴露的 HTML 清理函数,委托给 sanitizer 模块。
flush_events 🔒
把累积的普通事件交给 pulldown-cmark 默认渲染器输出并清空批次(保留容量)。
render_markdown_enhanced
增强版 Markdown 渲染:生成 TOC、标题锚点与语法高亮代码块。