Documentation
¶
Index ¶
- func ProcessParse(process *process.Process) interface{}
- func ProcessParseBytes(process *process.Process) interface{}
- func RunCommand()
- type CommandLineConverter
- type DocxBody
- type DocxBold
- type DocxCoreProperties
- type DocxDocument
- type DocxDrawing
- type DocxItalic
- type DocxPPr
- type DocxPStyle
- type DocxParagraph
- type DocxRPr
- type DocxRelationship
- type DocxRelationships
- type DocxRun
- type DocxText
- type FileParser
- type Media
- type Metadata
- type ParseResult
- type Parser
- type PptxCNvPr
- type PptxCSld
- type PptxCoreProperties
- type PptxNvSpPr
- type PptxPPr
- type PptxParagraph
- type PptxPresentation
- type PptxRPr
- type PptxRelationship
- type PptxRelationships
- type PptxRun
- type PptxShape
- type PptxSlide
- type PptxSlideID
- type PptxSlideIDLst
- type PptxSpTree
- type PptxTxBody
- type ProcessMediaEntry
- type ProcessParseResult
- type TextRange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProcessParse ¶
ProcessParse office.Parse Parse an Office document (DOCX/PPTX) from a file path. Embedded media is extracted and saved as files to output_dir.
Args:
- filePath string - Path to the Office document
- config map[string]interface{} - Optional configuration
Config fields:
- output_dir string - Directory for extracted media (optional, default: auto temp dir)
Returns: *ProcessParseResult - Parsed document with markdown, metadata, and media file paths
Note: If output_dir is not specified, a temp directory is created automatically. The caller is responsible for cleaning up the output directory when done.
Usage:
var result = Process("office.Parse", "/path/to/document.docx", {"output_dir": "/data/tmp"})
// Returns: {"markdown": "...", "metadata": {...}, "media": [{"path": "/data/tmp/image1.png", ...}]}
func ProcessParseBytes ¶
ProcessParseBytes office.ParseBytes Parse an Office document from base64-encoded data (for in-memory files). Embedded media is extracted and saved as files to output_dir.
Args:
- data string - Base64-encoded file content
- config map[string]interface{} - Optional configuration
Config fields:
- output_dir string - Directory for extracted media (optional, default: auto temp dir)
Returns: *ProcessParseResult - Parsed document with markdown, metadata, and media file paths
Note: The base64 decode + parse will hold the entire file in memory. For very large files (>100MB), prefer using office.Parse with a file path instead. If output_dir is not specified, a temp directory is created automatically. The caller is responsible for cleaning up the output directory when done.
Usage:
var result = Process("office.ParseBytes", "UEsDBBQAAAAIAA...", {"output_dir": "/data/tmp"})
// Returns: {"markdown": "...", "metadata": {...}, "media": [{"path": "/data/tmp/image1.png", ...}]}
Types ¶
type CommandLineConverter ¶
type CommandLineConverter struct {
// contains filtered or unexported fields
}
CommandLineConverter handles command line operations
func NewCommandLineConverter ¶
func NewCommandLineConverter() *CommandLineConverter
NewCommandLineConverter creates a new command line converter
func (*CommandLineConverter) ConvertFile ¶
func (c *CommandLineConverter) ConvertFile(inputPath string) error
ConvertFile converts a single Office document to markdown and saves to output directory
type DocxBody ¶
type DocxBody struct {
XMLName xml.Name `xml:"body"`
Paragraphs []DocxParagraph `xml:"p"`
}
DocxBody represents the document body
type DocxCoreProperties ¶
type DocxCoreProperties struct {
XMLName xml.Name `xml:"coreProperties"`
Title string `xml:"title"`
Subject string `xml:"subject"`
Creator string `xml:"creator"`
Keywords string `xml:"keywords"`
Description string `xml:"description"`
}
DocxCoreProperties represents document core properties
type DocxDocument ¶
DocxDocument represents the main document structure
type DocxDrawing ¶
DocxDrawing represents embedded drawings/images
type DocxItalic ¶
DocxItalic represents italic formatting
type DocxPPr ¶
type DocxPPr struct {
XMLName xml.Name `xml:"pPr"`
PStyle DocxPStyle `xml:"pStyle"`
}
DocxPPr represents paragraph properties
type DocxPStyle ¶
DocxPStyle represents paragraph style
type DocxParagraph ¶
type DocxParagraph struct {
XMLName xml.Name `xml:"p"`
PPr DocxPPr `xml:"pPr"`
Runs []DocxRun `xml:"r"`
}
DocxParagraph represents a paragraph in the document
type DocxRPr ¶
type DocxRPr struct {
XMLName xml.Name `xml:"rPr"`
Bold *DocxBold `xml:"b"`
Italic *DocxItalic `xml:"i"`
}
DocxRPr represents run properties (formatting)
type DocxRelationship ¶
type DocxRelationship struct {
XMLName xml.Name `xml:"Relationship"`
ID string `xml:"Id,attr"`
Type string `xml:"Type,attr"`
Target string `xml:"Target,attr"`
}
DocxRelationship represents a single relationship
type DocxRelationships ¶
type DocxRelationships struct {
XMLName xml.Name `xml:"Relationships"`
Relationships []DocxRelationship `xml:"Relationship"`
}
DocxRelationships represents document relationships
type DocxRun ¶
type DocxRun struct {
XMLName xml.Name `xml:"r"`
RPr DocxRPr `xml:"rPr"`
Text []DocxText `xml:"t"`
Drawing DocxDrawing `xml:"drawing"`
}
DocxRun represents a run of text with formatting
type FileParser ¶
type FileParser interface {
Parse(data []byte) (*ParseResult, error)
GetSupportedFormats() []string
}
FileParser interface for Office document parsing
type Media ¶
type Media struct {
ID string `json:"id"`
Type string `json:"type"` // image, video, audio
Format string `json:"format"` // png, jpg, mp4, etc.
Content []byte `json:"content"` // File content
Filename string `json:"filename"` // Original filename
RefID string `json:"ref_id"` // Reference ID
}
Media represents a media file within the document
type Metadata ¶
type Metadata struct {
Title string `json:"title"`
Author string `json:"author"`
Subject string `json:"subject"`
Keywords string `json:"keywords"`
Pages int `json:"pages"`
TextRanges []TextRange `json:"text_ranges"`
MediaRefs map[string]string `json:"media_refs"` // Media reference mapping
}
Metadata contains document metadata and text range information
type ParseResult ¶
type ParseResult struct {
Markdown string `json:"markdown"`
Metadata *Metadata `json:"metadata"`
Media []Media `json:"media"`
}
ParseResult represents the result of parsing an Office document
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser handles Office document parsing
func (*Parser) GetSupportedFormats ¶
GetSupportedFormats returns the list of supported document formats
type PptxCSld ¶
type PptxCSld struct {
XMLName xml.Name `xml:"cSld"`
SpTree PptxSpTree `xml:"spTree"`
}
PptxCSld represents the common slide data
type PptxCoreProperties ¶
type PptxCoreProperties struct {
XMLName xml.Name `xml:"coreProperties"`
Title string `xml:"title"`
Subject string `xml:"subject"`
Creator string `xml:"creator"`
Keywords string `xml:"keywords"`
Description string `xml:"description"`
}
PptxCoreProperties represents presentation core properties
type PptxNvSpPr ¶
PptxNvSpPr represents non-visual shape properties
type PptxParagraph ¶
type PptxParagraph struct {
XMLName xml.Name `xml:"p"`
PPr PptxPPr `xml:"pPr"`
Runs []PptxRun `xml:"r"`
}
PptxParagraph represents a paragraph in text body
type PptxPresentation ¶
type PptxPresentation struct {
XMLName xml.Name `xml:"presentation"`
SlideIDLst PptxSlideIDLst `xml:"sldIdLst"`
}
PptxPresentation represents the main presentation structure
type PptxRPr ¶
type PptxRPr struct {
XMLName xml.Name `xml:"rPr"`
Bold string `xml:"b,attr"`
Italic string `xml:"i,attr"`
}
PptxRPr represents run properties
type PptxRelationship ¶
type PptxRelationship struct {
XMLName xml.Name `xml:"Relationship"`
ID string `xml:"Id,attr"`
Type string `xml:"Type,attr"`
Target string `xml:"Target,attr"`
}
PptxRelationship represents a single relationship
type PptxRelationships ¶
type PptxRelationships struct {
XMLName xml.Name `xml:"Relationships"`
Relationships []PptxRelationship `xml:"Relationship"`
}
PptxRelationships represents presentation relationships
type PptxShape ¶
type PptxShape struct {
XMLName xml.Name `xml:"sp"`
TxBody PptxTxBody `xml:"txBody"`
NvSpPr PptxNvSpPr `xml:"nvSpPr"`
}
PptxShape represents a shape in the slide
type PptxSlideID ¶
PptxSlideID represents a slide ID reference
type PptxSlideIDLst ¶
type PptxSlideIDLst struct {
XMLName xml.Name `xml:"sldIdLst"`
SlideIds []PptxSlideID `xml:"sldId"`
}
PptxSlideIDLst represents the list of slide IDs
type PptxSpTree ¶
PptxSpTree represents the shape tree
type PptxTxBody ¶
type PptxTxBody struct {
XMLName xml.Name `xml:"txBody"`
Paragraphs []PptxParagraph `xml:"p"`
}
PptxTxBody represents text body
type ProcessMediaEntry ¶
type ProcessMediaEntry struct {
ID string `json:"id"`
Type string `json:"type"` // "image", "video", "audio"
Format string `json:"format"` // "png", "jpeg", "gif", etc.
Filename string `json:"filename"` // Original filename
Path string `json:"path"` // OS file path where media is saved
}
ProcessMediaEntry represents a media entry with file path (no base64).
type ProcessParseResult ¶
type ProcessParseResult struct {
Markdown string `json:"markdown"`
Metadata *Metadata `json:"metadata"`
Media []ProcessMediaEntry `json:"media"`
}
ProcessParseResult is the result returned by office process handlers. Media files are saved to output_dir; media[].path contains the file path.