Render content images at their original position in the prose flow - #22
Merged
Conversation
Images captured from a live DOM now carry a `position` anchor (the index of the block they follow, or -1 to lead the document), mirroring how data tables are anchored. toMarkdown splices positioned images into the flow, interleaved with prose and tables, instead of listing every image at the document tail. Images without a position (vision pipeline, stored articles, out-of-range anchors) keep the trailing-list fallback, and a new `unpositionedImages` diagnostic mirrors `unpositionedTables`. Spliced images keep the lowest render priority, so the "outline" budget still sheds images first and never spends heading/lead budget on them. Co-Authored-By: Claude Fable 5 <[email protected]>
yrstm
marked this pull request as ready for review
July 28, 2026 14:45
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.
Why
Mantis previously appended all images as a batch at the end of Markdown while data tables were already rendered inline. Content images should stay near the prose and tables they accompanied on the page.
What
positionanchor: the index of the captured block they follow, or-1when they lead the document.flowOrder, preserving their actual DOM order when they share an anchor.toMarkdown()validates anchors before splicing. Missing, fractional, non-finite, negative out-of-range, and past-the-end positions use the trailing fallback instead of being dropped.outlinebudget still sheds images first and images do not consume a section's lead priority.unpositionedImages,MantisImage.position, and the sharedflowOrderfields are documented in the type declarations.Compatibility
Testing
npm test: 70 passing.npm run types:check: passing.npm run benchmark: 129/129.npm run perf: fidelity checks passing.npm pack --dry-run: passing.testanddemo-browser: passing.