Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProcessHTMLWithDiag ¶
func ProcessHTMLWithDiag(ctx context.Context, htmlContent string, baseURL string) (*HTMLResult, *DiagnosticInfo, error)
ProcessHTMLWithDiag 带诊断的 HTML 处理(用于测试)
Types ¶
type DiagnosticInfo ¶
type DiagnosticInfo struct {
ReadabilityOK bool
ReadabilityTitle string
ContentLength int
StructureTags map[string]int // 标签名 → 数量
// 各阶段快照
StagePreCleanLen int // 预清理后 HTML 长度
StageAnchoredLen int // 结构锚定后 HTML 长度
StageExtractSrc string // 提取来源: "readability" | "heuristic"
StageExtractLen int // 提取后内容 HTML 长度
StageConvertLen int // markdown 转换后长度
StageFinalLen int // 最终 markdown 长度
}
DiagnosticInfo 诊断信息(用于测试和调试)
type HTMLResult ¶
HTMLResult HTML 处理结果
func ProcessHTML ¶
ProcessHTML 完整的 HTML → Markdown 管线 管线:预清理 → 结构保护 → readability 提取 → 后处理 → html→md
type Options ¶
type Options struct {
MaxInlineLines int
MaxInlineChars int
MaxContentLength int // 内容超过此长度也写文件,默认 100000
FileOutputDir string
Store StoreWriter
}
Options 内容处理选项
type Output ¶
type Output struct {
Mode string // "inline" | "saved_to_file"
Title string
Markdown string // Mode=inline 时有值
FilePath string // Mode=saved_to_file 时有值
TotalLines int
TotalChars int
Summary string
AgentHint string
StatusCode int
ContType string
}
Output 内容处理输出
type PDFParseError ¶
PDFParseError PDF 解析错误
func (*PDFParseError) Error ¶
func (e *PDFParseError) Error() string
type PDFParseResult ¶
type PDFParseResult struct {
SourcePath string
Title string
PageCount int
Method string
Markdown string
}
PDFParseResult PDF 解析结果(内部)
func ParsePDFBytes ¶
func ParsePDFBytes(ctx context.Context, data []byte, name string, opts PDFOptions) (*PDFParseResult, error)
ParsePDFBytes 解析 PDF 字节流
func ParsePDFFile ¶
func ParsePDFFile(ctx context.Context, filePath string, opts PDFOptions) (*PDFParseResult, error)
ParsePDFFile 解析本地 PDF 文件
type StoreWriter ¶
type StoreWriter interface {
WriteMarkdown(content string, title string, sourceURL string) (filePath string, totalLines int, totalChars int, summary string, err error)
WriteMarkdownFromReader(r io.Reader, title string, sourceURL string) (filePath string, totalLines int, totalChars int, summary string, err error)
}
StoreWriter 文件写入接口(支持 mock)
Click to show internal directories.
Click to hide internal directories.