@effortlessmotion/pdf-to-md 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +157 -0
- package/bin/cli.js +9 -0
- package/dist/cjs/analyze.d.cts +35 -0
- package/dist/cjs/analyze.d.ts +35 -0
- package/dist/cjs/analyze.js +620 -0
- package/dist/cjs/analyze.js.map +1 -0
- package/dist/cjs/audit.d.cts +38 -0
- package/dist/cjs/audit.d.ts +38 -0
- package/dist/cjs/audit.js +252 -0
- package/dist/cjs/audit.js.map +1 -0
- package/dist/cjs/cli/audit.d.cts +3 -0
- package/dist/cjs/cli/audit.d.ts +3 -0
- package/dist/cjs/cli/audit.js +269 -0
- package/dist/cjs/cli/audit.js.map +1 -0
- package/dist/cjs/cli/extract.d.cts +3 -0
- package/dist/cjs/cli/extract.d.ts +3 -0
- package/dist/cjs/cli/extract.js +704 -0
- package/dist/cjs/cli/extract.js.map +1 -0
- package/dist/cjs/cli/index.d.cts +5 -0
- package/dist/cjs/cli/index.d.ts +5 -0
- package/dist/cjs/cli/index.js +58 -0
- package/dist/cjs/cli/index.js.map +1 -0
- package/dist/cjs/cli/render.d.cts +3 -0
- package/dist/cjs/cli/render.d.ts +3 -0
- package/dist/cjs/cli/render.js +361 -0
- package/dist/cjs/cli/render.js.map +1 -0
- package/dist/cjs/cli/types.d.cts +10 -0
- package/dist/cjs/cli/types.d.ts +10 -0
- package/dist/cjs/cli/types.js +7 -0
- package/dist/cjs/cli/types.js.map +1 -0
- package/dist/cjs/cli.d.cts +2 -0
- package/dist/cjs/cli.d.ts +2 -0
- package/dist/cjs/cli.js +345 -0
- package/dist/cjs/cli.js.map +1 -0
- package/dist/cjs/collect.d.cts +6 -0
- package/dist/cjs/collect.d.ts +6 -0
- package/dist/cjs/collect.js +370 -0
- package/dist/cjs/collect.js.map +1 -0
- package/dist/cjs/dict.d.cts +8 -0
- package/dist/cjs/dict.d.ts +8 -0
- package/dist/cjs/dict.js +55 -0
- package/dist/cjs/dict.js.map +1 -0
- package/dist/cjs/emit.d.cts +27 -0
- package/dist/cjs/emit.d.ts +27 -0
- package/dist/cjs/emit.js +187 -0
- package/dist/cjs/emit.js.map +1 -0
- package/dist/cjs/engines/tesseract.d.cts +30 -0
- package/dist/cjs/engines/tesseract.d.ts +30 -0
- package/dist/cjs/engines/tesseract.js +650 -0
- package/dist/cjs/engines/tesseract.js.map +1 -0
- package/dist/cjs/errors.d.cts +21 -0
- package/dist/cjs/errors.d.ts +21 -0
- package/dist/cjs/errors.js +124 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/extract.d.cts +88 -0
- package/dist/cjs/extract.d.ts +88 -0
- package/dist/cjs/extract.js +436 -0
- package/dist/cjs/extract.js.map +1 -0
- package/dist/cjs/geometry.d.cts +63 -0
- package/dist/cjs/geometry.d.ts +63 -0
- package/dist/cjs/geometry.js +521 -0
- package/dist/cjs/geometry.js.map +1 -0
- package/dist/cjs/index.d.cts +15 -0
- package/dist/cjs/index.d.ts +15 -0
- package/dist/cjs/index.js +56 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lines.d.cts +3 -0
- package/dist/cjs/lines.d.ts +3 -0
- package/dist/cjs/lines.js +181 -0
- package/dist/cjs/lines.js.map +1 -0
- package/dist/cjs/markdown.d.cts +2 -0
- package/dist/cjs/markdown.d.ts +2 -0
- package/dist/cjs/markdown.js +222 -0
- package/dist/cjs/markdown.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/page-marker.d.cts +16 -0
- package/dist/cjs/page-marker.d.ts +16 -0
- package/dist/cjs/page-marker.js +85 -0
- package/dist/cjs/page-marker.js.map +1 -0
- package/dist/cjs/pdf-open.d.cts +12 -0
- package/dist/cjs/pdf-open.d.ts +12 -0
- package/dist/cjs/pdf-open.js +257 -0
- package/dist/cjs/pdf-open.js.map +1 -0
- package/dist/cjs/raster.d.cts +26 -0
- package/dist/cjs/raster.d.ts +26 -0
- package/dist/cjs/raster.js +262 -0
- package/dist/cjs/raster.js.map +1 -0
- package/dist/cjs/render-analysis.d.cts +25 -0
- package/dist/cjs/render-analysis.d.ts +25 -0
- package/dist/cjs/render-analysis.js +319 -0
- package/dist/cjs/render-analysis.js.map +1 -0
- package/dist/cjs/report.d.cts +12 -0
- package/dist/cjs/report.d.ts +12 -0
- package/dist/cjs/report.js +392 -0
- package/dist/cjs/report.js.map +1 -0
- package/dist/cjs/resolve.d.cts +1 -0
- package/dist/cjs/resolve.d.ts +1 -0
- package/dist/cjs/resolve.js +18 -0
- package/dist/cjs/resolve.js.map +1 -0
- package/dist/cjs/types.d.cts +171 -0
- package/dist/cjs/types.d.ts +171 -0
- package/dist/cjs/types.js +9 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/validate.d.cts +14 -0
- package/dist/cjs/validate.d.ts +14 -0
- package/dist/cjs/validate.js +96 -0
- package/dist/cjs/validate.js.map +1 -0
- package/dist/esm/analyze.d.ts +35 -0
- package/dist/esm/analyze.js +270 -0
- package/dist/esm/analyze.js.map +1 -0
- package/dist/esm/audit.d.ts +38 -0
- package/dist/esm/audit.js +113 -0
- package/dist/esm/audit.js.map +1 -0
- package/dist/esm/cli/audit.d.ts +3 -0
- package/dist/esm/cli/audit.js +20 -0
- package/dist/esm/cli/audit.js.map +1 -0
- package/dist/esm/cli/extract.d.ts +3 -0
- package/dist/esm/cli/extract.js +313 -0
- package/dist/esm/cli/extract.js.map +1 -0
- package/dist/esm/cli/index.d.ts +5 -0
- package/dist/esm/cli/index.js +7 -0
- package/dist/esm/cli/index.js.map +1 -0
- package/dist/esm/cli/render.d.ts +3 -0
- package/dist/esm/cli/render.js +77 -0
- package/dist/esm/cli/render.js.map +1 -0
- package/dist/esm/cli/types.d.ts +10 -0
- package/dist/esm/cli/types.js +3 -0
- package/dist/esm/cli/types.js.map +1 -0
- package/dist/esm/cli.d.ts +2 -0
- package/dist/esm/cli.js +90 -0
- package/dist/esm/cli.js.map +1 -0
- package/dist/esm/collect.d.ts +6 -0
- package/dist/esm/collect.js +80 -0
- package/dist/esm/collect.js.map +1 -0
- package/dist/esm/dict.d.ts +8 -0
- package/dist/esm/dict.js +28 -0
- package/dist/esm/dict.js.map +1 -0
- package/dist/esm/emit.d.ts +27 -0
- package/dist/esm/emit.js +131 -0
- package/dist/esm/emit.js.map +1 -0
- package/dist/esm/engines/tesseract.d.ts +30 -0
- package/dist/esm/engines/tesseract.js +190 -0
- package/dist/esm/engines/tesseract.js.map +1 -0
- package/dist/esm/errors.d.ts +21 -0
- package/dist/esm/errors.js +9 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/extract.d.ts +88 -0
- package/dist/esm/extract.js +147 -0
- package/dist/esm/extract.js.map +1 -0
- package/dist/esm/geometry.d.ts +63 -0
- package/dist/esm/geometry.js +279 -0
- package/dist/esm/geometry.js.map +1 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lines.d.ts +3 -0
- package/dist/esm/lines.js +67 -0
- package/dist/esm/lines.js.map +1 -0
- package/dist/esm/markdown.d.ts +2 -0
- package/dist/esm/markdown.js +153 -0
- package/dist/esm/markdown.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/page-marker.d.ts +16 -0
- package/dist/esm/page-marker.js +40 -0
- package/dist/esm/page-marker.js.map +1 -0
- package/dist/esm/pdf-open.d.ts +12 -0
- package/dist/esm/pdf-open.js +61 -0
- package/dist/esm/pdf-open.js.map +1 -0
- package/dist/esm/raster.d.ts +26 -0
- package/dist/esm/raster.js +60 -0
- package/dist/esm/raster.js.map +1 -0
- package/dist/esm/render-analysis.d.ts +25 -0
- package/dist/esm/render-analysis.js +115 -0
- package/dist/esm/render-analysis.js.map +1 -0
- package/dist/esm/report.d.ts +12 -0
- package/dist/esm/report.js +182 -0
- package/dist/esm/report.js.map +1 -0
- package/dist/esm/resolve.d.ts +1 -0
- package/dist/esm/resolve.js +7 -0
- package/dist/esm/resolve.js.map +1 -0
- package/dist/esm/types.d.ts +171 -0
- package/dist/esm/types.js +6 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/validate.d.ts +14 -0
- package/dist/esm/validate.js +56 -0
- package/dist/esm/validate.js.map +1 -0
- package/package.json +67 -0
- package/skills/pdf-to-md/SKILL.md +102 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Projects/pdf-to-md/src/cli/extract.ts"],"sourcesContent":["// extract command — parse this command's flags, call src/extract.ts, print\n// and write the result. No business logic here — the library returns data and throws; only the CLI prints and exits.\nimport { readFileSync, writeFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { parseArgs } from 'node:util';\nimport type { OcrWordInput } from '../extract.ts';\nimport type { Tuning } from '../geometry.ts';\nimport type { Analysis, Report } from '../types.ts';\nimport type { Command } from './types.ts';\n\nconst USAGE =\n 'usage: pdf-to-md [extract] <file.pdf> [out.md] [--json] [--page-markers] [--ocr] [--no-ocr] ' +\n '[--pages N[-M]] [--stdout] [--words-json=FILE] [--debug-words=FILE] ' +\n '[--format md|txt|raw (default md; raw = Analysis JSON incl. the report; txt = reading-order plain text)] ' +\n '[--dpi=N (OCR render resolution, default 288; raise for tiny print or chart/label pages, ' +\n '>~400 measured worse on ordinary prose pages)] ' +\n '[--float-max-words=N] [--float-max-width=F] [--float-margin=F] [--para-gap=F] [--heading-scale=F] ' +\n '[--col-max-width=F] [--col-split=F] [--line-y-tol=F] [--line-height-ratio=F]';\n\nconst FORMATS = ['md', 'txt', 'raw'] as const;\ntype Format = (typeof FORMATS)[number];\n\n// A bad tuning-flag value (non-numeric, or <= 0 unless the flag allows zero) is a usage error, not a silent no-op.\nconst TUNING_FLAGS: {\n name: string;\n key: keyof Tuning;\n allowZero?: boolean;\n isInt?: boolean;\n}[] = [\n {\n name: 'float-max-words',\n key: 'floatMaxWords',\n allowZero: true,\n isInt: true,\n },\n { name: 'float-max-width', key: 'floatMaxWidth' },\n { name: 'float-margin', key: 'floatMargin' },\n { name: 'para-gap', key: 'paraGap' },\n { name: 'heading-scale', key: 'headingScale' },\n { name: 'col-max-width', key: 'colMaxWidth' },\n { name: 'col-split', key: 'colSplit' },\n { name: 'line-y-tol', key: 'lineYTol' },\n { name: 'line-height-ratio', key: 'lineHeightRatio' },\n];\n\nconst extract: Command = async (ctx) => {\n // --debug-words takes a required FILE value; a bare --debug-words is a\n // usage error, checked before parseArgs so it can't silently swallow the next token as its value.\n if (ctx.rest.includes('--debug-words')) {\n ctx.usageError(`${USAGE}\\n--debug-words requires a value: --debug-words=FILE`);\n }\n\n const parsed = (() => {\n try {\n return parseArgs({\n args: ctx.rest,\n options: {\n json: { type: 'boolean', default: false },\n 'page-markers': { type: 'boolean', default: false },\n ocr: { type: 'boolean', default: false },\n 'no-ocr': { type: 'boolean', default: false },\n stdout: { type: 'boolean', default: false },\n 'debug-words': { type: 'string' },\n help: { type: 'boolean', default: false, short: 'h' },\n pages: { type: 'string' },\n dpi: { type: 'string' },\n format: { type: 'string', default: 'md' },\n 'words-json': { type: 'string' },\n ...Object.fromEntries(TUNING_FLAGS.map((f) => [f.name, { type: 'string' as const }])),\n },\n allowPositionals: true,\n });\n } catch (err) {\n // usageError exits; the throw is dead code that tells the compiler so.\n throw ctx.usageError(`${(err as Error).message}\\n${USAGE}`);\n }\n })();\n const values = parsed.values as Record<string, string | boolean | undefined>;\n const positionals = parsed.positionals;\n\n if (values.help) {\n console.log(USAGE);\n return;\n }\n\n const [src, outArg] = positionals;\n const wordsPath = values['words-json'] as string | undefined;\n if (!src && !wordsPath) ctx.usageError(USAGE);\n\n const formatRaw = values.format as string;\n if (!(FORMATS as readonly string[]).includes(formatRaw)) {\n ctx.usageError(`${USAGE}\\n--format must be one of ${FORMATS.join('|')} (got ${JSON.stringify(formatRaw)})`);\n }\n const format = formatRaw as Format;\n\n // --pages: a malformed spec is a usage error; out-of-range page NUMBERS\n // clamp instead (collect.ts / the engine apply the same clamping policy).\n let pages: { first: number; last: number } | undefined;\n if (values.pages !== undefined) {\n const m = /^(\\d+)(?:-(\\d+))?$/.exec(values.pages as string);\n const first = m ? Number(m[1]) : Number.NaN;\n const last = m ? (m[2] !== undefined ? Number(m[2]) : first) : Number.NaN;\n if (!m || first < 1 || last < first) {\n ctx.usageError(`${USAGE}\\n--pages requires N or N-M, N >= 1, M >= N (got ${JSON.stringify(values.pages)})`);\n }\n pages = { first, last };\n }\n\n const tuning: Partial<Tuning> = {};\n for (const spec of TUNING_FLAGS) {\n const raw = values[spec.name] as string | undefined;\n if (raw === undefined) continue;\n const value = Number(raw);\n const ok = raw !== '' && Number.isFinite(value) && (spec.allowZero ? value >= 0 : value > 0);\n if (!ok) {\n ctx.usageError(`${USAGE}\\n--${spec.name} requires a ${spec.allowZero ? 'non-negative' : 'positive'} number (got ${JSON.stringify(raw)})`);\n }\n (tuning[spec.key] as number) = spec.isInt ? Math.trunc(value) : value;\n }\n\n // --dpi: page-render resolution, validated like the tuning flags. Default\n // 288 is the measured operating point; >~400 measured WORSE on ordinary pages — not a \"bigger is safer\" knob.\n let dpi: number | undefined;\n if (values.dpi !== undefined) {\n const raw = values.dpi as string;\n const value = Number(raw);\n if (raw === '' || !Number.isFinite(value) || value <= 0) {\n ctx.usageError(`${USAGE}\\n--dpi requires a positive number (got ${JSON.stringify(raw)})`);\n }\n dpi = value;\n }\n\n // In --words-json mode there may be no PDF positional; the words file\n // stands in for naming, extension stripped so the default dest can never overwrite the input. Default extension follows --format.\n const source = src ?? (wordsPath as string);\n const defaultExt = format === 'raw' ? 'json' : format === 'txt' ? 'txt' : 'md';\n const dest = outArg || `${source.replace(/\\.(pdf|jsonl)$/i, '')}.${defaultExt}`;\n\n const onWarning = (m: string) => console.error(m);\n const showProgress = process.stderr.isTTY;\n // onProgress carries per-page timing/count only; human-readable\n // diagnostics (e.g. the sparse-retry notice) arrive via onWarning instead, so they print regardless of TTY-ness.\n const onProgress = (e: { type: 'page'; page: number; words: number; ms: number }) => {\n if (showProgress) console.error(`p${e.page}: ${e.words} words, ${e.ms}ms`);\n };\n const debugWordsPath = values['debug-words'] as string | undefined;\n if (debugWordsPath !== undefined && debugWordsPath.trim() === '') {\n ctx.usageError(`${USAGE}\\n--debug-words requires a value: --debug-words=FILE`);\n }\n // The severity-1 audit instrument: every recognized word as clean JSON\n // lines to its own file. stderr stays a human channel (mixed prose), never a dump target — this file is guaranteed byte-for-byte parseable.\n const onWords = debugWordsPath\n ? (words: OcrWordInput[]) => {\n const lines = words.map((w) => {\n const entry: OcrWordInput = { page: w.page, text: w.text, x: w.x, y: w.y, w: w.w, h: w.h };\n if (w.confidence !== undefined) entry.confidence = w.confidence;\n return JSON.stringify(entry);\n });\n writeFileSync(debugWordsPath, lines.length ? `${lines.join('\\n')}\\n` : '');\n }\n : undefined;\n\n const common = { pages, onWarning };\n const ocrCommon = {\n ...common,\n tuning,\n dpi,\n onProgress,\n onWords,\n };\n\n let words: OcrWordInput[] | undefined;\n let skipped = 0;\n if (wordsPath !== undefined) {\n ({ words, skipped } = parseWordLines(readFileSync(wordsPath, 'utf8')));\n if (skipped > 0) console.error(`--words-json: skipped ${skipped} non-JSON line(s)`);\n }\n\n let content: string;\n let report: Report;\n if (format === 'md') {\n // Unchanged path: extractOcr/pdfToMarkdown directly, exactly as before\n // --format existed.\n const { extractOcr, pdfToMarkdown } = await import('../extract.ts');\n let markdown: string;\n if (words !== undefined) {\n ({ markdown, report } = await extractOcr({ words }, ocrCommon));\n } else {\n ({ markdown, report } = await pdfToMarkdown(src, {\n ...ocrCommon,\n ocr: values.ocr as boolean,\n noOcr: values['no-ocr'] as boolean,\n pageMarkers: values['page-markers'] as boolean,\n }));\n }\n content = markdown;\n } else {\n // raw/txt: both render from an Analysis — raw IS the Analysis as JSON;\n // txt is toText(analysis). Mirrors pdfToMarkdown's own auto-OCR fallback decision so a different --format doesn't silently pick a different path.\n const { analyze } = await import('../analyze.ts');\n const { toText } = await import('../render-analysis.ts');\n const { needsOcrFallback, ocrFallbackNotice } = await import('../extract.ts');\n let analysis: Analysis;\n if (words !== undefined) {\n analysis = await analyze({ words }, { ...ocrCommon, path: 'ocr' });\n } else if (values.ocr) {\n analysis = await analyze(src, { ...ocrCommon, path: 'ocr' });\n } else {\n const text = await analyze(src, { ...common, path: 'text', pageMarkers: values['page-markers'] as boolean });\n if (needsOcrFallback(text.report.charsPerPage) && !values['no-ocr']) {\n onWarning(ocrFallbackNotice(text.report.charsPerPage));\n analysis = await analyze(src, { ...ocrCommon, path: 'ocr', fallback: true });\n } else {\n analysis = text;\n }\n }\n report = analysis.report;\n content = format === 'raw' ? JSON.stringify(analysis, null, 1) : toText(analysis);\n }\n\n if (values.stdout) process.stdout.write(content);\n else writeFileSync(dest, content);\n\n // The library's Report stays clean of source/out; --json consumers keep\n // report.json files around and need to know which input produced each one, so the CLI (only) decorates the printed JSON with source/out here.\n if (values.json) console.log(JSON.stringify({ source, out: dest, ...report }, null, 1));\n else if (report.path === 'ocr') {\n console.error(`${path.basename(dest).padEnd(32)} OCR path heads=${report.headings}(junk ${report.junkHeadings}) ` + `paras=${report.paragraphs} callouts=${report.callouts} floats=${report.floats ?? 0} dangling=${report.danglingLong} (long) ` + `~${report.charsPerPage} chars/page`);\n } else {\n console.error(\n `${path.basename(dest).padEnd(32)} body=${report.bodyFontHeight}pt heads=${report.headings}(junk ${report.junkHeadings}) ` +\n `lists=${report.listItems} paras=${report.paragraphs} callouts=${report.callouts} pairs=${report.joinedPairs} ` +\n `~${report.charsPerPage} chars/page` +\n (report.sparse ? ' ⚠️ implausibly sparse — pages are likely images; re-run with --ocr' : '')\n );\n }\n};\n\n// Parse one word-dump JSON line per word — key order is not guaranteed, parse\n// never grep. Non-JSON lines are skipped with a count, not fatal (the auditor applies the same policy).\nfunction parseWordLines(raw: string): { words: OcrWordInput[]; skipped: number } {\n const words: OcrWordInput[] = [];\n let skipped = 0;\n for (const line of raw.split('\\n')) {\n if (!line.trim()) continue;\n try {\n words.push(JSON.parse(line));\n } catch {\n skipped++;\n }\n }\n return { words, skipped };\n}\n\nexport default extract;\n"],"names":["USAGE","FORMATS","TUNING_FLAGS","name","key","allowZero","isInt","extract","ctx","parsed","values","positionals","src","outArg","wordsPath","formatRaw","format","pages","m","first","last","tuning","spec","raw","value","ok","dpi","source","defaultExt","dest","onWarning","showProgress","onProgress","debugWordsPath","onWords","common","ocrCommon","words","skipped","content","report","extractOcr","pdfToMarkdown","markdown","analyze","toText","needsOcrFallback","ocrFallbackNotice","analysis","text","rest","includes","usageError","parseArgs","args","options","json","type","default","ocr","stdout","help","short","Object","fromEntries","map","f","allowPositionals","err","message","console","log","JSON","join","stringify","undefined","exec","Number","NaN","isFinite","Math","trunc","replace","error","process","stderr","isTTY","e","page","ms","trim","lines","w","entry","x","y","h","confidence","writeFileSync","length","parseWordLines","readFileSync","noOcr","pageMarkers","path","charsPerPage","fallback","write","out","basename","padEnd","headings","junkHeadings","paragraphs","callouts","floats","danglingLong","bodyFontHeight","listItems","joinedPairs","sparse","split","line","push","parse"],"mappings":"AAAA,2EAA2E;AAC3E,qHAAqH;;;;;+BA6PrH;;;eAAA;;;sBA5P4C;+DAC3B;wBACS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAM1B,IAAMA,QACJ,iGACA,yEACA,8GACA,8FACA,oDACA,uGACA;AAEF,IAAMC,UAAU;IAAC;IAAM;IAAO;CAAM;AAGpC,mHAAmH;AACnH,IAAMC,eAKA;IACJ;QACEC,MAAM;QACNC,KAAK;QACLC,WAAW;QACXC,OAAO;IACT;IACA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,6BAAA;gBAAA;;;gBAAA;sBAAA;;;;IAQL,OAAO;QAAED,OAAAA;QAAOC,SAAAA;IAAQ;AAC1B;IAEA,WAAe/B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "COMMANDS", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return COMMANDS;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
12
|
+
if (typeof WeakMap !== "function") return null;
|
|
13
|
+
var cacheBabelInterop = new WeakMap();
|
|
14
|
+
var cacheNodeInterop = new WeakMap();
|
|
15
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
16
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
17
|
+
})(nodeInterop);
|
|
18
|
+
}
|
|
19
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
20
|
+
if (!nodeInterop && obj && obj.__esModule) return obj;
|
|
21
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
|
|
22
|
+
default: obj
|
|
23
|
+
};
|
|
24
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
25
|
+
if (cache && cache.has(obj)) return cache.get(obj);
|
|
26
|
+
var newObj = {
|
|
27
|
+
__proto__: null
|
|
28
|
+
};
|
|
29
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
30
|
+
for(var key in obj){
|
|
31
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
32
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
33
|
+
if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
|
|
34
|
+
else newObj[key] = obj[key];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
newObj.default = obj;
|
|
38
|
+
if (cache) cache.set(obj, newObj);
|
|
39
|
+
return newObj;
|
|
40
|
+
}
|
|
41
|
+
var COMMANDS = {
|
|
42
|
+
extract: function extract() {
|
|
43
|
+
return Promise.resolve().then(function() {
|
|
44
|
+
return /*#__PURE__*/ _interop_require_wildcard(require("./extract.js"));
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
render: function render() {
|
|
48
|
+
return Promise.resolve().then(function() {
|
|
49
|
+
return /*#__PURE__*/ _interop_require_wildcard(require("./render.js"));
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
audit: function audit() {
|
|
53
|
+
return Promise.resolve().then(function() {
|
|
54
|
+
return /*#__PURE__*/ _interop_require_wildcard(require("./audit.js"));
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Projects/pdf-to-md/src/cli/index.ts"],"sourcesContent":["import type { Command } from './types.ts';\n\n// Lazy registry: a command's imports load only when it runs. These names are\n// reserved — a PDF literally named `extract`/`render` (no extension) needs a ./ prefix.\nexport const COMMANDS: Record<string, () => Promise<{ default: Command }>> = {\n extract: () => import('./extract.ts'),\n render: () => import('./render.ts'),\n audit: () => import('./audit.ts'),\n};\n\nexport type { Command, Ctx } from './types.ts';\n"],"names":["COMMANDS","extract","render","audit"],"mappings":";;;;+BAIaA;;;eAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAN,IAAMA,WAAgE;IAC3EC,SAAS,SAATA;eAAe;2DAAA,QAAO;;;IACtBC,QAAQ,SAARA;eAAc;2DAAA,QAAO;;;IACrBC,OAAO,SAAPA;eAAa;2DAAA,QAAO;;;AACtB"}
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
// render command — render PDF pages to PNG for human/vision-model
|
|
2
|
+
// verification (extraction output is a claim; the page itself is the truth). Thin wrapper: parse flags, call src/raster.ts, write files.
|
|
3
|
+
"use strict";
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "default", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function() {
|
|
10
|
+
return _default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _nodefs = require("node:fs");
|
|
14
|
+
var _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
15
|
+
var _nodeutil = require("node:util");
|
|
16
|
+
var _errorsts = require("../errors.js");
|
|
17
|
+
function _array_like_to_array(arr, len) {
|
|
18
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
19
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
20
|
+
return arr2;
|
|
21
|
+
}
|
|
22
|
+
function _array_with_holes(arr) {
|
|
23
|
+
if (Array.isArray(arr)) return arr;
|
|
24
|
+
}
|
|
25
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
26
|
+
try {
|
|
27
|
+
var info = gen[key](arg);
|
|
28
|
+
var value = info.value;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
reject(error);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (info.done) resolve(value);
|
|
34
|
+
else Promise.resolve(value).then(_next, _throw);
|
|
35
|
+
}
|
|
36
|
+
function _async_to_generator(fn) {
|
|
37
|
+
return function() {
|
|
38
|
+
var self = this, args = arguments;
|
|
39
|
+
return new Promise(function(resolve, reject) {
|
|
40
|
+
var gen = fn.apply(self, args);
|
|
41
|
+
function _next(value) {
|
|
42
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
43
|
+
}
|
|
44
|
+
function _throw(err) {
|
|
45
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
46
|
+
}
|
|
47
|
+
_next(undefined);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function _interop_require_default(obj) {
|
|
52
|
+
return obj && obj.__esModule ? obj : {
|
|
53
|
+
default: obj
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
57
|
+
if (typeof WeakMap !== "function") return null;
|
|
58
|
+
var cacheBabelInterop = new WeakMap();
|
|
59
|
+
var cacheNodeInterop = new WeakMap();
|
|
60
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
61
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
62
|
+
})(nodeInterop);
|
|
63
|
+
}
|
|
64
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
65
|
+
if (!nodeInterop && obj && obj.__esModule) return obj;
|
|
66
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
|
|
67
|
+
default: obj
|
|
68
|
+
};
|
|
69
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
70
|
+
if (cache && cache.has(obj)) return cache.get(obj);
|
|
71
|
+
var newObj = {
|
|
72
|
+
__proto__: null
|
|
73
|
+
};
|
|
74
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
75
|
+
for(var key in obj){
|
|
76
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
77
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
78
|
+
if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);
|
|
79
|
+
else newObj[key] = obj[key];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
newObj.default = obj;
|
|
83
|
+
if (cache) cache.set(obj, newObj);
|
|
84
|
+
return newObj;
|
|
85
|
+
}
|
|
86
|
+
function _iterable_to_array_limit(arr, i) {
|
|
87
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
88
|
+
if (_i == null) return;
|
|
89
|
+
var _arr = [];
|
|
90
|
+
var _n = true;
|
|
91
|
+
var _d = false;
|
|
92
|
+
var _s, _e;
|
|
93
|
+
try {
|
|
94
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
95
|
+
_arr.push(_s.value);
|
|
96
|
+
if (i && _arr.length === i) break;
|
|
97
|
+
}
|
|
98
|
+
} catch (err) {
|
|
99
|
+
_d = true;
|
|
100
|
+
_e = err;
|
|
101
|
+
} finally{
|
|
102
|
+
try {
|
|
103
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
104
|
+
} finally{
|
|
105
|
+
if (_d) throw _e;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return _arr;
|
|
109
|
+
}
|
|
110
|
+
function _non_iterable_rest() {
|
|
111
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
112
|
+
}
|
|
113
|
+
function _sliced_to_array(arr, i) {
|
|
114
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
115
|
+
}
|
|
116
|
+
function _ts_generator(thisArg, body) {
|
|
117
|
+
var f, y, t, _ = {
|
|
118
|
+
label: 0,
|
|
119
|
+
sent: function() {
|
|
120
|
+
if (t[0] & 1) throw t[1];
|
|
121
|
+
return t[1];
|
|
122
|
+
},
|
|
123
|
+
trys: [],
|
|
124
|
+
ops: []
|
|
125
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
126
|
+
return d(g, "next", {
|
|
127
|
+
value: verb(0)
|
|
128
|
+
}), d(g, "throw", {
|
|
129
|
+
value: verb(1)
|
|
130
|
+
}), d(g, "return", {
|
|
131
|
+
value: verb(2)
|
|
132
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
133
|
+
value: function() {
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
136
|
+
}), g;
|
|
137
|
+
function verb(n) {
|
|
138
|
+
return function(v) {
|
|
139
|
+
return step([
|
|
140
|
+
n,
|
|
141
|
+
v
|
|
142
|
+
]);
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function step(op) {
|
|
146
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
147
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
148
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
149
|
+
if (y = 0, t) op = [
|
|
150
|
+
op[0] & 2,
|
|
151
|
+
t.value
|
|
152
|
+
];
|
|
153
|
+
switch(op[0]){
|
|
154
|
+
case 0:
|
|
155
|
+
case 1:
|
|
156
|
+
t = op;
|
|
157
|
+
break;
|
|
158
|
+
case 4:
|
|
159
|
+
_.label++;
|
|
160
|
+
return {
|
|
161
|
+
value: op[1],
|
|
162
|
+
done: false
|
|
163
|
+
};
|
|
164
|
+
case 5:
|
|
165
|
+
_.label++;
|
|
166
|
+
y = op[1];
|
|
167
|
+
op = [
|
|
168
|
+
0
|
|
169
|
+
];
|
|
170
|
+
continue;
|
|
171
|
+
case 7:
|
|
172
|
+
op = _.ops.pop();
|
|
173
|
+
_.trys.pop();
|
|
174
|
+
continue;
|
|
175
|
+
default:
|
|
176
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
177
|
+
_ = 0;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
181
|
+
_.label = op[1];
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
185
|
+
_.label = t[1];
|
|
186
|
+
t = op;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
if (t && _.label < t[2]) {
|
|
190
|
+
_.label = t[2];
|
|
191
|
+
_.ops.push(op);
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
if (t[2]) _.ops.pop();
|
|
195
|
+
_.trys.pop();
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
op = body.call(thisArg, _);
|
|
199
|
+
} catch (e) {
|
|
200
|
+
op = [
|
|
201
|
+
6,
|
|
202
|
+
e
|
|
203
|
+
];
|
|
204
|
+
y = 0;
|
|
205
|
+
} finally{
|
|
206
|
+
f = t = 0;
|
|
207
|
+
}
|
|
208
|
+
if (op[0] & 5) throw op[1];
|
|
209
|
+
return {
|
|
210
|
+
value: op[0] ? op[1] : void 0,
|
|
211
|
+
done: true
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
216
|
+
if (!o) return;
|
|
217
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
218
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
219
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
220
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
221
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
222
|
+
}
|
|
223
|
+
var USAGE = 'usage: pdf-to-md render <file.pdf> <page>[-<page>] [--dpi|-d N (default 288)] [--out|-o DIR (default .)]';
|
|
224
|
+
var render = function render(ctx) {
|
|
225
|
+
return _async_to_generator(function() {
|
|
226
|
+
var _values_out, parsed, values, positionals, _positionals, pdfPath, spec, m, firstPage, lastPage, dpi, outDir, stem, _ref, awaitPdfOpen, openPdfForRender, renderLoadedPage, loadingTask, doc, n, png, outPath;
|
|
227
|
+
return _ts_generator(this, function(_state) {
|
|
228
|
+
switch(_state.label){
|
|
229
|
+
case 0:
|
|
230
|
+
parsed = function() {
|
|
231
|
+
try {
|
|
232
|
+
return (0, _nodeutil.parseArgs)({
|
|
233
|
+
args: ctx.rest,
|
|
234
|
+
options: {
|
|
235
|
+
dpi: {
|
|
236
|
+
type: 'string',
|
|
237
|
+
default: '288',
|
|
238
|
+
short: 'd'
|
|
239
|
+
},
|
|
240
|
+
out: {
|
|
241
|
+
type: 'string',
|
|
242
|
+
short: 'o'
|
|
243
|
+
},
|
|
244
|
+
help: {
|
|
245
|
+
type: 'boolean',
|
|
246
|
+
default: false,
|
|
247
|
+
short: 'h'
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
allowPositionals: true
|
|
251
|
+
});
|
|
252
|
+
} catch (err) {
|
|
253
|
+
// usageError exits; the throw is dead code that tells the compiler so.
|
|
254
|
+
throw ctx.usageError("".concat(err.message, "\n").concat(USAGE));
|
|
255
|
+
}
|
|
256
|
+
}();
|
|
257
|
+
values = parsed.values, positionals = parsed.positionals;
|
|
258
|
+
if (values.help) {
|
|
259
|
+
console.log(USAGE);
|
|
260
|
+
return [
|
|
261
|
+
2
|
|
262
|
+
];
|
|
263
|
+
}
|
|
264
|
+
_positionals = _sliced_to_array(positionals, 2), pdfPath = _positionals[0], spec = _positionals[1];
|
|
265
|
+
if (!pdfPath || !spec) ctx.usageError(USAGE);
|
|
266
|
+
m = /^(\d+)(?:-(\d+))?$/.exec(spec);
|
|
267
|
+
if (m === null) throw ctx.usageError("".concat(USAGE, "\ncould not parse page spec: ").concat(spec));
|
|
268
|
+
firstPage = Number(m[1]);
|
|
269
|
+
lastPage = m[2] !== undefined ? Number(m[2]) : firstPage;
|
|
270
|
+
if (!(firstPage >= 1) || !(lastPage >= firstPage)) throw ctx.usageError("".concat(USAGE, "\ninvalid page spec: ").concat(spec));
|
|
271
|
+
dpi = Number.parseFloat(values.dpi);
|
|
272
|
+
if (!(dpi > 0)) ctx.usageError("".concat(USAGE, "\n--dpi must be positive"));
|
|
273
|
+
outDir = (_values_out = values.out) !== null && _values_out !== void 0 ? _values_out : process.cwd();
|
|
274
|
+
(0, _nodefs.mkdirSync)(outDir, {
|
|
275
|
+
recursive: true
|
|
276
|
+
});
|
|
277
|
+
stem = _nodepath.default.basename(pdfPath, _nodepath.default.extname(pdfPath)).replaceAll(' ', '-');
|
|
278
|
+
return [
|
|
279
|
+
4,
|
|
280
|
+
Promise.resolve().then(function() {
|
|
281
|
+
return /*#__PURE__*/ _interop_require_wildcard(require("../pdf-open.js"));
|
|
282
|
+
})
|
|
283
|
+
];
|
|
284
|
+
case 1:
|
|
285
|
+
_ref = _state.sent(), awaitPdfOpen = _ref.awaitPdfOpen, openPdfForRender = _ref.openPdfForRender;
|
|
286
|
+
return [
|
|
287
|
+
4,
|
|
288
|
+
Promise.resolve().then(function() {
|
|
289
|
+
return /*#__PURE__*/ _interop_require_wildcard(require("../raster.js"));
|
|
290
|
+
})
|
|
291
|
+
];
|
|
292
|
+
case 2:
|
|
293
|
+
renderLoadedPage = _state.sent().renderLoadedPage;
|
|
294
|
+
loadingTask = openPdfForRender(pdfPath);
|
|
295
|
+
_state.label = 3;
|
|
296
|
+
case 3:
|
|
297
|
+
_state.trys.push([
|
|
298
|
+
3,
|
|
299
|
+
,
|
|
300
|
+
9,
|
|
301
|
+
11
|
|
302
|
+
]);
|
|
303
|
+
return [
|
|
304
|
+
4,
|
|
305
|
+
awaitPdfOpen(loadingTask, pdfPath)
|
|
306
|
+
];
|
|
307
|
+
case 4:
|
|
308
|
+
doc = _state.sent();
|
|
309
|
+
// Whole-range check before any file is written, so a partly-valid range
|
|
310
|
+
// fails atomically; renderLoadedPage re-validates per page.
|
|
311
|
+
if (lastPage > doc.numPages) {
|
|
312
|
+
throw new _errorsts.PdfToMdError('PAGE_RANGE', "page range ".concat(firstPage, "-").concat(lastPage, " is outside this document (1-").concat(doc.numPages, ")"));
|
|
313
|
+
}
|
|
314
|
+
n = firstPage;
|
|
315
|
+
_state.label = 5;
|
|
316
|
+
case 5:
|
|
317
|
+
if (!(n <= lastPage)) return [
|
|
318
|
+
3,
|
|
319
|
+
8
|
|
320
|
+
];
|
|
321
|
+
return [
|
|
322
|
+
4,
|
|
323
|
+
renderLoadedPage(doc, n, dpi)
|
|
324
|
+
];
|
|
325
|
+
case 6:
|
|
326
|
+
png = _state.sent().png;
|
|
327
|
+
outPath = _nodepath.default.join(outDir, "".concat(stem, "-p").concat(n, ".png"));
|
|
328
|
+
(0, _nodefs.writeFileSync)(outPath, png);
|
|
329
|
+
console.log(outPath);
|
|
330
|
+
_state.label = 7;
|
|
331
|
+
case 7:
|
|
332
|
+
n++;
|
|
333
|
+
return [
|
|
334
|
+
3,
|
|
335
|
+
5
|
|
336
|
+
];
|
|
337
|
+
case 8:
|
|
338
|
+
return [
|
|
339
|
+
3,
|
|
340
|
+
11
|
|
341
|
+
];
|
|
342
|
+
case 9:
|
|
343
|
+
return [
|
|
344
|
+
4,
|
|
345
|
+
loadingTask.destroy()
|
|
346
|
+
];
|
|
347
|
+
case 10:
|
|
348
|
+
_state.sent();
|
|
349
|
+
return [
|
|
350
|
+
7
|
|
351
|
+
];
|
|
352
|
+
case 11:
|
|
353
|
+
return [
|
|
354
|
+
2
|
|
355
|
+
];
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
})();
|
|
359
|
+
};
|
|
360
|
+
var _default = render;
|
|
361
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Projects/pdf-to-md/src/cli/render.ts"],"sourcesContent":["// render command — render PDF pages to PNG for human/vision-model\n// verification (extraction output is a claim; the page itself is the truth). Thin wrapper: parse flags, call src/raster.ts, write files.\nimport { mkdirSync, writeFileSync } from 'node:fs';\nimport path from 'node:path';\nimport { parseArgs } from 'node:util';\nimport { PdfToMdError } from '../errors.ts';\nimport type { Command } from './types.ts';\n\nconst USAGE = 'usage: pdf-to-md render <file.pdf> <page>[-<page>] [--dpi|-d N (default 288)] [--out|-o DIR (default .)]';\n\nconst render: Command = async (ctx) => {\n const parsed = (() => {\n try {\n return parseArgs({\n args: ctx.rest,\n options: {\n dpi: { type: 'string', default: '288', short: 'd' },\n out: { type: 'string', short: 'o' },\n help: { type: 'boolean', default: false, short: 'h' },\n },\n allowPositionals: true,\n });\n } catch (err) {\n // usageError exits; the throw is dead code that tells the compiler so.\n throw ctx.usageError(`${(err as Error).message}\\n${USAGE}`);\n }\n })();\n const { values, positionals } = parsed;\n\n if (values.help) {\n console.log(USAGE);\n return;\n }\n\n const [pdfPath, spec] = positionals;\n if (!pdfPath || !spec) ctx.usageError(USAGE);\n\n const m = /^(\\d+)(?:-(\\d+))?$/.exec(spec);\n if (m === null) throw ctx.usageError(`${USAGE}\\ncould not parse page spec: ${spec}`);\n const firstPage = Number(m[1]);\n const lastPage = m[2] !== undefined ? Number(m[2]) : firstPage;\n if (!(firstPage >= 1) || !(lastPage >= firstPage)) throw ctx.usageError(`${USAGE}\\ninvalid page spec: ${spec}`);\n\n const dpi = Number.parseFloat(values.dpi as string);\n if (!(dpi > 0)) ctx.usageError(`${USAGE}\\n--dpi must be positive`);\n\n const outDir = values.out ?? process.cwd();\n mkdirSync(outDir, { recursive: true });\n const stem = path.basename(pdfPath, path.extname(pdfPath)).replaceAll(' ', '-');\n\n // Imported here, not at module top: keeps pdfjs/canvas out of every other command's startup.\n const { awaitPdfOpen, openPdfForRender } = await import('../pdf-open.ts');\n const { renderLoadedPage } = await import('../raster.ts');\n const loadingTask = openPdfForRender(pdfPath);\n try {\n const doc = await awaitPdfOpen(loadingTask, pdfPath);\n\n // Whole-range check before any file is written, so a partly-valid range\n // fails atomically; renderLoadedPage re-validates per page.\n if (lastPage > doc.numPages) {\n throw new PdfToMdError('PAGE_RANGE', `page range ${firstPage}-${lastPage} is outside this document (1-${doc.numPages})`);\n }\n for (let n = firstPage; n <= lastPage; n++) {\n const { png } = await renderLoadedPage(doc, n, dpi);\n const outPath = path.join(outDir, `${stem}-p${n}.png`);\n writeFileSync(outPath, png);\n console.log(outPath);\n }\n } finally {\n await loadingTask.destroy();\n }\n};\n\nexport default render;\n"],"names":["USAGE","render","ctx","values","parsed","positionals","pdfPath","spec","m","firstPage","lastPage","dpi","outDir","stem","awaitPdfOpen","openPdfForRender","renderLoadedPage","loadingTask","doc","n","png","outPath","parseArgs","args","rest","options","type","default","short","out","help","allowPositionals","err","usageError","message","console","log","exec","Number","undefined","parseFloat","process","cwd","mkdirSync","recursive","path","basename","extname","replaceAll","numPages","PdfToMdError","join","writeFileSync","destroy"],"mappings":"AAAA,kEAAkE;AAClE,yIAAyI;;;;;+BAwEzI;;;eAAA;;;sBAvEyC;+DACxB;wBACS;wBACG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG7B,IAAMA,QAAQ;AAEd,IAAMC,SAAkB,gBAAOC;;YAoCdC,aAnCTC,QAgBED,QAAQE,aAOQA,cAAjBC,SAASC,MAGVC,GAEAC,WACAC,UAGAC,KAGAC,QAEAC,MAGqC,MAAnCC,cAAcC,kBACdC,kBACFC,aAEEC,KAOGC,GACCC,KACFC;;;;oBArDJjB,SAAS,AAAC;wBACd,IAAI;4BACF,OAAOkB,IAAAA,mBAAS,EAAC;gCACfC,MAAMrB,IAAIsB,IAAI;gCACdC,SAAS;oCACPd,KAAK;wCAAEe,MA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BAAS,EAAC/B,QAAQ;wBAAEgC,WAAW;oBAAK;oBAC9B/B,OAAOgC,iBAAI,CAACC,QAAQ,CAACxC,SAASuC,iBAAI,CAACE,OAAO,CAACzC,UAAU0C,UAAU,CAAC,KAAK;oBAGhC;;wBAAM;2EAAA,QAAO;;;;oBAAb,OAAA,eAAnClC,eAAmC,KAAnCA,cAAcC,mBAAqB,KAArBA;oBACO;;wBAAM;2EAAA,QAAO;;;;oBAAlCC,mBAAqB,cAArBA;oBACFC,cAAcF,iBAAiBT;;;;;;;;;oBAEvB;;wBAAMQ,aAAaG,aAAaX;;;oBAAtCY,MAAM;oBAEZ,wEAAwE;oBACxE,4DAA4D;oBAC5D,IAAIR,WAAWQ,IAAI+B,QAAQ,EAAE;wBAC3B,MAAM,IAAIC,sBAAY,CAAC,cAAc,AAAC,cAA0BxC,OAAbD,WAAU,KAA2CS,OAAxCR,UAAS,iCAA4C,OAAbQ,IAAI+B,QAAQ,EAAC;oBACvH;oBACS9B,IAAIV;;;yBAAWU,CAAAA,KAAKT,QAAO;;;;oBAClB;;wBAAMM,iBAAiBE,KAAKC,GAAGR;;;oBAAvCS,MAAQ,cAARA;oBACFC,UAAUwB,iBAAI,CAACM,IAAI,CAACvC,QAAQ,AAAC,GAAWO,OAATN,MAAK,MAAM,OAAFM,GAAE;oBAChDiC,IAAAA,qBAAa,EAAC/B,SAASD;oBACvBe,QAAQC,GAAG,CAACf;;;oBAJyBF;;;;;;;;;;;oBAOvC;;wBAAMF,YAAYoC,OAAO;;;oBAAzB;;;;;;;;;;IAEJ;;IAEA,WAAepD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface Ctx {
|
|
2
|
+
/** binary name, for usage strings */
|
|
3
|
+
name: string;
|
|
4
|
+
/** argv after the command word */
|
|
5
|
+
rest: string[];
|
|
6
|
+
/** print the message and exit 2 — every malformed-invocation path.
|
|
7
|
+
* Readonly property (not method) syntax: TS only applies never-return control-flow analysis to readonly property-typed function members. */
|
|
8
|
+
readonly usageError: (message: string) => never;
|
|
9
|
+
}
|
|
10
|
+
export type Command = (ctx: Ctx) => Promise<void> | void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface Ctx {
|
|
2
|
+
/** binary name, for usage strings */
|
|
3
|
+
name: string;
|
|
4
|
+
/** argv after the command word */
|
|
5
|
+
rest: string[];
|
|
6
|
+
/** print the message and exit 2 — every malformed-invocation path.
|
|
7
|
+
* Readonly property (not method) syntax: TS only applies never-return control-flow analysis to readonly property-typed function members. */
|
|
8
|
+
readonly usageError: (message: string) => never;
|
|
9
|
+
}
|
|
10
|
+
export type Command = (ctx: Ctx) => Promise<void> | void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Handed to every command; the command word is peeled off in src/cli.ts and
|
|
2
|
+
// each command owns its own parseArgs table over `rest` (our commands' flags are disjoint, so a shared table would let `render --para-gap=2` parse silently as a no-op).
|
|
3
|
+
"use strict";
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Projects/pdf-to-md/src/cli/types.ts"],"sourcesContent":["// Handed to every command; the command word is peeled off in src/cli.ts and\n// each command owns its own parseArgs table over `rest` (our commands' flags are disjoint, so a shared table would let `render --para-gap=2` parse silently as a no-op).\nexport interface Ctx {\n /** binary name, for usage strings */\n name: string;\n /** argv after the command word */\n rest: string[];\n /** print the message and exit 2 — every malformed-invocation path.\n * Readonly property (not method) syntax: TS only applies never-return control-flow analysis to readonly property-typed function members. */\n readonly usageError: (message: string) => never;\n}\n\nexport type Command = (ctx: Ctx) => Promise<void> | void;\n"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,yKAAyK"}
|