types

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cell

type Cell struct {
	Content string
	ColSpan int // For merged cells (DOCX), 1 if not merged
	RowSpan int // For merged cells (DOCX), 1 if not merged
}

Cell represents a table cell with optional merged cell information.

type DocumentData

type DocumentData struct {
	Elements   []Element   // Ordered sequence of elements (preserves document structure)
	Headings   []Heading   // All headings (for backward compatibility)
	Paragraphs []Paragraph // All paragraphs (for backward compatibility)
	Tables     []Table     // All tables (for backward compatibility)
	Images     []Image     // All images (for backward compatibility)
	Lists      []List      // All lists (for backward compatibility, DOCX only)
	Links      []Link      // All links (for backward compatibility, DOCX only)
	Warnings   []Warning   // Parsing warnings (non-fatal issues)
}

DocumentData represents extracted document content from DOCX or PDF files. This is the common data structure used by both parsers before conversion to Markdown. Elements preserves document order if populated by the parser. The individual slices (Headings, Paragraphs, etc.) are kept for backward compatibility.

type Element

type Element struct {
	Type      ElementType
	Heading   *Heading
	Paragraph *Paragraph
	Table     *Table
	Image     *Image
	List      *List
	Link      *Link
}

Element represents a single document element with its type and data. This preserves document order by allowing elements to be stored in sequence.

type ElementType

type ElementType int

ElementType represents the type of a document element.

const (
	ElementTypeHeading ElementType = iota
	ElementTypeParagraph
	ElementTypeTable
	ElementTypeImage
	ElementTypeList
	ElementTypeLink
)

type Formatting

type Formatting struct {
	Bold      bool
	Italic    bool
	Underline bool
	Code      bool
}

Formatting represents text formatting attributes.

type Heading

type Heading struct {
	Level int // 1-6 for H1-H6
	Text  string
}

Heading represents a document heading with its level (1-6).

type Image

type Image struct {
	Data     []byte
	Format   string // "png", "jpeg", "gif", etc.
	Filename string
	AltText  string
	Width    int
	Height   int
}

Image represents an extracted image from the document.

type Link struct {
	Text string
	URL  string
}

Link represents a hyperlink.

type List

type List struct {
	Ordered bool
	Items   []ListItem
}

List represents a list (ordered or unordered) with items.

type ListItem

type ListItem struct {
	Text  string
	Level int // Nesting level (0 = top level)
}

ListItem represents a single item in a list.

type Paragraph

type Paragraph struct {
	Text       string
	Formatting Formatting
}

Paragraph represents a paragraph with optional formatting.

type Table

type Table struct {
	Rows [][]Cell
}

Table represents a table with rows and cells.

type Warning

type Warning struct {
	Category string // Category of warning: "image", "table", "link", "close", etc.
	Message  string // Human-readable warning message
	Error    error  // Optional underlying error (nil if no error)
}

Warning represents a non-fatal parsing issue that occurred during document extraction. Warnings allow users to know about partial failures (e.g., failed image extraction, table extraction issues) without failing the entire parse operation.

Jump to

Keyboard shortcuts

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