Documentation
¶
Index ¶
- func DetectDocumentType(data []byte) string
- func ExtractHTMLFromZip(data []byte) ([]byte, error)
- func FetchZoteroMetadata(ctx context.Context, zoteroID string, apiKey string, libraryID string) (*models.ItemMetadata, error)
- func GetData(ctx context.Context, sourceInfo models.SourceInfo) (models.DocumentData, error)
- func GetDataWithMetadata(ctx context.Context, sourceInfo models.SourceInfo) (models.DocumentData, *models.ItemMetadata, error)
- func GetFromURL(ctx context.Context, url string) ([]byte, error)
- func GetFromZotero(ctx context.Context, zoteroID string, apiKey string, libraryID string) ([]byte, error)
- func MergeMetadata(external *models.ItemMetadata, extracted *models.ItemMetadata) *models.ItemMetadata
- func PreprocessHTML(htmlData []byte) (string, error)
- func SplitPdf(pdf models.DocumentData) (models.DocumentPages, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectDocumentType ¶
DetectDocumentType determines the type of document from the raw data by checking magic bytes/headers
func ExtractHTMLFromZip ¶
ExtractHTMLFromZip attempts to extract HTML content from a ZIP archive (typically used for Zotero web page snapshots). It looks for the main HTML file and returns its contents. Returns error if no HTML file is found.
func FetchZoteroMetadata ¶
func FetchZoteroMetadata(ctx context.Context, zoteroID string, apiKey string, libraryID string) (*models.ItemMetadata, error)
FetchZoteroMetadata retrieves metadata for a Zotero item (attachment or parent item). If the zoteroID is an attachment, it fetches the parent item's metadata. Returns nil if the item is not found or has no useful metadata.
func GetData ¶
func GetData(ctx context.Context, sourceInfo models.SourceInfo) (models.DocumentData, error)
GetData retrieves document data from a source and detects its type
func GetDataWithMetadata ¶
func GetDataWithMetadata(ctx context.Context, sourceInfo models.SourceInfo) (models.DocumentData, *models.ItemMetadata, error)
GetDataWithMetadata retrieves document data from a source and detects its type, also returning external metadata if available (e.g., from Zotero). Returns the document data and external metadata (nil if not available).
func GetFromURL ¶
GetFromURL fetches document data from a URL
func GetFromZotero ¶
func GetFromZotero(ctx context.Context, zoteroID string, apiKey string, libraryID string) ([]byte, error)
GetFromZotero fetches document data from a Zotero library
func MergeMetadata ¶
func MergeMetadata(external *models.ItemMetadata, extracted *models.ItemMetadata) *models.ItemMetadata
MergeMetadata merges external metadata with extracted metadata. External metadata takes priority for all fields. Falls back to extracted metadata when external field is empty.
func PreprocessHTML ¶
PreprocessHTML converts HTML to markdown to reduce context window usage. This strips unnecessary markup, scripts, styling, and images while preserving document structure (headings, lists, tables, links).
func SplitPdf ¶
func SplitPdf(pdf models.DocumentData) (models.DocumentPages, error)
SplitPdf splits a PDF document into individual pages
Types ¶
This section is empty.