docparser/Supported formats
Supported formats
What docparser captures from each format — .docx, .xlsx, .pdf, .html, .pptx, .epub, and plain text/CSV.
docparser dispatches by file extension and normalizes everything into the same
Markdown + JSON block schema (see Output & schema).
Here's what each parser captures.
.docx
- Walks the document body in document order (paragraphs + tables + drawings).
- Preserves heading hierarchy (
section_path) on every block. - Extracts every embedded image to
data/assets/<slug>/with a stableimg-<seq>-<sha10>.<ext>name. - Detects figure/table captions (style
Caption, or text matchingFigure 1: …/Fig. 1./Table 1.) and associates the caption with the preceding image. - Captures
context_beforeandcontext_afterfor every image so the VLM has document-grounded context.
.xlsx
- Iterates every sheet, every row, every column.
- For each cell stores: address, row/col indices, value, openpyxl
data_type,number_format,hyperlink,comment, and the formula (from a second pass withdata_only=False). - Stores
merged_ranges,frozen_panes, and any embedded images. - Markdown rendering uses the first non-empty row as a header heuristic and
preserves multi-line cells with
<br>.
.pdf
- Page-by-page text extraction in reading order via PyMuPDF's blocks API.
- Best-effort heading detection from font size (≥120% of the body-text median promotes a line to a heading; the bold flag is tracked).
- Embedded raster images extracted via
doc.extract_image(xref). - Pluggable backends, OCR, and table extraction — covered in detail in PDF backends & OCR.
.html
- Article-grade body extraction via
trafilatura. - Plus a structural BeautifulSoup walk that emits typed blocks
(
heading/paragraph/list/table/image) so downstream RAG layers can rely on the JSON. sourcemay be a local path or anhttp(s)://URL.
.pptx
- Walks slides in presentation order; each slide becomes a section.
- Emits per-slide headings (slide title), bulleted text frames (with list level), tables, pictures, and speaker notes.
- Embedded pictures are extracted and optionally captioned.
.epub
- Walks the spine in reading order; per-chapter BeautifulSoup structural walk.
- Captures metadata (title/author/language), headings, paragraphs, lists, tables, and embedded images (resolved from the EPUB image manifest).
.txt / .md and .csv / .tsv (core, no extras)
- Plain text is split into paragraph blocks; Markdown is passed through and also decomposed into heading / list / code / paragraph blocks.
- CSV/TSV: delimiter sniffing, header detection, a Markdown table, and one JSON record per row.
Extras required
.docx, .xlsx, and .txt/.md/.csv work with the core install. .pdf,
.html, .pptx, and .epub each need their respective
install extra.