Documentation
¶
Overview ¶
Package docformat turns a fetched non-HTML document into Markdown by choosing the right formatter for it: vCard, iCalendar, RSS/Atom, JSON (record arrays, Jupyter notebooks, OpenAPI specs, generic documents), CSV/TSV, Git patches and source files.
The formatters live in internal/extract; this package owns the choice between them, so every caller picks the same formatter for the same body. The order and the checks follow the Cloudflare hub's scrape path (hub/src/scrape.ts), which the hub parity test (cmd/edgefetch/hub_parity_test.go) holds the node to until the hub stops processing pages (docs/HUB-NODE-PROCESSING-PLAN.md).
Index ¶
Constants ¶
const ( KindVCard = "vcard" KindICalendar = "icalendar" KindFeed = "feed" KindJSONRecords = "json-records" KindJSON = "json" KindCSV = "csv" KindPatch = "patch" KindSource = "source" )
Kinds of document Render recognizes.
Variables ¶
This section is empty.
Functions ¶
func LooksLikeHTML ¶
LooksLikeHTML reports whether a body goes to the HTML extractor rather than to Render.
Types ¶
type Doc ¶
type Doc struct {
Kind string
Title string
Description string
Markdown string
// Links are the item links of a feed.
Links []string
// Records is set for KindJSONRecords.
Records *jobs.ChunkedJSONRecordsResult
}
Doc is a formatted document.
type Input ¶
type Input struct {
Body string
ContentType string
URL string
// ChunkRecords splits a JSON array of records into one chunk per record (filtered by JSONFilter), as the scrape
// and extract paths do. Without it, record arrays get the generic JSON formatter.
ChunkRecords bool
JSONFilter string
}
Input is one fetched document. Body must not be HTML; callers send HTML to the HTML extractor instead.