Extract

Turn a document into Markdown that still knows what a heading is. The next stage splits on that structure — so flattening to plain text here would leave it nothing to split on.

Extract a document

Checking whether the local package is running…

Drop a document here

Text, Markdown, HTML and CSV work unaided — PDF, Word, slides and spreadsheets need the local package

Markdown keeps headings and tables. Text flattens everything — which also means the chunk tool has nothing structural left to work with.

A YAML block recording the source, page count and extraction time.

Page boundaries as HTML comments. Renderers ignore them; the chunk tool reads them, which is what lets a chunk cite its page.

Render tables as Markdown tables rather than flattening them to lines.

Nothing here is uploaded. The bridge, when it runs at all, runs on your own machine and answers only to this page.

Arguments

The same arguments work in all three places — this page, the Assistant, and the Python package. This table is generated from the tool spec the code itself reads, so it cannot drift out of date.

Where Headings Come From

Structure is read, never invented. A format with no notion of a heading gets page or section markers and nothing more — guessing from font sizes would produce an outline that looks right and is wrong.

FormatHeadings fromRuns where
.mdthe Markdown itselfthis tab
.htmlh1–h6 tagsthis tab
.csvnone — becomes one tablethis tab
.txtnone — split on blank linesthis tab
.docxparagraph styleslocal package
.pdfthe PDF outline, when it has onelocal package
.pptxslide titleslocal package
.xlsxsheet nameslocal package
.epubthe table of contentslocal package
.odtparagraph styleslocal package
.emlmail headerslocal package
.rtfnonelocal package

Use It From Python

The Python tier reads every format on the list. It is also what this page talks to when you run the bridge.

From the THL library

Document loaders are an optional extra, so the base install stays small for anyone who only wanted to convert an image.

Install
pip install "thehallucinatedlab[extract]"
Extract a document
from thehallucinatedlab import extract result = extract("report.pdf") print(result.path, result.pages, result.headings)
Or from the command line
thl extract report.pdf --format markdown # plain english works too thl "extract this pdf to markdown"
Let this page use it
thl serve

The bridge listens on loopback only and accepts requests from this origin alone. Nothing is uploaded — the file goes from your disk to a process on the same machine and back. Close the terminal and the page carries on with the formats it reads unaided.