API Reference
CyberGo html is a Go library for HTML content extraction. Its API has two entry points: package functions for one-off calls, and Processor instances that reuse the cache and accumulate state. The table below maps each component to its documentation.
| Component | Description | Docs |
|---|---|---|
| Package functions | Convenience functions for one-off calls | Package Functions |
| Processor | Processor instance that reuses resources and cache | Processor |
| Reader mode | Whole-page sectioned view with links preserved (ReadPage*) | Reader Mode |
| Config | Configuration struct and presets | Config |
| Output Formats | Markdown and JSON output | Output Formats |
| Link Extraction | Standalone link extraction API | Link Extraction |
| Batch Processing | Concurrent batch extraction | Batch Processing |
| Interfaces | Extractor, StatsProvider, and others | Interfaces |
| Types | Result, ReadResult, ImageInfo, and others | Type Definitions |
| Constants & Errors | Defaults and sentinel errors | Constants & Errors |
| Security | Content cleaning, input limits, path safety | Security |
| Audit System | Audit pipeline and Sinks | Audit System |
API Overview
Two Calling Modes
text
┌─────────────────────────────────────────┐
│ Package functions (one-off) │
│ html.Extract(data) → *Result, error │
│ Reuses Processor via sync.Pool │
└─────────────────────────────────────────┘
┌─────────────────────────────────────────┐
│ Processor (instance mode) │
│ p, _ := html.New(cfg) │
│ defer p.Close() │
│ result, err := p.Extract(data) │
│ ✓ cache reuse ✓ stats ✓ audit log │
└─────────────────────────────────────────┘Function Naming Rules
| Pattern | Naming | Example |
|---|---|---|
| Base | Extract* | Extract, ExtractText |
| From file | Extract*FromFile | ExtractFromFile |
| With context | Extract*WithContext | ExtractWithContext |
| From file + context | Extract*FromFileWithContext | ExtractFromFileWithContext |
| Reader mode | ReadPage* | ReadPage, ReadPageToMarkdown |
| Reader mode (no links) | ReadPage*Text | ReadPageToMarkdownText |
ReadPage* is a separate family whose naming mirrors Extract*: *FromFile takes a path, WithContext makes the call cancellable, and *ToMarkdown/*ToMarkdownText return a single Markdown document directly.
Module Information
- Module path:
github.com/cybergodev/html - Go version: 1.26+
- Dependencies:
golang.org/x/net,golang.org/x/text
Core Type Quick Reference
| Type | Description | Docs |
|---|---|---|
Result | Extraction result (text, title, metadata, quality signals, media, statistics) | Type Definitions |
ReadResult | Reader-mode result (whole-page sections plus metadata) | Reader Mode |
PageSection | One reader-mode section (kind, text, links, images) | Reader Mode |
Config | Unified config struct and presets | Config |
Processor | Core processing engine with cache and statistics | Processor |
Statistics | Processing statistics (hits, errors, average time) | Type Definitions |
BatchResult | Batch extraction result | Batch Processing |
LinkResource | Link resource with type classification | Link Extraction |
AuditEntry | Audit log entry | Audit System |
Interface Quick Reference
| Interface | Description | Docs |
|---|---|---|
Extractor | Main extraction interface, for decoupling and mocking (excludes ReadPage*) | Interfaces |
StatsProvider | Statistics and cache management interface | Interfaces |
Scorer | Custom content scoring algorithm | Interfaces |
ArticleFinder | Optional: take over article-node selection in one pass | Interfaces |
ContentNode | Node abstraction hiding the internal parser type | Interfaces |
AuditSink | Audit log output target | Interfaces |
Preset Configurations
Start from a preset and override fields; do not hand-write a zero-value config (Config{} fails Validate()):
| Preset | Purpose |
|---|---|
DefaultConfig() | General scenarios, balancing features and performance |
TextOnlyConfig() | No media or link information retained; those extractions are skipped |
MarkdownConfig() | Inline images and links in the body rendered as Markdown |
HighSecurityConfig() | High-security environments: tighter limits, shorter timeouts, audit enabled |
See Config for details.
Find an API by Scenario
| Need | Recommended API | Docs |
|---|---|---|
| Plain text only | ExtractText / Processor.ExtractText | Package Functions |
| Whole-page text for an LLM | ReadPageToMarkdown | Reader Mode |
| Sectioned page view, filtered by the caller | ReadPage + ReadResult.Sections | Reader Mode |
| Markdown output | ExtractToMarkdown or MarkdownConfig() | Output Formats |
| Extract all link resources | ExtractAllLinks | Link Extraction |
| Concurrent batch processing | ExtractBatch / ExtractBatchFiles | Batch Processing |
| Custom article detection | Scorer interface + Config.Scorer (optionally ArticleFinder for single-pass selection) | Interfaces |
| Audit security events | AuditConfig + AuditSink | Audit System |
| High-frequency reuse + cache | html.New() long-lived Processor | Processor |