Repository navigation
markdown: read the pages back as a document, and decode what the file says - #49
Merged
Merged
Conversation
… says pdfops markdown writes the pages as Markdown -- headings, paragraphs, lists and tables, through go-pdfkit/document v0.1.0. With -json it writes one record per page instead: the page's markdown plus the document's own metadata, which is the shape a retrieval pipeline already expects (LlamaIndex's document schema, which is what PyMuPDF4LLM's LlamaMarkdownReader produces). One verb for both of BentoPDF's pdf-to-markdown and prepare-pdf-for-ai, because prepare-pdf-for-ai IS per-page markdown with metadata. THE RANGE IS APPLIED AFTER THE DOCUMENT IS READ. What counts as a heading is decided by the sizes the whole document uses, so asking for page nine alone would give it different headings from asking for all of them -- and a caller doing a document a page at a time would get a different answer for every page. A test asserts that page one reads the same both ways. AND IT DECODES THE METADATA. A title written in UTF-16 behind a byte order mark came out of ToString as "\xfe\xffL\x00a\x00..."; `info` printed it that way too, for as long as that verb has existed. Both go through reader.TextString now, and `info` on a pandoc-produced file says creator LaTeX via pandoc where it used to print the raw UTF-16. 100% of statements with no uncovered blocks, 17 mutations caught. Four needed tests that did not exist: the indentation, `[]` rather than `null` for a document with no pages, the base name rather than the whole path, and the lowered keys. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pdfops markdownwrites the pages as Markdown — headings, paragraphs, listsand tables — through
go-pdfkit/document v0.1.0. With
-jsonit writes one record per page instead: the page's Markdown plus thedocument's own metadata, which is the shape a retrieval pipeline already
expects (LlamaIndex's document schema, the one PyMuPDF4LLM's
LlamaMarkdownReaderproduces).One verb for both of BentoPDF's
pdf-to-markdownandprepare-pdf-for-ai,because
prepare-pdf-for-aiis per-page Markdown with metadata.⛔ The range is applied after the document is read, never before
What counts as a heading is decided by the sizes the whole document uses,
so asking for page nine alone would otherwise give it different headings from
asking for all of them — and a caller doing a document a page at a time would
get a different answer for every page. A test asserts that page one reads the
same both ways.
⛔ And it decodes the metadata
A title written in UTF-16 behind a byte order mark came out of
ToStringas\xfe\xffL\x00a\x00….infoprinted it that way too, for as long as thatverb has existed. Both go through
reader.TextStringnow, andinfoon a pandoc-produced file sayswhere it used to print the raw UTF-16.
How it is checked
100% of statements with no uncovered blocks, 17 mutations caught. Four needed
tests that did not exist:
[]rather thannullfile_pathwould have leaked the operator's directory layoutTitleandtitleare the same field to a callerReal output
🤖 Generated with Claude Code