kordoc 4.2.7 → 4.2.8

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 (88) hide show
  1. package/dist/{-7TEU6IRU.js → -SCTT2TBZ.js} +9 -9
  2. package/dist/{chunk-VWXA47AW.cjs → chunk-2BTKLDNX.cjs} +4 -4
  3. package/dist/{chunk-VWXA47AW.cjs.map → chunk-2BTKLDNX.cjs.map} +1 -1
  4. package/dist/{chunk-T6BTWUTC.js → chunk-4FTXKIGT.js} +2 -2
  5. package/dist/{chunk-ESV4KOSE.js → chunk-55QIELGV.js} +3 -3
  6. package/dist/{chunk-G2AS6ICC.js → chunk-7GEBDS6B.js} +2 -2
  7. package/dist/{chunk-YTRJDQ4Q.cjs → chunk-CELJIGBQ.cjs} +3 -3
  8. package/dist/{chunk-YTRJDQ4Q.cjs.map → chunk-CELJIGBQ.cjs.map} +1 -1
  9. package/dist/{chunk-PK5GLL5C.js → chunk-COHHXQSP.js} +2 -2
  10. package/dist/{chunk-FSUCQ6ZM.js → chunk-EOVJ27WC.js} +3 -3
  11. package/dist/{chunk-5HFKMCAX.js → chunk-FS3XQ3ZQ.js} +2 -2
  12. package/dist/{chunk-NAWC6HTC.js → chunk-GKSFNCVP.js} +2 -2
  13. package/dist/chunk-GKSFNCVP.js.map +1 -0
  14. package/dist/{chunk-AES6PHIG.js → chunk-IJUAWDOS.js} +3 -3
  15. package/dist/{chunk-2CHFQQXM.js → chunk-JP5MNHUK.js} +2 -2
  16. package/dist/{chunk-GJO3ORFW.js → chunk-LM7C6HI2.js} +1 -1
  17. package/dist/chunk-LM7C6HI2.js.map +1 -0
  18. package/dist/{chunk-HH4SD5RE.cjs → chunk-OQNFGKRY.cjs} +2 -2
  19. package/dist/{chunk-HH4SD5RE.cjs.map → chunk-OQNFGKRY.cjs.map} +1 -1
  20. package/dist/{chunk-YAQRGQUJ.js → chunk-QZCAIFUW.js} +2 -2
  21. package/dist/{chunk-RS5OID2J.cjs → chunk-ROKHZE76.cjs} +9 -9
  22. package/dist/{chunk-RS5OID2J.cjs.map → chunk-ROKHZE76.cjs.map} +1 -1
  23. package/dist/{chunk-62DHK6KT.js → chunk-UKEZ46VL.js} +2 -2
  24. package/dist/{chunk-NKERQ6GB.js → chunk-URKX77GB.js} +2 -2
  25. package/dist/{chunk-IVX3YLQH.js → chunk-WP4VD5T7.js} +2 -2
  26. package/dist/chunk-WP4VD5T7.js.map +1 -0
  27. package/dist/{chunk-LPRNVK4G.js → chunk-YNAPK4H6.js} +54 -30
  28. package/dist/chunk-YNAPK4H6.js.map +1 -0
  29. package/dist/chunks-KKYJDJT7.js +10 -0
  30. package/dist/cli.js +17 -17
  31. package/dist/{image-ocr-OS4ETBOL.js → image-ocr-ANSXR5KJ.js} +4 -4
  32. package/dist/{image-ocr-UX4QM35J.cjs → image-ocr-GHQ6YKJH.cjs} +9 -9
  33. package/dist/{image-ocr-UX4QM35J.cjs.map → image-ocr-GHQ6YKJH.cjs.map} +1 -1
  34. package/dist/{image-ocr-PGQ7JPDP.js → image-ocr-ORATZW73.js} +5 -5
  35. package/dist/index.cjs +480 -456
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +6 -0
  38. package/dist/index.d.ts +6 -0
  39. package/dist/index.js +49 -25
  40. package/dist/index.js.map +1 -1
  41. package/dist/mcp.js +15 -15
  42. package/dist/{parser-2JAC5WMM.js → parser-BPVTYM5K.js} +5 -5
  43. package/dist/{parser-T74C7Q57.js → parser-GZDOZCHM.js} +6 -6
  44. package/dist/{parser-GAZROLSA.cjs → parser-KTNIUF2N.cjs} +24 -24
  45. package/dist/{parser-GAZROLSA.cjs.map → parser-KTNIUF2N.cjs.map} +1 -1
  46. package/dist/pdf-ocr-6XKLXZTF.cjs +13 -0
  47. package/dist/{pdf-ocr-2SKGRXIR.cjs.map → pdf-ocr-6XKLXZTF.cjs.map} +1 -1
  48. package/dist/pdf-ocr-HWPNMKKC.js +12 -0
  49. package/dist/{pdf-ocr-3A3QLPID.js → pdf-ocr-W2PA2K3U.js} +5 -5
  50. package/dist/{profile-io-6GX564CO.js → profile-io-I2TH44EO.js} +3 -3
  51. package/dist/{rasterize-4V7PKE7A.js → rasterize-QBA43YAQ.js} +2 -2
  52. package/dist/render-MDJDKKNH.js +10 -0
  53. package/dist/seal-Z52JR2GX.js +10 -0
  54. package/dist/{watch-JVRAAJNA.js → watch-7V6X7LHV.js} +9 -9
  55. package/package.json +1 -1
  56. package/dist/chunk-GJO3ORFW.js.map +0 -1
  57. package/dist/chunk-IVX3YLQH.js.map +0 -1
  58. package/dist/chunk-LPRNVK4G.js.map +0 -1
  59. package/dist/chunk-NAWC6HTC.js.map +0 -1
  60. package/dist/chunks-TLAOHNPB.js +0 -10
  61. package/dist/pdf-ocr-2SKGRXIR.cjs +0 -13
  62. package/dist/pdf-ocr-WBOTDQ4D.js +0 -12
  63. package/dist/render-2AF7GZVN.js +0 -10
  64. package/dist/seal-2ES6UAN6.js +0 -10
  65. /package/dist/{-7TEU6IRU.js.map → -SCTT2TBZ.js.map} +0 -0
  66. /package/dist/{chunk-T6BTWUTC.js.map → chunk-4FTXKIGT.js.map} +0 -0
  67. /package/dist/{chunk-ESV4KOSE.js.map → chunk-55QIELGV.js.map} +0 -0
  68. /package/dist/{chunk-G2AS6ICC.js.map → chunk-7GEBDS6B.js.map} +0 -0
  69. /package/dist/{chunk-PK5GLL5C.js.map → chunk-COHHXQSP.js.map} +0 -0
  70. /package/dist/{chunk-FSUCQ6ZM.js.map → chunk-EOVJ27WC.js.map} +0 -0
  71. /package/dist/{chunk-5HFKMCAX.js.map → chunk-FS3XQ3ZQ.js.map} +0 -0
  72. /package/dist/{chunk-AES6PHIG.js.map → chunk-IJUAWDOS.js.map} +0 -0
  73. /package/dist/{chunk-2CHFQQXM.js.map → chunk-JP5MNHUK.js.map} +0 -0
  74. /package/dist/{chunk-YAQRGQUJ.js.map → chunk-QZCAIFUW.js.map} +0 -0
  75. /package/dist/{chunk-62DHK6KT.js.map → chunk-UKEZ46VL.js.map} +0 -0
  76. /package/dist/{chunk-NKERQ6GB.js.map → chunk-URKX77GB.js.map} +0 -0
  77. /package/dist/{chunks-TLAOHNPB.js.map → chunks-KKYJDJT7.js.map} +0 -0
  78. /package/dist/{image-ocr-OS4ETBOL.js.map → image-ocr-ANSXR5KJ.js.map} +0 -0
  79. /package/dist/{image-ocr-PGQ7JPDP.js.map → image-ocr-ORATZW73.js.map} +0 -0
  80. /package/dist/{parser-2JAC5WMM.js.map → parser-BPVTYM5K.js.map} +0 -0
  81. /package/dist/{parser-T74C7Q57.js.map → parser-GZDOZCHM.js.map} +0 -0
  82. /package/dist/{pdf-ocr-3A3QLPID.js.map → pdf-ocr-HWPNMKKC.js.map} +0 -0
  83. /package/dist/{pdf-ocr-WBOTDQ4D.js.map → pdf-ocr-W2PA2K3U.js.map} +0 -0
  84. /package/dist/{profile-io-6GX564CO.js.map → profile-io-I2TH44EO.js.map} +0 -0
  85. /package/dist/{rasterize-4V7PKE7A.js.map → rasterize-QBA43YAQ.js.map} +0 -0
  86. /package/dist/{render-2AF7GZVN.js.map → render-MDJDKKNH.js.map} +0 -0
  87. /package/dist/{seal-2ES6UAN6.js.map → seal-Z52JR2GX.js.map} +0 -0
  88. /package/dist/{watch-JVRAAJNA.js.map → watch-7V6X7LHV.js.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -92,6 +92,12 @@ interface IRTable {
92
92
  hasHeader: boolean;
93
93
  /** 표 캡션 (예: "표 1. 부서별 예산") — v3.0 */
94
94
  caption?: string;
95
+ /**
96
+ * 캡션 내부 블록 콘텐츠 — v4.2.8 (#55).
97
+ * 캡션 안 중첩표·문단을 구조 그대로, 원문 순서대로 보존한다 (IRCell.blocks와 같은 계약).
98
+ * 표가 있을 때만 채워지며, caption은 하위 호환용 평탄화 문자열로 계속 제공된다.
99
+ */
100
+ captionBlocks?: IRBlock[];
95
101
  }
96
102
  interface IRCell {
97
103
  text: string;
package/dist/index.d.ts CHANGED
@@ -92,6 +92,12 @@ interface IRTable {
92
92
  hasHeader: boolean;
93
93
  /** 표 캡션 (예: "표 1. 부서별 예산") — v3.0 */
94
94
  caption?: string;
95
+ /**
96
+ * 캡션 내부 블록 콘텐츠 — v4.2.8 (#55).
97
+ * 캡션 안 중첩표·문단을 구조 그대로, 원문 순서대로 보존한다 (IRCell.blocks와 같은 계약).
98
+ * 표가 있을 때만 채워지며, caption은 하위 호환용 평탄화 문자열로 계속 제공된다.
99
+ */
100
+ captionBlocks?: IRBlock[];
95
101
  }
96
102
  interface IRCell {
97
103
  text: string;
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  flattenLayoutTables,
9
9
  inlineImagesIntoMarkdown,
10
10
  mapPuaText
11
- } from "./chunk-YAQRGQUJ.js";
11
+ } from "./chunk-QZCAIFUW.js";
12
12
  import {
13
13
  parsePageRange
14
14
  } from "./chunk-GE43BE46.js";
@@ -27,7 +27,7 @@ import {
27
27
  sanitizeHref,
28
28
  stripDtd,
29
29
  toArrayBuffer
30
- } from "./chunk-IVX3YLQH.js";
30
+ } from "./chunk-WP4VD5T7.js";
31
31
 
32
32
  // src/index.ts
33
33
  import { readFile } from "fs/promises";
@@ -1914,6 +1914,7 @@ function resolveParaHeading(paraEl, ctx) {
1914
1914
  function buildTableWithCellMeta(state, keepAnchoredEmptyCols) {
1915
1915
  const table2 = buildTable(state.rows, { keepAnchoredEmptyCols });
1916
1916
  if (state.caption) table2.caption = state.caption;
1917
+ if (state.captionBlocks?.length) table2.captionBlocks = state.captionBlocks;
1917
1918
  const anchors = [];
1918
1919
  {
1919
1920
  const covered = /* @__PURE__ */ new Set();
@@ -2061,12 +2062,13 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
2061
2062
  }
2062
2063
  // 표/도표 캡션 — IRTable.caption으로 보존 (v3.0, 기존 무음 드롭 수정)
2063
2064
  case "caption": {
2064
- const capText = collectSubListText(el, ctx);
2065
- if (capText) {
2065
+ const cap = collectSubListContent(el, ctx);
2066
+ if (cap.text) {
2066
2067
  if (tableCtx) {
2067
- tableCtx.caption = (tableCtx.caption ? tableCtx.caption + "\n" : "") + capText;
2068
+ tableCtx.caption = (tableCtx.caption ? tableCtx.caption + "\n" : "") + cap.text;
2069
+ if (cap.hasStructure) (tableCtx.captionBlocks ??= []).push(...cap.blocks);
2068
2070
  } else {
2069
- blocks.push({ type: "paragraph", text: capText, pageNumber: ctx.sectionNum });
2071
+ blocks.push({ type: "paragraph", text: cap.text, pageNumber: ctx.sectionNum });
2070
2072
  }
2071
2073
  }
2072
2074
  break;
@@ -2316,40 +2318,60 @@ function hasPageAutoNum(el, depth = 0) {
2316
2318
  return false;
2317
2319
  }
2318
2320
  function collectSubListText(el, ctx, depth = 0) {
2319
- if (depth > 10) return "";
2321
+ return collectSubListContent(el, ctx, depth).text;
2322
+ }
2323
+ function collectSubListContent(el, ctx, depth = 0) {
2324
+ const out = { text: "", blocks: [], hasStructure: false };
2325
+ if (depth > 10) return out;
2320
2326
  const parts = [];
2321
2327
  const children = el.childNodes;
2322
- if (!children) return "";
2328
+ if (!children) return out;
2323
2329
  for (let i = 0; i < children.length; i++) {
2324
2330
  const ch = children[i];
2325
2331
  if (ch.nodeType !== 1) continue;
2326
2332
  const tag = (ch.tagName || ch.localName || "").replace(/^[^:]+:/, "");
2327
2333
  if (tag === "p" || tag === "para") {
2328
2334
  const t = extractParagraphInfo(ch, ctx.styleMap, ctx).text;
2329
- if (t) parts.push(t);
2335
+ if (t) {
2336
+ parts.push(t);
2337
+ out.blocks.push({ type: "paragraph", text: t, pageNumber: ctx.sectionNum });
2338
+ }
2330
2339
  const tbls = [];
2331
2340
  findTopLevelTbls(ch, tbls);
2332
2341
  for (const tbl2 of tbls) {
2333
- const flat = flattenSubListTable(tbl2, ctx, depth);
2334
- if (flat) parts.push(flat);
2342
+ const built = buildSubListTable(tbl2, ctx, depth);
2343
+ if (built.text) parts.push(built.text);
2344
+ if (built.block) {
2345
+ out.blocks.push(built.block);
2346
+ out.hasStructure = true;
2347
+ }
2335
2348
  }
2336
2349
  } else if (tag === "tbl") {
2337
- const flat = flattenSubListTable(ch, ctx, depth);
2338
- if (flat) parts.push(flat);
2350
+ const built = buildSubListTable(ch, ctx, depth);
2351
+ if (built.text) parts.push(built.text);
2352
+ if (built.block) {
2353
+ out.blocks.push(built.block);
2354
+ out.hasStructure = true;
2355
+ }
2339
2356
  } else {
2340
- const t = collectSubListText(ch, ctx, depth + 1);
2341
- if (t) parts.push(t);
2357
+ const sub = collectSubListContent(ch, ctx, depth + 1);
2358
+ if (sub.text) parts.push(sub.text);
2359
+ out.blocks.push(...sub.blocks);
2360
+ if (sub.hasStructure) out.hasStructure = true;
2342
2361
  }
2343
2362
  }
2344
- return parts.join("\n").trim();
2363
+ out.text = parts.join("\n").trim();
2364
+ return out;
2345
2365
  }
2346
- function flattenSubListTable(el, ctx, depth) {
2366
+ function buildSubListTable(el, ctx, depth) {
2347
2367
  const sink = [];
2348
2368
  const st = { rows: [], currentRow: [], cell: null };
2349
2369
  walkSection(el, sink, st, [], ctx, depth + 1);
2350
2370
  let flat = convertTableToText(st.rows);
2351
2371
  if (st.caption) flat = st.caption + (flat ? "\n" + flat : "");
2352
- return flat;
2372
+ const built = [];
2373
+ completeTable(st, [], built, ctx);
2374
+ return { text: flat, block: built.find((b) => b.type === "table") ?? null };
2353
2375
  }
2354
2376
  function findTopLevelTbls(el, out, depth = 0) {
2355
2377
  if (depth > MAX_XML_DEPTH) return;
@@ -2395,11 +2417,13 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
2395
2417
  walkSection(el, blocks, newTable, tableStack, ctx, d + 1);
2396
2418
  tableCtx = completeTable(newTable, tableStack, blocks, ctx);
2397
2419
  } else if (localTag === "caption" && !inShape) {
2398
- const capText = collectSubListText(el, ctx);
2399
- if (capText) {
2400
- if (tableCtx?.cell) mergeBlocksIntoCell(tableCtx.cell, [{ type: "paragraph", text: capText, pageNumber: ctx.sectionNum }]);
2401
- else if (tableCtx) tableCtx.caption = (tableCtx.caption ? tableCtx.caption + "\n" : "") + capText;
2402
- else blocks.push({ type: "paragraph", text: capText, pageNumber: ctx.sectionNum });
2420
+ const cap = collectSubListContent(el, ctx);
2421
+ if (cap.text) {
2422
+ if (tableCtx?.cell) mergeBlocksIntoCell(tableCtx.cell, [{ type: "paragraph", text: cap.text, pageNumber: ctx.sectionNum }]);
2423
+ else if (tableCtx) {
2424
+ tableCtx.caption = (tableCtx.caption ? tableCtx.caption + "\n" : "") + cap.text;
2425
+ if (cap.hasStructure) (tableCtx.captionBlocks ??= []).push(...cap.blocks);
2426
+ } else blocks.push({ type: "paragraph", text: cap.text, pageNumber: ctx.sectionNum });
2403
2427
  }
2404
2428
  } else if (localTag === "pic" || localTag === "shape" || localTag === "drawingObject") {
2405
2429
  if (tableCtx?.cell) {
@@ -30574,7 +30598,7 @@ async function parse(input, options) {
30574
30598
  }
30575
30599
  async function parseImage(buffer, options) {
30576
30600
  try {
30577
- const { parseImageDocument } = await import("./image-ocr-OS4ETBOL.js");
30601
+ const { parseImageDocument } = await import("./image-ocr-ANSXR5KJ.js");
30578
30602
  const { blocks, warnings } = await parseImageDocument(buffer, options);
30579
30603
  return {
30580
30604
  success: true,
@@ -30632,7 +30656,7 @@ async function parseHwp(buffer, options) {
30632
30656
  async function parsePdf(buffer, options) {
30633
30657
  let parsePdfDocument;
30634
30658
  try {
30635
- const mod = await import("./parser-2JAC5WMM.js");
30659
+ const mod = await import("./parser-BPVTYM5K.js");
30636
30660
  parsePdfDocument = mod.parsePdfDocument;
30637
30661
  } catch {
30638
30662
  return {