Documentation
¶
Overview ¶
Package layout 把与版式无关的流式文档模型排版为 OFD 固定版式页面。
Markdown、DOCX 等流式格式的导入器只负责把源格式解析为 Document, 断行、分页、字体选择和 OFD 生成由本包统一处理。当前实现以 Markdown 常见元素(段落、标题、列表、引用、代码、表格、图片)为范围。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Block ¶
type Block struct {
Kind Kind
// Level 是标题级别 1-6。
Level int
// Marker 是列表标记,如 "•" 或 "1."。
Marker string
// Indent 是缩进层级,用于列表和引用。
Indent int
// Inlines 是行内内容。
Inlines []Inline
// Code 是代码块纯文本。
Code string
// Image 是块级图片。
Image *Image
// Table 是表格。
Table *Table
}
Block 是块级元素。
type Image ¶
type Image struct {
// Source 是原始地址,用于诊断信息。
Source string
// Alt 是替代文本。
Alt string
// Data 是图片二进制数据。
Data []byte
// Format 是图片格式,如 PNG、JPEG。
Format string
// PixelWidth 和 PixelHeight 是图片像素尺寸。
PixelWidth int
PixelHeight int
}
Image 是块级图片。
type Options ¶
type Options struct {
// PageWidth 和 PageHeight 是页面物理尺寸。
PageWidth float64
PageHeight float64
// MarginTop、MarginRight、MarginBottom、MarginLeft 是页边距。
MarginTop float64
MarginRight float64
MarginBottom float64
MarginLeft float64
// BodySize 是正文字号,MonoSize 是代码字号。
BodySize float64
MonoSize float64
// LineHeight 是行高倍率。
LineHeight float64
// CodeLineHeight 是代码块的行高倍率;小于 LineHeight 可以让代码更紧凑。
CodeLineHeight float64
// BlockSpacing 是块间距,单位为正文行高的倍率。
BlockSpacing float64
// BodyFamily 和 MonoFamily 是逻辑字体族名。
BodyFamily string
MonoFamily string
}
Options 控制页面尺寸、字体与间距。长度单位为毫米,字号单位为磅。
Click to show internal directories.
Click to hide internal directories.