Documentation
¶
Overview ¶
Package officetext extracts plain/markdown text natively from DOCX, PPTX and XLSX files - no external service required. It exists so the read_file tool (and seshat-ai's upload/RAG ingestion paths) don't have to depend on docling-serve for formats that are just zipped XML: DOCX and PPTX share an OOXML document-tree shape (word/document.xml, ppt/slides/slideN.xml), so both walk the same generic tree in tree.go. XLSX is a distinct enough format (rows/columns/shared strings/formulas) that it's handled by excelize instead (see xlsx.go).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmpty = fmt.Errorf("no extractable text found")
ErrEmpty is returned by format extractors when the document parsed successfully but yielded no extractable text (e.g. an image-only slide deck) - callers can use this to decide whether to still try docling.
var SupportedExtensions = map[string]bool{ ".docx": true, ".pptx": true, ".xlsx": true, }
SupportedExtensions lists the formats this package can extract without any external service. Kept as the single source of truth for "is this a native-office format" checks - see internal/tools/files/read/detector.go.
Functions ¶
func Extract ¶
Extract dispatches to the format-specific extractor based on filename extension. ok is false when the extension isn't one this package handles; callers should fall back to another conversion path (e.g. docling) in that case rather than treating it as an error.
func ExtractDOCX ¶
ExtractDOCX converts a Word document's body (paragraphs, headings, tables) to markdown. Embedded images, headers/footers and tracked-changes markup are not rendered - callers that need those still have docling available.
func ExtractPPTX ¶
ExtractPPTX converts a slide deck to markdown: one "## Slide N" section per slide, with the slide's title (if any) promoted to a heading and other text placeholders/tables rendered below it. Slide order follows the presentation's actual slide order (ppt/presentation.xml's sldIdLst, resolved through the rels part), not filename sort - a deck whose slides were reordered after slideN.xml files were first created would otherwise come out in the wrong order.
func ExtractXLSX ¶
ExtractXLSX converts every sheet of a workbook to a markdown table, in workbook sheet order. Formulas are rendered as their last calculated value (excelize's GetRows resolves cached results, matching what a user would see with the workbook open), not as the formula text.
Types ¶
This section is empty.