Skip to content

Commit ee633b4

Browse files
Martinclaude
andcommitted
fix(insert-markers): extract images when insertMarkers enabled
Images were not being extracted when insert_markers=true but include_image_indexes=false, causing image markers to be missing from output. The extractPageContent function now receives shouldIncludeImages which is true when EITHER includeImageIndexes OR insertMarkers is enabled, ensuring images are available for marker insertion. Verified with real-world PDF (SOLO 574 HYDRO manual) showing correct [IMAGE] markers on all diagram pages. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 6b1778e commit ee633b4

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

dist/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,12 @@ var normalizeLine = (input, options) => {
15371537
return normalized;
15381538
};
15391539
var buildNormalizedPageText = (items, options) => {
1540-
const { preserveWhitespace = false, trimLines = true, maxCharsPerPage, insertMarkers = false } = options;
1540+
const {
1541+
preserveWhitespace = false,
1542+
trimLines = true,
1543+
maxCharsPerPage,
1544+
insertMarkers = false
1545+
} = options;
15411546
const normalizedLines = [];
15421547
let truncated = false;
15431548
let consumed = 0;
@@ -1633,7 +1638,8 @@ var processPage = async (pdfDocument, pageNum, sourceDescription, options, finge
16331638
if (cached) {
16341639
return cached;
16351640
}
1636-
const items = await extractPageContent(pdfDocument, pageNum, options.includeImageIndexes, sourceDescription);
1641+
const shouldIncludeImages = options.includeImageIndexes || options.insertMarkers;
1642+
const items = await extractPageContent(pdfDocument, pageNum, shouldIncludeImages, sourceDescription);
16371643
const normalized = buildNormalizedPageText(items, {
16381644
preserveWhitespace: options.preserveWhitespace,
16391645
trimLines: options.trimLines,

src/handlers/readPages.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@ const processPage = async (
3838
return cached;
3939
}
4040

41+
// Extract images if either includeImageIndexes or insertMarkers is enabled
42+
const shouldIncludeImages = options.includeImageIndexes || options.insertMarkers;
43+
4144
const items = await extractPageContent(
4245
pdfDocument,
4346
pageNum,
44-
options.includeImageIndexes,
47+
shouldIncludeImages,
4548
sourceDescription
4649
);
4750

0 commit comments

Comments
 (0)