documents

package
v0.0.0-...-25d9ce1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectDocumentType

func DetectDocumentType(data []byte) string

DetectDocumentType determines the type of document from the raw data by checking magic bytes/headers

func ExtractHTMLFromZip

func ExtractHTMLFromZip(data []byte) ([]byte, error)

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

func GetFromURL(ctx context.Context, url string) ([]byte, error)

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

func PreprocessHTML(htmlData []byte) (string, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL