kordoc 4.2.2 → 4.2.4

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 (103) hide show
  1. package/README.md +15 -3
  2. package/dist/{-NFHVGTVM.js → -2M56QRNH.js} +9 -9
  3. package/dist/{chunk-MYD3QLBL.js → chunk-7KRCQE3P.js} +2 -2
  4. package/dist/{chunk-OLDIDBJ2.js → chunk-7Z3NHIRR.js} +3 -3
  5. package/dist/{chunk-KKZATKQW.cjs → chunk-BLNOGMIM.cjs} +2 -2
  6. package/dist/chunk-BLNOGMIM.cjs.map +1 -0
  7. package/dist/{chunk-TXYQJXOV.js → chunk-CAA6DVEE.js} +91 -30
  8. package/dist/chunk-CAA6DVEE.js.map +1 -0
  9. package/dist/chunk-DCZVOIEO.cjs.map +1 -1
  10. package/dist/{chunk-MOOVF6CT.js → chunk-DOLK5KIS.js} +2 -2
  11. package/dist/{chunk-2L7MIKOM.js → chunk-E2K4SNMD.js} +2 -2
  12. package/dist/{chunk-X77U36TV.js → chunk-GFTAPAJS.js} +2 -2
  13. package/dist/{chunk-ZF7QL4IY.js → chunk-GJO3ORFW.js} +1 -1
  14. package/dist/chunk-GJO3ORFW.js.map +1 -0
  15. package/dist/chunk-GS7T56RP.cjs.map +1 -1
  16. package/dist/{chunk-FHYLLKIP.js → chunk-H6O65EPK.js} +2 -2
  17. package/dist/chunk-H7OWEYH2.cjs.map +1 -1
  18. package/dist/{chunk-DSL6EVFJ.js → chunk-I53FOXZR.js} +2 -2
  19. package/dist/{chunk-GHMVNMUN.js → chunk-LWNFAIYG.js} +3 -3
  20. package/dist/{chunk-EFF2JPPA.cjs → chunk-LXUZUUUG.cjs} +9 -9
  21. package/dist/chunk-LXUZUUUG.cjs.map +1 -0
  22. package/dist/{chunk-GUYIXVV7.js → chunk-OBX3VSIZ.js} +2 -2
  23. package/dist/chunk-OBX3VSIZ.js.map +1 -0
  24. package/dist/{chunk-T4AWY45Q.js → chunk-PMBWFYZQ.js} +2 -2
  25. package/dist/{chunk-IXHBRMDB.js → chunk-PQ46DC6Y.js} +2 -2
  26. package/dist/{chunk-WMU2KJHF.cjs → chunk-SCJLAOY3.cjs} +4 -4
  27. package/dist/chunk-SCJLAOY3.cjs.map +1 -0
  28. package/dist/{chunk-L5B7PQOP.js → chunk-WMM6XVQX.js} +2 -2
  29. package/dist/{chunk-DLFZAU4X.cjs → chunk-YFSYLEXO.cjs} +3 -3
  30. package/dist/chunk-YFSYLEXO.cjs.map +1 -0
  31. package/dist/{chunk-LUJN3VFB.js → chunk-ZHRYLT3N.js} +3 -3
  32. package/dist/chunks-GT45ALC5.js +10 -0
  33. package/dist/cli.js +18 -18
  34. package/dist/formula-SB3NHDUM.cjs.map +1 -1
  35. package/dist/{image-ocr-S4REURLR.js → image-ocr-HY42AVXC.js} +5 -5
  36. package/dist/{image-ocr-3AFBDDJI.cjs → image-ocr-JWAX5EOB.cjs} +9 -9
  37. package/dist/image-ocr-JWAX5EOB.cjs.map +1 -0
  38. package/dist/{image-ocr-TGHAMIQL.js → image-ocr-WCIDB6RY.js} +4 -4
  39. package/dist/index.cjs +508 -447
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts +7 -2
  42. package/dist/index.d.ts +7 -2
  43. package/dist/index.js +86 -25
  44. package/dist/index.js.map +1 -1
  45. package/dist/mcp.js +15 -15
  46. package/dist/page-range-P7SDW6LR.cjs.map +1 -1
  47. package/dist/{parser-MRM6WICO.cjs → parser-6RDEBLSB.cjs} +24 -24
  48. package/dist/parser-6RDEBLSB.cjs.map +1 -0
  49. package/dist/{parser-C3APVZGT.js → parser-SVZPCCRG.js} +6 -6
  50. package/dist/{parser-KMC4YOZH.js → parser-WRNS6MX2.js} +5 -5
  51. package/dist/pdf-ocr-4SGVLUNL.cjs +13 -0
  52. package/dist/pdf-ocr-4SGVLUNL.cjs.map +1 -0
  53. package/dist/pdf-ocr-7AAHJOXQ.js +12 -0
  54. package/dist/{pdf-ocr-UURMV6FD.js → pdf-ocr-WM3RZMZY.js} +5 -5
  55. package/dist/{profile-io-RLQ62KS5.js → profile-io-SWGUQSCL.js} +3 -3
  56. package/dist/{rasterize-LBABF2WI.js → rasterize-QA7W6QUF.js} +2 -2
  57. package/dist/render-DRUIPV77.js +10 -0
  58. package/dist/seal-3M4ZSW66.js +10 -0
  59. package/dist/{setup-Q2PRE7UA.js → setup-GUQT5ELJ.js} +23 -3
  60. package/dist/setup-GUQT5ELJ.js.map +1 -0
  61. package/dist/{watch-XEUEGOXW.js → watch-SFQNFU7Q.js} +9 -9
  62. package/package.json +1 -1
  63. package/dist/chunk-DLFZAU4X.cjs.map +0 -1
  64. package/dist/chunk-EFF2JPPA.cjs.map +0 -1
  65. package/dist/chunk-GUYIXVV7.js.map +0 -1
  66. package/dist/chunk-KKZATKQW.cjs.map +0 -1
  67. package/dist/chunk-TXYQJXOV.js.map +0 -1
  68. package/dist/chunk-WMU2KJHF.cjs.map +0 -1
  69. package/dist/chunk-ZF7QL4IY.js.map +0 -1
  70. package/dist/chunks-N4CWHTJI.js +0 -10
  71. package/dist/image-ocr-3AFBDDJI.cjs.map +0 -1
  72. package/dist/parser-MRM6WICO.cjs.map +0 -1
  73. package/dist/pdf-ocr-5BRMIJAT.cjs +0 -13
  74. package/dist/pdf-ocr-5BRMIJAT.cjs.map +0 -1
  75. package/dist/pdf-ocr-UDTEQEWA.js +0 -12
  76. package/dist/render-CYXQEHS7.js +0 -10
  77. package/dist/seal-SV6PFFYU.js +0 -10
  78. package/dist/setup-Q2PRE7UA.js.map +0 -1
  79. /package/dist/{-NFHVGTVM.js.map → -2M56QRNH.js.map} +0 -0
  80. /package/dist/{chunk-MYD3QLBL.js.map → chunk-7KRCQE3P.js.map} +0 -0
  81. /package/dist/{chunk-OLDIDBJ2.js.map → chunk-7Z3NHIRR.js.map} +0 -0
  82. /package/dist/{chunk-MOOVF6CT.js.map → chunk-DOLK5KIS.js.map} +0 -0
  83. /package/dist/{chunk-2L7MIKOM.js.map → chunk-E2K4SNMD.js.map} +0 -0
  84. /package/dist/{chunk-X77U36TV.js.map → chunk-GFTAPAJS.js.map} +0 -0
  85. /package/dist/{chunk-FHYLLKIP.js.map → chunk-H6O65EPK.js.map} +0 -0
  86. /package/dist/{chunk-DSL6EVFJ.js.map → chunk-I53FOXZR.js.map} +0 -0
  87. /package/dist/{chunk-GHMVNMUN.js.map → chunk-LWNFAIYG.js.map} +0 -0
  88. /package/dist/{chunk-T4AWY45Q.js.map → chunk-PMBWFYZQ.js.map} +0 -0
  89. /package/dist/{chunk-IXHBRMDB.js.map → chunk-PQ46DC6Y.js.map} +0 -0
  90. /package/dist/{chunk-L5B7PQOP.js.map → chunk-WMM6XVQX.js.map} +0 -0
  91. /package/dist/{chunk-LUJN3VFB.js.map → chunk-ZHRYLT3N.js.map} +0 -0
  92. /package/dist/{chunks-N4CWHTJI.js.map → chunks-GT45ALC5.js.map} +0 -0
  93. /package/dist/{image-ocr-S4REURLR.js.map → image-ocr-HY42AVXC.js.map} +0 -0
  94. /package/dist/{image-ocr-TGHAMIQL.js.map → image-ocr-WCIDB6RY.js.map} +0 -0
  95. /package/dist/{parser-C3APVZGT.js.map → parser-SVZPCCRG.js.map} +0 -0
  96. /package/dist/{parser-KMC4YOZH.js.map → parser-WRNS6MX2.js.map} +0 -0
  97. /package/dist/{pdf-ocr-UDTEQEWA.js.map → pdf-ocr-7AAHJOXQ.js.map} +0 -0
  98. /package/dist/{pdf-ocr-UURMV6FD.js.map → pdf-ocr-WM3RZMZY.js.map} +0 -0
  99. /package/dist/{profile-io-RLQ62KS5.js.map → profile-io-SWGUQSCL.js.map} +0 -0
  100. /package/dist/{rasterize-LBABF2WI.js.map → rasterize-QA7W6QUF.js.map} +0 -0
  101. /package/dist/{render-CYXQEHS7.js.map → render-DRUIPV77.js.map} +0 -0
  102. /package/dist/{seal-SV6PFFYU.js.map → seal-3M4ZSW66.js.map} +0 -0
  103. /package/dist/{watch-XEUEGOXW.js.map → watch-SFQNFU7Q.js.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -99,7 +99,8 @@ interface IRCell {
99
99
  rowSpan: number;
100
100
  /**
101
101
  * 셀 내부 블록 콘텐츠 — v3.0.
102
- * 중첩 표·이미지·다중 문단을 구조 그대로 보존한다.
102
+ * 중첩 표·이미지·다중 문단을 구조 그대로, 문서(원문) 순서대로 보존한다.
103
+ * 표와 텍스트가 한 줄에 번갈아 놓인 셀도 배치 순서를 따른다 (v4.2.3, #49).
103
104
  * blocks가 있으면 text는 blocks의 평탄화 텍스트(하위 호환용)다.
104
105
  */
105
106
  blocks?: IRBlock[];
@@ -218,7 +219,11 @@ interface ParseSuccess extends ParseResultBase {
218
219
  success: true;
219
220
  /** 추출된 마크다운 텍스트 */
220
221
  markdown: string;
221
- /** 중간 표현 블록 (구조화된 데이터 접근용) */
222
+ /**
223
+ * 중간 표현 블록 (구조화된 데이터 접근용).
224
+ * 블록은 문서(원문) 읽기 순서를 따른다 — 한 문단 안에 글자취급(treatAsChar)
225
+ * 표와 텍스트가 섞여 있어도 배치 순서대로 방출된다 (v4.2.3, #50).
226
+ */
222
227
  blocks: IRBlock[];
223
228
  /** 문서 메타데이터 */
224
229
  metadata?: DocumentMetadata;
package/dist/index.d.ts CHANGED
@@ -99,7 +99,8 @@ interface IRCell {
99
99
  rowSpan: number;
100
100
  /**
101
101
  * 셀 내부 블록 콘텐츠 — v3.0.
102
- * 중첩 표·이미지·다중 문단을 구조 그대로 보존한다.
102
+ * 중첩 표·이미지·다중 문단을 구조 그대로, 문서(원문) 순서대로 보존한다.
103
+ * 표와 텍스트가 한 줄에 번갈아 놓인 셀도 배치 순서를 따른다 (v4.2.3, #49).
103
104
  * blocks가 있으면 text는 blocks의 평탄화 텍스트(하위 호환용)다.
104
105
  */
105
106
  blocks?: IRBlock[];
@@ -218,7 +219,11 @@ interface ParseSuccess extends ParseResultBase {
218
219
  success: true;
219
220
  /** 추출된 마크다운 텍스트 */
220
221
  markdown: string;
221
- /** 중간 표현 블록 (구조화된 데이터 접근용) */
222
+ /**
223
+ * 중간 표현 블록 (구조화된 데이터 접근용).
224
+ * 블록은 문서(원문) 읽기 순서를 따른다 — 한 문단 안에 글자취급(treatAsChar)
225
+ * 표와 텍스트가 섞여 있어도 배치 순서대로 방출된다 (v4.2.3, #50).
226
+ */
222
227
  blocks: IRBlock[];
223
228
  /** 문서 메타데이터 */
224
229
  metadata?: DocumentMetadata;
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  flattenLayoutTables,
9
9
  inlineImagesIntoMarkdown,
10
10
  mapPuaText
11
- } from "./chunk-IXHBRMDB.js";
11
+ } from "./chunk-PQ46DC6Y.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-GUYIXVV7.js";
30
+ } from "./chunk-OBX3VSIZ.js";
31
31
 
32
32
  // src/index.ts
33
33
  import { readFile } from "fs/promises";
@@ -2105,7 +2105,7 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
2105
2105
  }
2106
2106
  break;
2107
2107
  case "p": {
2108
- const { text: rawText, href, footnote, style } = extractParagraphInfo(el, ctx.styleMap, ctx);
2108
+ const { text: rawText, href, footnote, style, segments } = extractParagraphInfo(el, ctx.styleMap, ctx);
2109
2109
  let text = rawText;
2110
2110
  let headingLevel;
2111
2111
  const ph = resolveParaHeading(el, ctx);
@@ -2113,6 +2113,35 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
2113
2113
  if (ph?.prefix) text = ph.prefix + " " + text;
2114
2114
  headingLevel = ph?.headingLevel;
2115
2115
  }
2116
+ if (segments) {
2117
+ const cell2 = tableCtx?.cell ?? null;
2118
+ const segs = [...segments];
2119
+ if (ph?.prefix) {
2120
+ const fi = segs.findIndex((s) => s);
2121
+ if (fi >= 0) segs[fi] = ph.prefix + " " + segs[fi];
2122
+ }
2123
+ let segIdx = 0;
2124
+ let first = true;
2125
+ const flush = () => {
2126
+ const s = segs[segIdx++];
2127
+ if (!s) return;
2128
+ const block = { type: "paragraph", text: s, pageNumber: ctx.sectionNum };
2129
+ if (first && !cell2) {
2130
+ first = false;
2131
+ if (style) block.style = style;
2132
+ if (href) block.href = href;
2133
+ if (footnote) block.footnoteText = footnote;
2134
+ }
2135
+ if (cell2) {
2136
+ cell2.text += (cell2.text ? "\n" : "") + s;
2137
+ (cell2.blocks ??= []).push(block);
2138
+ } else blocks.push(block);
2139
+ };
2140
+ tableCtx = walkParagraphChildren(el, blocks, tableCtx, tableStack, ctx, depth + 1, flush);
2141
+ while (segIdx < segs.length) flush();
2142
+ if (footnote && cell2) cell2.text += (cell2.text ? "\n" : "") + `(\uC8FC: ${footnote})`;
2143
+ break;
2144
+ }
2116
2145
  if (text) {
2117
2146
  if (tableCtx?.cell) {
2118
2147
  const cell2 = tableCtx.cell;
@@ -2331,7 +2360,7 @@ function findTopLevelTbls(el, out, depth = 0) {
2331
2360
  findTopLevelTbls(ch, out, depth + 1);
2332
2361
  }
2333
2362
  }
2334
- function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
2363
+ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth = 0, onTbl) {
2335
2364
  if (depth > MAX_XML_DEPTH) return tableCtx;
2336
2365
  const children = node.childNodes;
2337
2366
  if (!children) return tableCtx;
@@ -2345,6 +2374,7 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
2345
2374
  const tag = el.tagName || el.localName || "";
2346
2375
  const localTag = tag.replace(/^[^:]+:/, "");
2347
2376
  if (localTag === "tbl") {
2377
+ if (onTbl) onTbl();
2348
2378
  if (!tableCtx) {
2349
2379
  const chan = kordocTableChannel(el, ctx);
2350
2380
  if (chan) {
@@ -2391,6 +2421,9 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
2391
2421
  walkChildren(node, depth);
2392
2422
  return tableCtx;
2393
2423
  }
2424
+ function isInlineTbl(tbl2) {
2425
+ return findChildByLocalName(tbl2, "pos")?.getAttribute("treatAsChar") === "1";
2426
+ }
2394
2427
  function findDescendant(node, targetTag, depth = 0) {
2395
2428
  if (depth > 5) return null;
2396
2429
  const children = node.childNodes;
@@ -2564,7 +2597,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2564
2597
  ctx.warnings?.push({ page: ctx.sectionNum, message: "\uBCC0\uACBD\uCD94\uC801 \uC0AD\uC81C \uD14D\uC2A4\uD2B8 \uCD9C\uB825 \uC81C\uC678", code: "HIDDEN_TEXT_FILTERED" });
2565
2598
  }
2566
2599
  } else {
2567
- text += t;
2600
+ text += t.replace(/\x1E/g, "");
2568
2601
  }
2569
2602
  continue;
2570
2603
  }
@@ -2595,9 +2628,12 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2595
2628
  case "hwSpace":
2596
2629
  text += " ";
2597
2630
  break;
2631
+ // 테이블 자체는 walkSection에서 처리 — 글자취급(inline) 표만 경계 마커를 남겨
2632
+ // 표 앞뒤 텍스트를 문서 순서대로 분할 방출할 수 있게 한다 (#49/#50).
2633
+ // float·페이지 앵커 표는 텍스트 흐름 불참(reflow 모델 정합) — 종전대로 텍스트 뒤 방출
2598
2634
  case "tbl":
2635
+ if (isInlineTbl(child)) text += "";
2599
2636
  break;
2600
- // 테이블은 walkSection에서 처리
2601
2637
  // 하이퍼링크
2602
2638
  case "hyperlink": {
2603
2639
  const url = child.getAttribute("url") || child.getAttribute("href") || "";
@@ -2692,7 +2728,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2692
2728
  for (const r of closed) {
2693
2729
  if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
2694
2730
  const anchor = text.slice(r.start, r.end);
2695
- if (!anchor.trim() || /[\n\x1F\[\]]/.test(anchor)) continue;
2731
+ if (!anchor.trim() || /[\n\x1F\x1E\[\]]/.test(anchor)) continue;
2696
2732
  text = text.slice(0, r.start) + `[${anchor}](${r.url})` + text.slice(r.end);
2697
2733
  applied.push([r.start, r.end]);
2698
2734
  }
@@ -2700,10 +2736,18 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2700
2736
  }
2701
2737
  const leaderIdx = text.indexOf("");
2702
2738
  if (leaderIdx >= 0) text = text.substring(0, leaderIdx);
2703
- let cleanText = text.replace(/[ \t]+/g, " ").trim();
2704
- if (/^그림입니다\.?\s*원본\s*그림의\s*(이름|크기)/.test(cleanText)) cleanText = "";
2705
- cleanText = cleanText.replace(/그림입니다\.?\s*원본\s*그림의\s*(이름|크기)[^\n]*(\n[^\n]*원본\s*그림의\s*(이름|크기)[^\n]*)*/g, "").trim();
2706
- cleanText = cleanText.replace(/^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|선|직선|곡선|화살표|오각형|육각형|팔각형|별|십자|구름|마름모|도넛|평행사변형|사다리꼴|개체|그리기\s?개체|묶음\s?개체|글상자|표|그림|OLE\s?개체)\s?입니다\.?$/gm, "").trim();
2739
+ const cleanParaText = (raw) => {
2740
+ let t = raw.replace(/[ \t]+/g, " ").trim();
2741
+ if (/^그림입니다\.?\s*원본\s*그림의\s*(이름|크기)/.test(t)) t = "";
2742
+ t = t.replace(/그림입니다\.?\s*원본\s*그림의\s*(이름|크기)[^\n]*(\n[^\n]*원본\s*그림의\s*(이름|크기)[^\n]*)*/g, "").trim();
2743
+ return t.replace(/^(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|선|직선|곡선|화살표|오각형|육각형|팔각형|별|십자|구름|마름모|도넛|평행사변형|사다리꼴|개체|그리기\s?개체|묶음\s?개체|글상자|표|그림|OLE\s?개체)\s?입니다\.?$/gm, "").trim();
2744
+ };
2745
+ let segments;
2746
+ if (text.includes("")) {
2747
+ segments = text.split("").map(cleanParaText);
2748
+ text = text.replace(/\x1E/g, "");
2749
+ }
2750
+ const cleanText = cleanParaText(text);
2707
2751
  let style;
2708
2752
  if (styleMap && charPrId) {
2709
2753
  const charProp = styleMap.charProperties.get(charPrId);
@@ -2716,7 +2760,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2716
2760
  if (!style.fontSize && !style.bold && !style.italic) style = void 0;
2717
2761
  }
2718
2762
  }
2719
- return { text: cleanText, href, footnote, style };
2763
+ return { text: cleanText, href, footnote, style, segments };
2720
2764
  }
2721
2765
  var KORDOC_CHAR_CODE = "4";
2722
2766
  var KORDOC_PARA_QUOTE = "6";
@@ -23669,6 +23713,18 @@ function htmlCellInnerToLines(inner) {
23669
23713
  const lines = work.split(/<br\s*\/?>/gi).map((s) => s.trim()).filter((s) => s.length > 0);
23670
23714
  return { lines, hadNonText, imgSrcs };
23671
23715
  }
23716
+ function splitCellByTopLevelTables(html) {
23717
+ const tables = extractTopLevelTables(html);
23718
+ const texts = [];
23719
+ let rest = html;
23720
+ for (const t of tables) {
23721
+ const i = rest.indexOf(t);
23722
+ texts.push(rest.slice(0, i));
23723
+ rest = rest.slice(i + t.length);
23724
+ }
23725
+ texts.push(rest);
23726
+ return { texts, tables };
23727
+ }
23672
23728
  function extractTopLevelTables(html) {
23673
23729
  const result = [];
23674
23730
  let depth = 0;
@@ -24347,17 +24403,18 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
24347
24403
  const rowSpan = Math.min(cell2.rowSpan, rowCnt - cell2.r);
24348
24404
  const lines = cellLines[i];
24349
24405
  let nestedH = 0;
24350
- const nestedXmls = [];
24351
- for (const nested of extractTopLevelTables(cell2.inner)) {
24406
+ const { texts: segTexts, tables: nestedTables } = splitCellByTopLevelTables(cell2.inner);
24407
+ const nestedXmls = nestedTables.map((nested) => {
24352
24408
  const sw = spanW(cell2);
24353
24409
  const nestedW = Math.max(Math.min(Math.max(sw - 1020, 4e3), sw - 282), 500);
24354
24410
  const nestedXml = generateHtmlTableXml(nested, theme, nestedW, style ? { ...style, totalWidth: nestedW } : null);
24355
24411
  if (nestedXml) {
24356
- nestedXmls.push(nestedXml);
24357
24412
  const szH = nestedXml.match(/<hp:sz [^>]*height="(\d+)"/)?.[1];
24358
24413
  nestedH += (szH ? Number(szH) : (nested.match(/<tr[\s>]/gi) ?? []).length * cellH) + 300;
24359
24414
  }
24360
- }
24415
+ return nestedXml;
24416
+ });
24417
+ const segLines = segTexts.map((t) => htmlCellInnerToLines(t).lines);
24361
24418
  const usable = Math.max(spanW(cell2) - CELL_PAD, 1e3);
24362
24419
  let wrapLines = 0;
24363
24420
  for (const line of lines) wrapLines += Math.max(1, Math.ceil(measureTextWidth(unescapeHtml(line).trim(), measureH, 100) / usable));
@@ -24366,9 +24423,9 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
24366
24423
  const cellHeight = Math.max(prof?.cellH.get(`${cell2.r},${cell2.c}`) ?? 0, contentH);
24367
24424
  const perRow = Math.ceil(cellHeight / rowSpan);
24368
24425
  for (let r = cell2.r; r < cell2.r + rowSpan; r++) tableRowHeights[r] = Math.max(tableRowHeights[r], perRow);
24369
- return { cell: cell2, rowSpan, lines, nestedXmls, imgSrcs: cellParsed[i].imgSrcs };
24426
+ return { cell: cell2, rowSpan, lines, nestedXmls, segLines, imgSrcs: cellParsed[i].imgSrcs };
24370
24427
  });
24371
- const tcXmls = meta.map(({ cell: cell2, rowSpan, lines, nestedXmls, imgSrcs }) => {
24428
+ const tcXmls = meta.map(({ cell: cell2, rowSpan, nestedXmls, segLines, imgSrcs }) => {
24372
24429
  const k = `${cell2.r},${cell2.c}`;
24373
24430
  const isHeader = cell2.isHeader;
24374
24431
  const baseCharPr = style ? style.charPr : CHAR_NORMAL;
@@ -24379,7 +24436,7 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
24379
24436
  const paraPrId = style ? centered ? reg ? style.tblCenterParaPr ?? style.centerParaPr : style.centerParaPr : reg ? style.tblLeftParaPr ?? PARA_NORMAL : PARA_NORMAL : PARA_NORMAL;
24380
24437
  const picUrls = images ? [...imgSrcs] : [];
24381
24438
  const paras = [];
24382
- for (const line of lines) {
24439
+ const pushTextLine = (line) => {
24383
24440
  let text = unescapeHtml(line);
24384
24441
  if (images) {
24385
24442
  const { text: rest, urls } = splitImageRefs(text);
@@ -24391,7 +24448,14 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
24391
24448
  if (!images || text.trim() || picUrls.length === 0) {
24392
24449
  paras.push(`<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0"><hp:run charPrIDRef="${charPrId}"><hp:t>${escapeXml(text)}</hp:t></hp:run></hp:p>`);
24393
24450
  }
24394
- }
24451
+ };
24452
+ segLines.forEach((seg, si) => {
24453
+ for (const line of seg) pushTextLine(line);
24454
+ const nestedXml = nestedXmls[si];
24455
+ if (nestedXml) {
24456
+ paras.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${nestedXml}</hp:run></hp:p>`);
24457
+ }
24458
+ });
24395
24459
  if (images && picUrls.length > 0) {
24396
24460
  const pics = picUrls.map((u) => {
24397
24461
  const part = images.take(u);
@@ -24401,9 +24465,6 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3, style = null, r
24401
24465
  paras.push(`<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0"><hp:run charPrIDRef="${charPrId}">${pics.join("")}</hp:run></hp:p>`);
24402
24466
  }
24403
24467
  }
24404
- for (const nestedXml of nestedXmls) {
24405
- paras.push(`<hp:p paraPrIDRef="0" styleIDRef="0"><hp:run charPrIDRef="0">${nestedXml}</hp:run></hp:p>`);
24406
- }
24407
24468
  if (paras.length === 0) {
24408
24469
  paras.push(`<hp:p paraPrIDRef="${paraPrId}" styleIDRef="0"><hp:run charPrIDRef="${charPrId}"><hp:t></hp:t></hp:run></hp:p>`);
24409
24470
  }
@@ -30497,7 +30558,7 @@ async function parse(input, options) {
30497
30558
  }
30498
30559
  async function parseImage(buffer, options) {
30499
30560
  try {
30500
- const { parseImageDocument } = await import("./image-ocr-TGHAMIQL.js");
30561
+ const { parseImageDocument } = await import("./image-ocr-WCIDB6RY.js");
30501
30562
  const { blocks, warnings } = await parseImageDocument(buffer, options);
30502
30563
  return {
30503
30564
  success: true,
@@ -30555,7 +30616,7 @@ async function parseHwp(buffer, options) {
30555
30616
  async function parsePdf(buffer, options) {
30556
30617
  let parsePdfDocument;
30557
30618
  try {
30558
- const mod = await import("./parser-KMC4YOZH.js");
30619
+ const mod = await import("./parser-WRNS6MX2.js");
30559
30620
  parsePdfDocument = mod.parsePdfDocument;
30560
30621
  } catch {
30561
30622
  return {