pdf2md

Turns PDF books into clean Markdown with a table of contents, and packs chapters into context bundles for AI chats, all on a local machine.

Problem

Books in PDF form are hard for a language model to use: the text comes out unstructured, chapters are lost and the whole book is too long for one conversation.

Value

A long book becomes a set of chapters an agent can read in one go, without sending the text to an outside service.

Role

Architecture, choice of conversion engines, chapter-boundary tests and the decision records. Agents wrote most of the code.

  • Set up a layered architecture in which the conversion engines are swappable and compared on the same documents.
  • Used a local language model to classify documents and to recover the table of contents.
  • Built a regression suite for chapter boundaries so a changed engine cannot silently split a chapter wrong.
  • Recorded four architecture decisions.

Limits

  • The converted books are reading material under copyright and are never shown. Only the tool is described.

Sources

  • Four architecture decision records
  • Private version that runs on a local machine