Documentation
¶
Overview ¶
Package render 负责把 Markdown 源码渲染成 HTML 片段并提取标题大纲。 本包是纯计算:不读文件、不访问网络、无全局可变状态。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Heading ¶
type Heading struct {
Level int `json:"level"` // 1..6
Text string `json:"text"` // 纯文本,行内代码等标记已剥离
Anchor string `json:"anchor"` // 与正文中的 id 一致,用于跳转
}
Heading 是正文中的一个标题,用于构建右侧大纲。
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer 持有配置好的 goldmark 实例,可被多个 goroutine 并发复用。
type Result ¶
type Result struct {
Title string `json:"title"` // 首个 H1 的文本;没有 H1 时为空
HTML string `json:"html"` // 正文 HTML 片段,不含 <html>/<body>
Outline []Heading `json:"outline"` // 扁平列表,靠 Level 表达层级
HasMermaid bool `json:"hasMermaid"` // 供前端决定是否懒加载 mermaid
HasMath bool `json:"hasMath"` // 供前端决定是否懒加载 katex
}
Result 是一次渲染的全部产物。
Click to show internal directories.
Click to hide internal directories.