kordoc 4.0.5 → 4.0.7

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.
Files changed (109) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +806 -800
  3. package/dist/{-QVHGOOCR.js → -6HWEFXVV.js} +9 -9
  4. package/dist/{chunk-6PED5OOG.js → chunk-2SN3CKME.js} +2 -2
  5. package/dist/chunk-2SN3CKME.js.map +1 -0
  6. package/dist/{chunk-MOL7MDBG.js → chunk-3TBUDJDE.js} +1 -1
  7. package/dist/chunk-3TBUDJDE.js.map +1 -0
  8. package/dist/{chunk-FKK4K53F.js → chunk-5OKHAJ62.js} +2 -2
  9. package/dist/chunk-5OKHAJ62.js.map +1 -0
  10. package/dist/{chunk-5RPYBC2Q.js → chunk-6GBLFQMA.js} +1 -1
  11. package/dist/chunk-6GBLFQMA.js.map +1 -0
  12. package/dist/{chunk-GE43BE46.js → chunk-AIQ3ISQU.js} +1 -1
  13. package/dist/chunk-AIQ3ISQU.js.map +1 -0
  14. package/dist/{chunk-OMERK4AW.js → chunk-BKWHX3RC.js} +3 -3
  15. package/dist/chunk-BKWHX3RC.js.map +1 -0
  16. package/dist/{chunk-MEPHGCPQ.js → chunk-CFQLK3LM.js} +1 -1
  17. package/dist/chunk-CFQLK3LM.js.map +1 -0
  18. package/dist/{chunk-6BABRVOJ.js → chunk-CNM75ZSX.js} +2 -2
  19. package/dist/chunk-CNM75ZSX.js.map +1 -0
  20. package/dist/chunk-GS7T56RP.cjs.map +1 -1
  21. package/dist/{chunk-6WDPB4SN.js → chunk-NGSHDBQR.js} +3 -3
  22. package/dist/chunk-NGSHDBQR.js.map +1 -0
  23. package/dist/{chunk-ZGMMLYAL.js → chunk-ONXVBURQ.js} +2 -2
  24. package/dist/chunk-ONXVBURQ.js.map +1 -0
  25. package/dist/{chunk-QK2G34WE.js → chunk-Q7EN4EUJ.js} +2 -2
  26. package/dist/chunk-Q7EN4EUJ.js.map +1 -0
  27. package/dist/{chunk-Z6Q3YG22.js → chunk-TJJTLM76.js} +197 -98
  28. package/dist/chunk-TJJTLM76.js.map +1 -0
  29. package/dist/{chunk-6R5FY47W.cjs → chunk-U25XGCNH.cjs} +2 -2
  30. package/dist/chunk-U25XGCNH.cjs.map +1 -0
  31. package/dist/{chunk-DCZVOIEO.cjs → chunk-X34YWRL5.cjs} +1 -1
  32. package/dist/chunk-X34YWRL5.cjs.map +1 -0
  33. package/dist/cli.js +18 -18
  34. package/dist/cli.js.map +1 -1
  35. package/dist/{detect-RI2MQ33K.js → detect-NTR2FUEG.js} +2 -2
  36. package/dist/{formula-JCNF43NE.js → formula-KOQV353G.js} +1 -1
  37. package/dist/formula-KOQV353G.js.map +1 -0
  38. package/dist/{formula-RXVSQPXI.js → formula-MEDGYQXS.js} +1 -1
  39. package/dist/formula-MEDGYQXS.js.map +1 -0
  40. package/dist/{formula-5NKVS2LR.cjs → formula-ZYUDQHD3.cjs} +1 -1
  41. package/dist/formula-ZYUDQHD3.cjs.map +1 -0
  42. package/dist/index.cjs +328 -229
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.js +191 -92
  45. package/dist/index.js.map +1 -1
  46. package/dist/mcp.js +14 -14
  47. package/dist/mcp.js.map +1 -1
  48. package/dist/page-range-CIRRJPXJ.js +7 -0
  49. package/dist/page-range-OF5I4PQY.js +8 -0
  50. package/dist/page-range-TPIRSA3J.cjs +8 -0
  51. package/dist/page-range-TPIRSA3J.cjs.map +1 -0
  52. package/dist/{parser-3MAYZUJX.js → parser-5EHWYJMC.js} +93 -7
  53. package/dist/parser-5EHWYJMC.js.map +1 -0
  54. package/dist/{parser-2V5SPTU7.cjs → parser-E6U5TNAU.cjs} +105 -19
  55. package/dist/parser-E6U5TNAU.cjs.map +1 -0
  56. package/dist/{parser-YSHZC5FQ.js → parser-UGB3NIVH.js} +92 -6
  57. package/dist/parser-UGB3NIVH.js.map +1 -0
  58. package/dist/{profile-io-3EECPDHG.js → profile-io-CAKRPQRD.js} +3 -3
  59. package/dist/{provider-G4C2V2PD.cjs → provider-5K7O3Z2O.cjs} +1 -1
  60. package/dist/provider-5K7O3Z2O.cjs.map +1 -0
  61. package/dist/{provider-AKROB7WQ.js → provider-7H4CPZYS.js} +1 -1
  62. package/dist/provider-7H4CPZYS.js.map +1 -0
  63. package/dist/{provider-4ZJKV3DC.js → provider-H4WWSPOV.js} +1 -1
  64. package/dist/provider-H4WWSPOV.js.map +1 -0
  65. package/dist/render-P6663O4I.js +10 -0
  66. package/dist/seal-7PPTXKKV.js +10 -0
  67. package/dist/{setup-57FB3LSP.js → setup-QSJ2INNS.js} +1 -1
  68. package/dist/setup-QSJ2INNS.js.map +1 -0
  69. package/dist/{watch-7MHSCKEQ.js → watch-RMX427YR.js} +9 -9
  70. package/dist/watch-RMX427YR.js.map +1 -0
  71. package/package.json +97 -97
  72. package/dist/chunk-5RPYBC2Q.js.map +0 -1
  73. package/dist/chunk-6BABRVOJ.js.map +0 -1
  74. package/dist/chunk-6PED5OOG.js.map +0 -1
  75. package/dist/chunk-6R5FY47W.cjs.map +0 -1
  76. package/dist/chunk-6WDPB4SN.js.map +0 -1
  77. package/dist/chunk-DCZVOIEO.cjs.map +0 -1
  78. package/dist/chunk-FKK4K53F.js.map +0 -1
  79. package/dist/chunk-GE43BE46.js.map +0 -1
  80. package/dist/chunk-MEPHGCPQ.js.map +0 -1
  81. package/dist/chunk-MOL7MDBG.js.map +0 -1
  82. package/dist/chunk-OMERK4AW.js.map +0 -1
  83. package/dist/chunk-QK2G34WE.js.map +0 -1
  84. package/dist/chunk-Z6Q3YG22.js.map +0 -1
  85. package/dist/chunk-ZGMMLYAL.js.map +0 -1
  86. package/dist/formula-5NKVS2LR.cjs.map +0 -1
  87. package/dist/formula-JCNF43NE.js.map +0 -1
  88. package/dist/formula-RXVSQPXI.js.map +0 -1
  89. package/dist/page-range-737B4EZW.js +0 -8
  90. package/dist/page-range-LNMXJU6W.js +0 -7
  91. package/dist/page-range-P7SDW6LR.cjs +0 -8
  92. package/dist/page-range-P7SDW6LR.cjs.map +0 -1
  93. package/dist/parser-2V5SPTU7.cjs.map +0 -1
  94. package/dist/parser-3MAYZUJX.js.map +0 -1
  95. package/dist/parser-YSHZC5FQ.js.map +0 -1
  96. package/dist/provider-4ZJKV3DC.js.map +0 -1
  97. package/dist/provider-AKROB7WQ.js.map +0 -1
  98. package/dist/provider-G4C2V2PD.cjs.map +0 -1
  99. package/dist/render-MJSQ4TG2.js +0 -10
  100. package/dist/seal-R3POFNOU.js +0 -10
  101. package/dist/setup-57FB3LSP.js.map +0 -1
  102. package/dist/watch-7MHSCKEQ.js.map +0 -1
  103. /package/dist/{-QVHGOOCR.js.map → -6HWEFXVV.js.map} +0 -0
  104. /package/dist/{detect-RI2MQ33K.js.map → detect-NTR2FUEG.js.map} +0 -0
  105. /package/dist/{page-range-737B4EZW.js.map → page-range-CIRRJPXJ.js.map} +0 -0
  106. /package/dist/{page-range-LNMXJU6W.js.map → page-range-OF5I4PQY.js.map} +0 -0
  107. /package/dist/{profile-io-3EECPDHG.js.map → profile-io-CAKRPQRD.js.map} +0 -0
  108. /package/dist/{render-MJSQ4TG2.js.map → render-P6663O4I.js.map} +0 -0
  109. /package/dist/{seal-R3POFNOU.js.map → seal-7PPTXKKV.js.map} +0 -0
package/dist/index.js CHANGED
@@ -20,10 +20,10 @@ import {
20
20
  sanitizeHref,
21
21
  stripDtd,
22
22
  toArrayBuffer
23
- } from "./chunk-FKK4K53F.js";
23
+ } from "./chunk-5OKHAJ62.js";
24
24
  import {
25
25
  parsePageRange
26
- } from "./chunk-GE43BE46.js";
26
+ } from "./chunk-AIQ3ISQU.js";
27
27
 
28
28
  // src/index.ts
29
29
  import { readFile } from "fs/promises";
@@ -2229,8 +2229,15 @@ function collectSubListText(el, ctx, depth = 0) {
2229
2229
  if (tag === "p" || tag === "para") {
2230
2230
  const t = extractParagraphInfo(ch, ctx.styleMap, ctx).text;
2231
2231
  if (t) parts.push(t);
2232
+ const tbls = [];
2233
+ findTopLevelTbls(ch, tbls);
2234
+ for (const tbl2 of tbls) {
2235
+ const flat = flattenSubListTable(tbl2, ctx, depth);
2236
+ if (flat) parts.push(flat);
2237
+ }
2232
2238
  } else if (tag === "tbl") {
2233
- continue;
2239
+ const flat = flattenSubListTable(ch, ctx, depth);
2240
+ if (flat) parts.push(flat);
2234
2241
  } else {
2235
2242
  const t = collectSubListText(ch, ctx, depth + 1);
2236
2243
  if (t) parts.push(t);
@@ -2238,6 +2245,29 @@ function collectSubListText(el, ctx, depth = 0) {
2238
2245
  }
2239
2246
  return parts.join("\n").trim();
2240
2247
  }
2248
+ function flattenSubListTable(el, ctx, depth) {
2249
+ const sink = [];
2250
+ const st = { rows: [], currentRow: [], cell: null };
2251
+ walkSection(el, sink, st, [], ctx, depth + 1);
2252
+ let flat = convertTableToText(st.rows);
2253
+ if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
2254
+ return flat;
2255
+ }
2256
+ function findTopLevelTbls(el, out, depth = 0) {
2257
+ if (depth > MAX_XML_DEPTH) return;
2258
+ const kids2 = el.childNodes;
2259
+ if (!kids2) return;
2260
+ for (let i = 0; i < kids2.length; i++) {
2261
+ const ch = kids2[i];
2262
+ if (ch.nodeType !== 1) continue;
2263
+ const tag = (ch.tagName || ch.localName || "").replace(/^[^:]+:/, "");
2264
+ if (tag === "tbl") {
2265
+ out.push(ch);
2266
+ continue;
2267
+ }
2268
+ findTopLevelTbls(ch, out, depth + 1);
2269
+ }
2270
+ }
2241
2271
  function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
2242
2272
  if (depth > MAX_XML_DEPTH) return tableCtx;
2243
2273
  const children = node.childNodes;
@@ -18027,7 +18057,7 @@ async function parseXlsxDocument(buffer, options) {
18027
18057
  }
18028
18058
  let pageFilter = null;
18029
18059
  if (options?.pages) {
18030
- const { parsePageRange: parsePageRange2 } = await import("./page-range-LNMXJU6W.js");
18060
+ const { parsePageRange: parsePageRange2 } = await import("./page-range-CIRRJPXJ.js");
18031
18061
  pageFilter = parsePageRange2(options.pages, sheets.length);
18032
18062
  }
18033
18063
  const blocks = [];
@@ -18665,7 +18695,7 @@ async function parseXlsDocument(buffer, options) {
18665
18695
  const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
18666
18696
  let pageFilter = null;
18667
18697
  if (options?.pages) {
18668
- const { parsePageRange: parsePageRange2 } = await import("./page-range-LNMXJU6W.js");
18698
+ const { parsePageRange: parsePageRange2 } = await import("./page-range-CIRRJPXJ.js");
18669
18699
  pageFilter = parsePageRange2(options.pages, totalSheets);
18670
18700
  }
18671
18701
  const allBlocks = [];
@@ -19267,6 +19297,102 @@ function extractRun(r) {
19267
19297
  }
19268
19298
  return { text, bold, italic };
19269
19299
  }
19300
+ function fieldUrlFromInstr(instr) {
19301
+ if (!/HYPERLINK\b/i.test(instr)) return null;
19302
+ const urlM = instr.match(/HYPERLINK\s+"([^"]*)"/i);
19303
+ const anchorM = instr.match(/\\l\s+"([^"]*)"/i);
19304
+ if (urlM && urlM[1]) {
19305
+ return anchorM && anchorM[1] ? `${urlM[1]}#${anchorM[1]}` : urlM[1];
19306
+ }
19307
+ if (anchorM && anchorM[1]) return `#${anchorM[1]}`;
19308
+ return null;
19309
+ }
19310
+ function makeLink(text, rawHref) {
19311
+ if (!text) return "";
19312
+ if (!rawHref) return text;
19313
+ const href = sanitizeHref(rawHref);
19314
+ return href ? `[${text}](${href})` : text;
19315
+ }
19316
+ function collectInline(p, footnotes, rels) {
19317
+ const parts = [];
19318
+ let bold = false;
19319
+ let italic = false;
19320
+ let footnoteText;
19321
+ let fieldActive = false;
19322
+ let fieldStage = "instr";
19323
+ let fieldInstr = "";
19324
+ let fieldDisplay = "";
19325
+ const flushField = () => {
19326
+ if (!fieldActive) return;
19327
+ if (fieldDisplay) {
19328
+ const url = fieldUrlFromInstr(fieldInstr);
19329
+ parts.push(url ? makeLink(fieldDisplay, url) : fieldDisplay);
19330
+ }
19331
+ fieldActive = false;
19332
+ fieldStage = "instr";
19333
+ fieldInstr = "";
19334
+ fieldDisplay = "";
19335
+ };
19336
+ for (const el of effectiveChildElements(p)) {
19337
+ if (matchesLocal(el, "hyperlink")) {
19338
+ const rId = getAttr(el, "id");
19339
+ const anchor = getAttr(el, "anchor");
19340
+ const t = findElements(el, "r").map((r) => extractRun(r).text).join("");
19341
+ if (!t) continue;
19342
+ let raw = null;
19343
+ if (rId && rels.has(rId)) raw = rels.get(rId);
19344
+ else if (anchor) raw = `#${anchor}`;
19345
+ if (fieldActive && fieldStage === "display") fieldDisplay += t;
19346
+ else parts.push(makeLink(t, raw));
19347
+ continue;
19348
+ }
19349
+ if (matchesLocal(el, "fldSimple")) {
19350
+ const t = findElements(el, "r").map((r) => extractRun(r).text).join("");
19351
+ if (!t) continue;
19352
+ const url = fieldUrlFromInstr(getAttr(el, "instr") ?? "");
19353
+ parts.push(url ? makeLink(t, url) : t);
19354
+ continue;
19355
+ }
19356
+ if (matchesLocal(el, "r")) {
19357
+ for (const fc of getChildElements(el, "fldChar")) {
19358
+ const ty = getAttr(fc, "fldCharType");
19359
+ if (ty === "begin") {
19360
+ flushField();
19361
+ fieldActive = true;
19362
+ fieldStage = "instr";
19363
+ } else if (ty === "separate") {
19364
+ if (fieldActive) fieldStage = "display";
19365
+ } else if (ty === "end") flushField();
19366
+ }
19367
+ if (fieldActive && fieldStage === "instr") {
19368
+ for (const it of getChildElements(el, "instrText")) fieldInstr += it.textContent ?? "";
19369
+ }
19370
+ const rr = extractRun(el);
19371
+ if (rr.bold) bold = true;
19372
+ if (rr.italic) italic = true;
19373
+ const fnRefEls = getChildElements(el, "footnoteReference");
19374
+ if (fnRefEls.length > 0) {
19375
+ const fnId = getAttr(fnRefEls[0], "id");
19376
+ if (fnId && footnotes.has(fnId)) footnoteText = footnotes.get(fnId);
19377
+ }
19378
+ if (rr.text) {
19379
+ if (fieldActive && fieldStage === "display") fieldDisplay += rr.text;
19380
+ else if (fieldActive && fieldStage === "instr") {
19381
+ } else parts.push(rr.text);
19382
+ }
19383
+ continue;
19384
+ }
19385
+ }
19386
+ flushField();
19387
+ for (const om of collectOmmlRoots(p)) {
19388
+ const latex = ommlElementToLatex(om);
19389
+ if (!latex) continue;
19390
+ if (isDisplayMath(om)) parts.push(" $$" + latex + "$$ ");
19391
+ else parts.push(" $" + latex + "$ ");
19392
+ }
19393
+ const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
19394
+ return { text, bold, italic, footnoteText };
19395
+ }
19270
19396
  function parseParagraph2(p, styles, numbering, footnotes, rels) {
19271
19397
  const pPrEls = getChildElements(p, "pPr");
19272
19398
  let styleId = "";
@@ -19283,54 +19409,7 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
19283
19409
  ilvl = ilvlEls.length > 0 ? parseInt(getAttr(ilvlEls[0], "val") ?? "0", 10) : 0;
19284
19410
  }
19285
19411
  }
19286
- const parts = [];
19287
- let hasBold = false;
19288
- let hasItalic = false;
19289
- let href;
19290
- let footnoteText;
19291
- const hyperlinks = getChildElements(p, "hyperlink");
19292
- const hyperlinkTexts = /* @__PURE__ */ new Set();
19293
- for (const hl of hyperlinks) {
19294
- const rId = getAttr(hl, "id");
19295
- const hlText = [];
19296
- const runs2 = findElements(hl, "r");
19297
- for (const r of runs2) {
19298
- const result = extractRun(r);
19299
- hlText.push(result.text);
19300
- }
19301
- const text2 = hlText.join("");
19302
- if (text2) {
19303
- hyperlinkTexts.add(text2);
19304
- if (rId && rels.has(rId)) {
19305
- href = rels.get(rId);
19306
- parts.push(text2);
19307
- } else {
19308
- parts.push(text2);
19309
- }
19310
- }
19311
- }
19312
- const runs = getChildElements(p, "r");
19313
- for (const r of runs) {
19314
- if (r.parentNode && r.parentNode.localName === "hyperlink") continue;
19315
- const result = extractRun(r);
19316
- if (result.bold) hasBold = true;
19317
- if (result.italic) hasItalic = true;
19318
- const fnRefEls = getChildElements(r, "footnoteReference");
19319
- if (fnRefEls.length > 0) {
19320
- const fnId = getAttr(fnRefEls[0], "id");
19321
- if (fnId && footnotes.has(fnId)) {
19322
- footnoteText = footnotes.get(fnId);
19323
- }
19324
- }
19325
- if (result.text) parts.push(result.text);
19326
- }
19327
- for (const om of collectOmmlRoots(p)) {
19328
- const latex = ommlElementToLatex(om);
19329
- if (!latex) continue;
19330
- if (isDisplayMath(om)) parts.push(" $$" + latex + "$$ ");
19331
- else parts.push(" $" + latex + "$ ");
19332
- }
19333
- const text = parts.join("").replace(/[ \t]{2,}/g, " ").trim();
19412
+ const { text, bold: hasBold, italic: hasItalic, footnoteText } = collectInline(p, footnotes, rels);
19334
19413
  if (!text) return null;
19335
19414
  const style = styles.get(styleId);
19336
19415
  if (style?.outlineLevel !== void 0 && style.outlineLevel >= 0 && style.outlineLevel <= 5) {
@@ -19350,7 +19429,6 @@ function parseParagraph2(p, styles, numbering, footnotes, rels) {
19350
19429
  if (hasBold || hasItalic) {
19351
19430
  block.style = { bold: hasBold || void 0, italic: hasItalic || void 0 };
19352
19431
  }
19353
- if (href) block.href = href;
19354
19432
  if (footnoteText) block.footnoteText = footnoteText;
19355
19433
  return block;
19356
19434
  }
@@ -19451,46 +19529,61 @@ function collectCellText(tc2, styles, numbering, footnotes, rels, depth) {
19451
19529
  }
19452
19530
  return parts;
19453
19531
  }
19454
- async function extractImages(zip, rels, doc, warnings) {
19455
- const blocks = [];
19532
+ async function buildImageMap(zip, rels, doc, warnings) {
19533
+ const imageMap = /* @__PURE__ */ new Map();
19456
19534
  const images = [];
19457
- const drawingElements = findElements(doc.documentElement, "drawing");
19458
19535
  let imgIdx = 0;
19459
- for (const drawing of drawingElements) {
19460
- const blips = findElements(drawing, "blip");
19461
- for (const blip of blips) {
19462
- const embedId = getAttr(blip, "embed");
19463
- if (!embedId) continue;
19464
- const target = rels.get(embedId);
19465
- if (!target) continue;
19466
- const imgPath = target.startsWith("/") ? target.slice(1) : target.startsWith("word/") ? target : `word/${target}`;
19467
- const imgFile = zip.file(imgPath);
19468
- if (!imgFile) continue;
19469
- try {
19470
- const data = await imgFile.async("uint8array");
19471
- imgIdx++;
19472
- const ext = imgPath.split(".").pop()?.toLowerCase() ?? "png";
19473
- const mimeMap = {
19474
- png: "image/png",
19475
- jpg: "image/jpeg",
19476
- jpeg: "image/jpeg",
19477
- gif: "image/gif",
19478
- bmp: "image/bmp",
19479
- wmf: "image/wmf",
19480
- emf: "image/emf"
19481
- };
19482
- const filename = `image_${String(imgIdx).padStart(3, "0")}.${ext}`;
19483
- images.push({ filename, data, mimeType: mimeMap[ext] ?? "image/png" });
19484
- blocks.push({ type: "image", text: filename });
19485
- } catch (err) {
19486
- warnings.push({
19487
- code: "SKIPPED_IMAGE",
19488
- message: `DOCX \uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328 (${imgPath}): ${err instanceof Error ? err.message : String(err)}`
19489
- });
19490
- }
19536
+ for (const blip of findElements(doc.documentElement, "blip")) {
19537
+ const embedId = getAttr(blip, "embed");
19538
+ if (!embedId || imageMap.has(embedId)) continue;
19539
+ const target = rels.get(embedId);
19540
+ if (!target) continue;
19541
+ const imgPath = target.startsWith("/") ? target.slice(1) : target.startsWith("word/") ? target : `word/${target}`;
19542
+ const imgFile = zip.file(imgPath);
19543
+ if (!imgFile) continue;
19544
+ try {
19545
+ const data = await imgFile.async("uint8array");
19546
+ imgIdx++;
19547
+ const ext = imgPath.split(".").pop()?.toLowerCase() ?? "png";
19548
+ const mimeMap = {
19549
+ png: "image/png",
19550
+ jpg: "image/jpeg",
19551
+ jpeg: "image/jpeg",
19552
+ gif: "image/gif",
19553
+ bmp: "image/bmp",
19554
+ wmf: "image/wmf",
19555
+ emf: "image/emf"
19556
+ };
19557
+ const filename = `image_${String(imgIdx).padStart(3, "0")}.${ext}`;
19558
+ images.push({ filename, data, mimeType: mimeMap[ext] ?? "image/png" });
19559
+ imageMap.set(embedId, filename);
19560
+ } catch (err) {
19561
+ warnings.push({
19562
+ code: "SKIPPED_IMAGE",
19563
+ message: `DOCX \uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328 (${imgPath}): ${err instanceof Error ? err.message : String(err)}`
19564
+ });
19491
19565
  }
19492
19566
  }
19493
- return { blocks, images };
19567
+ return { imageMap, images };
19568
+ }
19569
+ function collectParagraphBlips(node, out = [], depth = 0) {
19570
+ if (depth > 40) return out;
19571
+ for (const el of effectiveChildElements(node)) {
19572
+ if (matchesLocal(el, "txbxContent") || matchesLocal(el, "Fallback")) continue;
19573
+ if (matchesLocal(el, "blip")) out.push(el);
19574
+ else collectParagraphBlips(el, out, depth + 1);
19575
+ }
19576
+ return out;
19577
+ }
19578
+ function emitParagraphImages(p, imageMap, linked, out) {
19579
+ for (const blip of collectParagraphBlips(p)) {
19580
+ const embedId = getAttr(blip, "embed");
19581
+ if (!embedId) continue;
19582
+ const filename = imageMap.get(embedId);
19583
+ if (!filename) continue;
19584
+ linked.add(embedId);
19585
+ out.push({ type: "image", text: filename });
19586
+ }
19494
19587
  }
19495
19588
  async function parseDocxDocument(buffer, options) {
19496
19589
  precheckZipSize(buffer, MAX_DECOMPRESS_SIZE4);
@@ -19547,6 +19640,8 @@ async function parseDocxDocument(buffer, options) {
19547
19640
  if (body.length === 0) {
19548
19641
  throw new KordocError("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19549
19642
  }
19643
+ const { imageMap, images } = await buildImageMap(zip, rels, doc, warnings);
19644
+ const linkedImages = /* @__PURE__ */ new Set();
19550
19645
  const blocks = [];
19551
19646
  const bodyEl = body[0];
19552
19647
  const topLevel = effectiveChildElements(bodyEl);
@@ -19555,16 +19650,20 @@ async function parseDocxDocument(buffer, options) {
19555
19650
  if (localName2 === "p") {
19556
19651
  const block = parseParagraph2(el, styles, numbering, footnotes, rels);
19557
19652
  if (block) blocks.push(block);
19653
+ if (imageMap.size > 0) emitParagraphImages(el, imageMap, linkedImages, blocks);
19558
19654
  for (const tp of collectTextboxParagraphs(el)) {
19559
19655
  const tb = parseParagraph2(tp, styles, numbering, footnotes, rels);
19560
19656
  if (tb) blocks.push(tb);
19657
+ if (imageMap.size > 0) emitParagraphImages(tp, imageMap, linkedImages, blocks);
19561
19658
  }
19562
19659
  } else if (localName2 === "tbl") {
19563
19660
  const block = parseTable(el, styles, numbering, footnotes, rels);
19564
19661
  if (block) blocks.push(block);
19565
19662
  }
19566
19663
  }
19567
- const { blocks: imgBlocks, images } = await extractImages(zip, rels, doc, warnings);
19664
+ for (const [embedId, filename] of imageMap) {
19665
+ if (!linkedImages.has(embedId)) blocks.push({ type: "image", text: filename });
19666
+ }
19568
19667
  const metadata = {};
19569
19668
  const coreFile = zip.file("docProps/core.xml");
19570
19669
  if (coreFile) {
@@ -29784,7 +29883,7 @@ async function parseHwp(buffer, options) {
29784
29883
  async function parsePdf(buffer, options) {
29785
29884
  let parsePdfDocument;
29786
29885
  try {
29787
- const mod = await import("./parser-YSHZC5FQ.js");
29886
+ const mod = await import("./parser-UGB3NIVH.js");
29788
29887
  parsePdfDocument = mod.parsePdfDocument;
29789
29888
  } catch {
29790
29889
  return {