kordoc 4.2.7 → 4.2.9

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 (89) hide show
  1. package/dist/{-7TEU6IRU.js → -ECUCTQTR.js} +9 -9
  2. package/dist/{chunk-AES6PHIG.js → chunk-27Z4PUZZ.js} +3 -3
  3. package/dist/{chunk-62DHK6KT.js → chunk-3PLF5UIS.js} +2 -2
  4. package/dist/{chunk-G2AS6ICC.js → chunk-3TSTZGCJ.js} +2 -2
  5. package/dist/{chunk-RS5OID2J.cjs → chunk-4ZWKFDUC.cjs} +9 -9
  6. package/dist/{chunk-RS5OID2J.cjs.map → chunk-4ZWKFDUC.cjs.map} +1 -1
  7. package/dist/{chunk-VWXA47AW.cjs → chunk-6GM2QLM3.cjs} +4 -4
  8. package/dist/{chunk-VWXA47AW.cjs.map → chunk-6GM2QLM3.cjs.map} +1 -1
  9. package/dist/{chunk-IVX3YLQH.js → chunk-7ZARSBQ3.js} +2 -2
  10. package/dist/chunk-7ZARSBQ3.js.map +1 -0
  11. package/dist/{chunk-LPRNVK4G.js → chunk-G3DMDTZI.js} +64 -39
  12. package/dist/chunk-G3DMDTZI.js.map +1 -0
  13. package/dist/{chunk-HH4SD5RE.cjs → chunk-GZ7W64QU.cjs} +2 -2
  14. package/dist/{chunk-HH4SD5RE.cjs.map → chunk-GZ7W64QU.cjs.map} +1 -1
  15. package/dist/{chunk-PK5GLL5C.js → chunk-KTPZYXN2.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-5HFKMCAX.js → chunk-LXE7OR6N.js} +2 -2
  19. package/dist/{chunk-T6BTWUTC.js → chunk-MHMVFI2N.js} +2 -2
  20. package/dist/{chunk-NAWC6HTC.js → chunk-NIISBGSR.js} +2 -2
  21. package/dist/chunk-NIISBGSR.js.map +1 -0
  22. package/dist/{chunk-YTRJDQ4Q.cjs → chunk-PATPZTH7.cjs} +3 -3
  23. package/dist/{chunk-YTRJDQ4Q.cjs.map → chunk-PATPZTH7.cjs.map} +1 -1
  24. package/dist/{chunk-YAQRGQUJ.js → chunk-STYN45MS.js} +2 -2
  25. package/dist/{chunk-2CHFQQXM.js → chunk-VEHC4EJL.js} +2 -2
  26. package/dist/{chunk-FSUCQ6ZM.js → chunk-WTT2KJOM.js} +4 -4
  27. package/dist/chunk-WTT2KJOM.js.map +1 -0
  28. package/dist/{chunk-ESV4KOSE.js → chunk-XU4VWOKL.js} +3 -3
  29. package/dist/{chunk-NKERQ6GB.js → chunk-YR4PF56B.js} +2 -2
  30. package/dist/chunks-VFIMYK36.js +10 -0
  31. package/dist/cli.js +17 -17
  32. package/dist/{image-ocr-UX4QM35J.cjs → image-ocr-J5656BEE.cjs} +9 -9
  33. package/dist/{image-ocr-UX4QM35J.cjs.map → image-ocr-J5656BEE.cjs.map} +1 -1
  34. package/dist/{image-ocr-PGQ7JPDP.js → image-ocr-KZTNJ62U.js} +5 -5
  35. package/dist/{image-ocr-OS4ETBOL.js → image-ocr-PS7XCV6K.js} +4 -4
  36. package/dist/index.cjs +491 -466
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +6 -0
  39. package/dist/index.d.ts +6 -0
  40. package/dist/index.js +60 -35
  41. package/dist/index.js.map +1 -1
  42. package/dist/mcp.js +15 -15
  43. package/dist/{parser-2JAC5WMM.js → parser-A34NAYKA.js} +5 -5
  44. package/dist/{parser-GAZROLSA.cjs → parser-CSYU3CAW.cjs} +24 -24
  45. package/dist/{parser-GAZROLSA.cjs.map → parser-CSYU3CAW.cjs.map} +1 -1
  46. package/dist/{parser-T74C7Q57.js → parser-WNFWMBSL.js} +6 -6
  47. package/dist/pdf-ocr-KBMWPG2L.js +12 -0
  48. package/dist/{pdf-ocr-3A3QLPID.js → pdf-ocr-NPZG67FN.js} +5 -5
  49. package/dist/pdf-ocr-O44DAGTY.cjs +13 -0
  50. package/dist/{pdf-ocr-2SKGRXIR.cjs.map → pdf-ocr-O44DAGTY.cjs.map} +1 -1
  51. package/dist/{profile-io-6GX564CO.js → profile-io-43MF52H6.js} +3 -3
  52. package/dist/{rasterize-4V7PKE7A.js → rasterize-OG7KXBJS.js} +2 -2
  53. package/dist/render-336CJHAS.js +10 -0
  54. package/dist/seal-TM2XCE2R.js +10 -0
  55. package/dist/{watch-JVRAAJNA.js → watch-SOHQMZN2.js} +9 -9
  56. package/package.json +1 -1
  57. package/dist/chunk-FSUCQ6ZM.js.map +0 -1
  58. package/dist/chunk-GJO3ORFW.js.map +0 -1
  59. package/dist/chunk-IVX3YLQH.js.map +0 -1
  60. package/dist/chunk-LPRNVK4G.js.map +0 -1
  61. package/dist/chunk-NAWC6HTC.js.map +0 -1
  62. package/dist/chunks-TLAOHNPB.js +0 -10
  63. package/dist/pdf-ocr-2SKGRXIR.cjs +0 -13
  64. package/dist/pdf-ocr-WBOTDQ4D.js +0 -12
  65. package/dist/render-2AF7GZVN.js +0 -10
  66. package/dist/seal-2ES6UAN6.js +0 -10
  67. /package/dist/{-7TEU6IRU.js.map → -ECUCTQTR.js.map} +0 -0
  68. /package/dist/{chunk-AES6PHIG.js.map → chunk-27Z4PUZZ.js.map} +0 -0
  69. /package/dist/{chunk-62DHK6KT.js.map → chunk-3PLF5UIS.js.map} +0 -0
  70. /package/dist/{chunk-G2AS6ICC.js.map → chunk-3TSTZGCJ.js.map} +0 -0
  71. /package/dist/{chunk-PK5GLL5C.js.map → chunk-KTPZYXN2.js.map} +0 -0
  72. /package/dist/{chunk-5HFKMCAX.js.map → chunk-LXE7OR6N.js.map} +0 -0
  73. /package/dist/{chunk-T6BTWUTC.js.map → chunk-MHMVFI2N.js.map} +0 -0
  74. /package/dist/{chunk-YAQRGQUJ.js.map → chunk-STYN45MS.js.map} +0 -0
  75. /package/dist/{chunk-2CHFQQXM.js.map → chunk-VEHC4EJL.js.map} +0 -0
  76. /package/dist/{chunk-ESV4KOSE.js.map → chunk-XU4VWOKL.js.map} +0 -0
  77. /package/dist/{chunk-NKERQ6GB.js.map → chunk-YR4PF56B.js.map} +0 -0
  78. /package/dist/{chunks-TLAOHNPB.js.map → chunks-VFIMYK36.js.map} +0 -0
  79. /package/dist/{image-ocr-PGQ7JPDP.js.map → image-ocr-KZTNJ62U.js.map} +0 -0
  80. /package/dist/{image-ocr-OS4ETBOL.js.map → image-ocr-PS7XCV6K.js.map} +0 -0
  81. /package/dist/{parser-2JAC5WMM.js.map → parser-A34NAYKA.js.map} +0 -0
  82. /package/dist/{parser-T74C7Q57.js.map → parser-WNFWMBSL.js.map} +0 -0
  83. /package/dist/{pdf-ocr-3A3QLPID.js.map → pdf-ocr-KBMWPG2L.js.map} +0 -0
  84. /package/dist/{pdf-ocr-WBOTDQ4D.js.map → pdf-ocr-NPZG67FN.js.map} +0 -0
  85. /package/dist/{profile-io-6GX564CO.js.map → profile-io-43MF52H6.js.map} +0 -0
  86. /package/dist/{rasterize-4V7PKE7A.js.map → rasterize-OG7KXBJS.js.map} +0 -0
  87. /package/dist/{render-2AF7GZVN.js.map → render-336CJHAS.js.map} +0 -0
  88. /package/dist/{seal-2ES6UAN6.js.map → seal-TM2XCE2R.js.map} +0 -0
  89. /package/dist/{watch-JVRAAJNA.js.map → watch-SOHQMZN2.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-STYN45MS.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-7ZARSBQ3.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) {
@@ -17544,9 +17568,8 @@ function decodeJohab(ch) {
17544
17568
  const jongIdx = ch & 31;
17545
17569
  const cho = CHO_MAP[choIdx];
17546
17570
  const jung = JUNG_MAP[jungIdx];
17547
- let jong = JONG_MAP[jongIdx];
17548
- if (cho !== -1 && jung !== -1) {
17549
- if (jong === -1) jong = 0;
17571
+ const jong = JONG_MAP[jongIdx];
17572
+ if (cho !== -1 && jung !== -1 && jong !== -1) {
17550
17573
  return 44032 + cho * 588 + jung * 28 + jong;
17551
17574
  }
17552
17575
  const hit = lookupSymbol(ch);
@@ -17715,8 +17738,6 @@ var LINE_INFO_SIZE = 14;
17715
17738
  var INLINE_CHAR_SHAPE_SIZE = 31;
17716
17739
  var SIMPLE_CTRL = /* @__PURE__ */ new Map([
17717
17740
  [9, { extraBytes: 6, extraHchar: 3, emit: " " }],
17718
- [7, { extraBytes: 6, extraHchar: 3, emit: "\uFFFC" }],
17719
- [8, { extraBytes: 6, extraHchar: 3, emit: "\uFFFC" }],
17720
17741
  [18, { extraBytes: 6, extraHchar: 3, emit: " " }],
17721
17742
  // AutoNumber → 공백 (HWP5 패턴)
17722
17743
  [19, { extraBytes: 6, extraHchar: 3, emit: "\uFFFC" }],
@@ -17725,7 +17746,8 @@ var SIMPLE_CTRL = /* @__PURE__ */ new Map([
17725
17746
  [22, { extraBytes: 22, extraHchar: 11, emit: "\uFFFC" }],
17726
17747
  [23, { extraBytes: 8, extraHchar: 4, emit: "\uFFFC" }],
17727
17748
  [24, { extraBytes: 4, extraHchar: 2, emit: "-" }],
17728
- [25, { extraBytes: 4, extraHchar: 2, emit: "-" }],
17749
+ [25, { extraBytes: 4, extraHchar: 2, emit: null }],
17750
+ // 차례 표식 — 비가시 (rhwp #2765)
17729
17751
  [26, { extraBytes: 244, extraHchar: 122, emit: "\uFFFC" }],
17730
17752
  [28, { extraBytes: 62, extraHchar: 31, emit: "\uFFFC" }],
17731
17753
  [30, { extraBytes: 2, extraHchar: 1, emit: "\xA0" }],
@@ -17869,9 +17891,6 @@ function parseCharStream(reader, charCount, ctx) {
17869
17891
  case 11:
17870
17892
  parsePicture(reader, ctx);
17871
17893
  break;
17872
- case 12:
17873
- reader.skip(84);
17874
- break;
17875
17894
  case 14:
17876
17895
  reader.skip(84);
17877
17896
  break;
@@ -17896,6 +17915,12 @@ function parseCharStream(reader, charCount, ctx) {
17896
17915
  case 6:
17897
17916
  reader.skip(34);
17898
17917
  break;
17918
+ case 7:
17919
+ reader.skip(76);
17920
+ break;
17921
+ case 8:
17922
+ reader.skip(88);
17923
+ break;
17899
17924
  case 29:
17900
17925
  if (headerVal1 < 1e6) reader.skip(headerVal1);
17901
17926
  break;
@@ -29815,7 +29840,7 @@ function findFirst(el, name, depth = 0) {
29815
29840
  return null;
29816
29841
  }
29817
29842
  function escapeXml3(s) {
29818
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
29843
+ return s.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
29819
29844
  }
29820
29845
  var OBJ_TAGS = /* @__PURE__ */ new Set(["tbl", "pic", "container", "equation", "rect", "ellipse", "polygon", "curv", "line", "arc", "ole", "textart"]);
29821
29846
  var pt = (u) => String(Math.round(u) / 100);
@@ -30574,7 +30599,7 @@ async function parse(input, options) {
30574
30599
  }
30575
30600
  async function parseImage(buffer, options) {
30576
30601
  try {
30577
- const { parseImageDocument } = await import("./image-ocr-OS4ETBOL.js");
30602
+ const { parseImageDocument } = await import("./image-ocr-PS7XCV6K.js");
30578
30603
  const { blocks, warnings } = await parseImageDocument(buffer, options);
30579
30604
  return {
30580
30605
  success: true,
@@ -30632,7 +30657,7 @@ async function parseHwp(buffer, options) {
30632
30657
  async function parsePdf(buffer, options) {
30633
30658
  let parsePdfDocument;
30634
30659
  try {
30635
- const mod = await import("./parser-2JAC5WMM.js");
30660
+ const mod = await import("./parser-A34NAYKA.js");
30636
30661
  parsePdfDocument = mod.parsePdfDocument;
30637
30662
  } catch {
30638
30663
  return {