kordoc 4.1.0 → 4.2.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.
Files changed (109) hide show
  1. package/README.md +25 -5
  2. package/dist/{-AS4IABL2.js → -SXQIZHYA.js} +10 -9
  3. package/dist/{parser-PEOYBXBO.js → chunk-26AJJCFF.js} +1339 -2023
  4. package/dist/chunk-26AJJCFF.js.map +1 -0
  5. package/dist/{parser-XX4QTDFQ.js → chunk-4JPPLIIV.js} +1337 -2019
  6. package/dist/chunk-4JPPLIIV.js.map +1 -0
  7. package/dist/chunk-4VNLZ2GZ.js +13 -0
  8. package/dist/chunk-4VNLZ2GZ.js.map +1 -0
  9. package/dist/{chunk-37HJHCPA.js → chunk-6SHO3BNV.js} +3 -3
  10. package/dist/{chunk-UOO7LSDG.js → chunk-7FCNOKOR.js} +1 -9
  11. package/dist/chunk-7FCNOKOR.js.map +1 -0
  12. package/dist/{chunk-SSTK6IKK.js → chunk-CMN3SYZ3.js} +14 -5
  13. package/dist/chunk-CMN3SYZ3.js.map +1 -0
  14. package/dist/{chunk-F2ZU3IZG.js → chunk-ELOV2GIJ.js} +2 -2
  15. package/dist/chunk-F2HYH62H.cjs +130 -0
  16. package/dist/chunk-F2HYH62H.cjs.map +1 -0
  17. package/dist/{chunk-O5VS7RIR.js → chunk-FSXLSHCW.js} +3 -3
  18. package/dist/{chunk-O5VS7RIR.js.map → chunk-FSXLSHCW.js.map} +1 -1
  19. package/dist/chunk-GEPINOL6.js +83 -0
  20. package/dist/chunk-GEPINOL6.js.map +1 -0
  21. package/dist/chunk-H7OWEYH2.cjs +243 -0
  22. package/dist/chunk-H7OWEYH2.cjs.map +1 -0
  23. package/dist/{chunk-L2XQQTOY.js → chunk-IGGRLWT5.js} +126 -46
  24. package/dist/chunk-IGGRLWT5.js.map +1 -0
  25. package/dist/chunk-J2RZ444H.js +243 -0
  26. package/dist/chunk-J2RZ444H.js.map +1 -0
  27. package/dist/chunk-JP5YH3Z4.js +130 -0
  28. package/dist/chunk-JP5YH3Z4.js.map +1 -0
  29. package/dist/{parser-N4A7UGDK.cjs → chunk-LHROM2BO.cjs} +1300 -1985
  30. package/dist/chunk-LHROM2BO.cjs.map +1 -0
  31. package/dist/chunk-NNDVFNMJ.js +246 -0
  32. package/dist/chunk-NNDVFNMJ.js.map +1 -0
  33. package/dist/{chunk-WO52HVQJ.js → chunk-PLIY23LY.js} +2 -2
  34. package/dist/{chunk-GQVSHGG4.js → chunk-V6U6YS5B.js} +2 -2
  35. package/dist/{chunk-4KI23VHA.js → chunk-WF2E5P2G.js} +16 -130
  36. package/dist/chunk-WF2E5P2G.js.map +1 -0
  37. package/dist/{chunk-AX2R5Q2N.js → chunk-WQLHPOMJ.js} +3 -3
  38. package/dist/{chunk-37VKMUST.cjs → chunk-XTCT6KQ5.cjs} +34 -148
  39. package/dist/chunk-XTCT6KQ5.cjs.map +1 -0
  40. package/dist/chunks-ZQEFAZNC.js +10 -0
  41. package/dist/cli.js +76 -19
  42. package/dist/cli.js.map +1 -1
  43. package/dist/{formula-RXVSQPXI.js → formula-KSNAEBZ2.js} +23 -232
  44. package/dist/formula-KSNAEBZ2.js.map +1 -0
  45. package/dist/{formula-5NKVS2LR.cjs → formula-SB3NHDUM.cjs} +30 -240
  46. package/dist/formula-SB3NHDUM.cjs.map +1 -0
  47. package/dist/{formula-JCNF43NE.js → formula-SXC6LRRC.js} +23 -233
  48. package/dist/formula-SXC6LRRC.js.map +1 -0
  49. package/dist/index.cjs +527 -447
  50. package/dist/index.cjs.map +1 -1
  51. package/dist/index.d.cts +7 -3
  52. package/dist/index.d.ts +7 -3
  53. package/dist/index.js +129 -49
  54. package/dist/index.js.map +1 -1
  55. package/dist/mcp.js +21 -19
  56. package/dist/mcp.js.map +1 -1
  57. package/dist/models-KA4GLQK5.js +25 -0
  58. package/dist/parser-ND2YGQZR.js +800 -0
  59. package/dist/parser-ND2YGQZR.js.map +1 -0
  60. package/dist/parser-RBZHA6SY.js +804 -0
  61. package/dist/parser-RBZHA6SY.js.map +1 -0
  62. package/dist/parser-WDZOMDG4.cjs +803 -0
  63. package/dist/parser-WDZOMDG4.cjs.map +1 -0
  64. package/dist/pdf-ocr-2Z7VZIFI.cjs +439 -0
  65. package/dist/pdf-ocr-2Z7VZIFI.cjs.map +1 -0
  66. package/dist/pdf-ocr-FJFXFADQ.js +438 -0
  67. package/dist/pdf-ocr-FJFXFADQ.js.map +1 -0
  68. package/dist/pdf-ocr-VYE4DHD4.js +386 -0
  69. package/dist/pdf-ocr-VYE4DHD4.js.map +1 -0
  70. package/dist/{profile-io-PLDQFPJA.js → profile-io-TWHDIVPL.js} +3 -3
  71. package/dist/{rasterize-WWNQLKYW.js → rasterize-W2NEZUSW.js} +2 -2
  72. package/dist/render-4MG5QUDG.js +10 -0
  73. package/dist/seal-D2QNXJVO.js +10 -0
  74. package/dist/seal-D2QNXJVO.js.map +1 -0
  75. package/dist/{watch-SFHXZALC.js → watch-VWXJZT2R.js} +11 -10
  76. package/dist/watch-VWXJZT2R.js.map +1 -0
  77. package/package.json +2 -1
  78. package/dist/chunk-37VKMUST.cjs.map +0 -1
  79. package/dist/chunk-4KI23VHA.js.map +0 -1
  80. package/dist/chunk-L2XQQTOY.js.map +0 -1
  81. package/dist/chunk-SSTK6IKK.js.map +0 -1
  82. package/dist/chunk-UOO7LSDG.js.map +0 -1
  83. package/dist/chunks-WVMGF7JL.js +0 -10
  84. package/dist/formula-5NKVS2LR.cjs.map +0 -1
  85. package/dist/formula-JCNF43NE.js.map +0 -1
  86. package/dist/formula-RXVSQPXI.js.map +0 -1
  87. package/dist/parser-N4A7UGDK.cjs.map +0 -1
  88. package/dist/parser-PEOYBXBO.js.map +0 -1
  89. package/dist/parser-XX4QTDFQ.js.map +0 -1
  90. package/dist/provider-4FAYHJ6N.cjs +0 -39
  91. package/dist/provider-4FAYHJ6N.cjs.map +0 -1
  92. package/dist/provider-C6IOGIS5.js +0 -37
  93. package/dist/provider-C6IOGIS5.js.map +0 -1
  94. package/dist/provider-UIBW2MIH.js +0 -39
  95. package/dist/provider-UIBW2MIH.js.map +0 -1
  96. package/dist/render-T7S6H6AN.js +0 -10
  97. package/dist/seal-7PTL6MXH.js +0 -10
  98. package/dist/watch-SFHXZALC.js.map +0 -1
  99. /package/dist/{-AS4IABL2.js.map → -SXQIZHYA.js.map} +0 -0
  100. /package/dist/{chunk-37HJHCPA.js.map → chunk-6SHO3BNV.js.map} +0 -0
  101. /package/dist/{chunk-F2ZU3IZG.js.map → chunk-ELOV2GIJ.js.map} +0 -0
  102. /package/dist/{chunk-WO52HVQJ.js.map → chunk-PLIY23LY.js.map} +0 -0
  103. /package/dist/{chunk-GQVSHGG4.js.map → chunk-V6U6YS5B.js.map} +0 -0
  104. /package/dist/{chunk-AX2R5Q2N.js.map → chunk-WQLHPOMJ.js.map} +0 -0
  105. /package/dist/{chunks-WVMGF7JL.js.map → chunks-ZQEFAZNC.js.map} +0 -0
  106. /package/dist/{profile-io-PLDQFPJA.js.map → models-KA4GLQK5.js.map} +0 -0
  107. /package/dist/{render-T7S6H6AN.js.map → profile-io-TWHDIVPL.js.map} +0 -0
  108. /package/dist/{rasterize-WWNQLKYW.js.map → rasterize-W2NEZUSW.js.map} +0 -0
  109. /package/dist/{seal-7PTL6MXH.js.map → render-4MG5QUDG.js.map} +0 -0
@@ -1,10 +1,12 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ inlineImagesIntoMarkdown
4
+ } from "./chunk-7FCNOKOR.js";
2
5
  import {
3
6
  HEADING_RATIO_H1,
4
7
  HEADING_RATIO_H2,
5
- HEADING_RATIO_H3,
6
- inlineImagesIntoMarkdown
7
- } from "./chunk-UOO7LSDG.js";
8
+ HEADING_RATIO_H3
9
+ } from "./chunk-4VNLZ2GZ.js";
8
10
  import {
9
11
  detectFormat,
10
12
  detectOle2Format,
@@ -25,7 +27,7 @@ import {
25
27
  paraTextPureT,
26
28
  patchZipEntries,
27
29
  scanSectionXml
28
- } from "./chunk-AX2R5Q2N.js";
30
+ } from "./chunk-WQLHPOMJ.js";
29
31
  import {
30
32
  MAX_COLS,
31
33
  MAX_ROWS,
@@ -35,14 +37,14 @@ import {
35
37
  dedupeRunningHeaders,
36
38
  flattenLayoutTables,
37
39
  mapPuaText
38
- } from "./chunk-SSTK6IKK.js";
40
+ } from "./chunk-CMN3SYZ3.js";
39
41
  import {
40
42
  SPACE_EM_FIXED,
41
43
  charWidthEm1000,
42
44
  fitRatioForFewerLines,
43
45
  measureTextWidth,
44
46
  simulateWrap
45
- } from "./chunk-37HJHCPA.js";
47
+ } from "./chunk-6SHO3BNV.js";
46
48
  import {
47
49
  MAX_DECOMPRESS_SIZE,
48
50
  MAX_XML_DEPTH,
@@ -54,7 +56,7 @@ import {
54
56
  createXmlParser,
55
57
  extractTextFromNode,
56
58
  findChildByLocalName
57
- } from "./chunk-GQVSHGG4.js";
59
+ } from "./chunk-V6U6YS5B.js";
58
60
  import {
59
61
  KordocError,
60
62
  classifyError,
@@ -66,7 +68,7 @@ import {
66
68
  sanitizeHref,
67
69
  stripDtd,
68
70
  toArrayBuffer
69
- } from "./chunk-O5VS7RIR.js";
71
+ } from "./chunk-FSXLSHCW.js";
70
72
 
71
73
  // src/index.ts
72
74
  import { readFile } from "fs/promises";
@@ -1712,6 +1714,19 @@ function findKordocMarkedCell(el, depth) {
1712
1714
  }
1713
1715
  return null;
1714
1716
  }
1717
+ function hasPageAutoNum(el, depth = 0) {
1718
+ if (depth > 10) return false;
1719
+ const children = el.childNodes;
1720
+ if (!children) return false;
1721
+ for (let i = 0; i < children.length; i++) {
1722
+ const ch = children[i];
1723
+ if (ch.nodeType !== 1) continue;
1724
+ const tag = (ch.tagName || ch.localName || "").replace(/^[^:]+:/, "");
1725
+ if (tag === "autoNum" && ch.getAttribute?.("numType") === "PAGE") return true;
1726
+ if (hasPageAutoNum(ch, depth + 1)) return true;
1727
+ }
1728
+ return false;
1729
+ }
1715
1730
  function collectSubListText(el, ctx, depth = 0) {
1716
1731
  if (depth > 10) return "";
1717
1732
  const parts = [];
@@ -1890,6 +1905,22 @@ function extractParagraphInfo(para2, styleMap, ctx) {
1890
1905
  let href;
1891
1906
  let footnote;
1892
1907
  let charPrId;
1908
+ const linkRanges = [];
1909
+ const openFields = [];
1910
+ const onFieldBegin = (el) => {
1911
+ const url = extractHyperlinkHref(el);
1912
+ if (url) {
1913
+ linkRanges.push({ url, start: text.length });
1914
+ openFields.push({ rangeIdx: linkRanges.length - 1 });
1915
+ if (!href) href = url;
1916
+ } else {
1917
+ openFields.push({});
1918
+ }
1919
+ };
1920
+ const onFieldEnd = () => {
1921
+ const open = openFields.pop();
1922
+ if (open?.rangeIdx !== void 0) linkRanges[open.rangeIdx].end = text.length;
1923
+ };
1893
1924
  const handleCtrl = (ctrlEl) => {
1894
1925
  const kids2 = ctrlEl.childNodes;
1895
1926
  if (!kids2) return;
@@ -1899,10 +1930,13 @@ function extractParagraphInfo(para2, styleMap, ctx) {
1899
1930
  const ktag = (k.tagName || k.localName || "").replace(/^[^:]+:/, "");
1900
1931
  switch (ktag) {
1901
1932
  // 머리말/꼬리말 — 문서당 1회 수집, 본문 앞/뒤 배치
1933
+ // 페이지 번호 크롬(autoNum PAGE + 문자 없는 잔여 텍스트, 예: "- 1 -")은 본문 정보가
1934
+ // 아니므로 방출하지 않는다
1902
1935
  case "header":
1903
1936
  case "footer": {
1904
1937
  if (!ctx) break;
1905
1938
  const t = collectSubListText(k, ctx);
1939
+ if (t && hasPageAutoNum(k) && !/\p{L}/u.test(t)) break;
1906
1940
  if (t) {
1907
1941
  const bucket = ktag === "header" ? ctx.shared.pageText.headers : ctx.shared.pageText.footers;
1908
1942
  if (!bucket.includes(t)) bucket.push(t);
@@ -1916,13 +1950,12 @@ function extractParagraphInfo(para2, styleMap, ctx) {
1916
1950
  if (noteText) footnote = (footnote ? footnote + "; " : "") + noteText;
1917
1951
  break;
1918
1952
  }
1919
- // 하이퍼링크 — fieldBegin type=HYPERLINK의 Path 파라미터
1920
- case "fieldBegin": {
1921
- const url = extractHyperlinkHref(k);
1922
- if (url && !href) href = url;
1953
+ // 하이퍼링크 — fieldBegin type=HYPERLINK의 Path 파라미터 (extent 오프셋 추적)
1954
+ case "fieldBegin":
1955
+ onFieldBegin(k);
1923
1956
  break;
1924
- }
1925
1957
  case "fieldEnd":
1958
+ onFieldEnd();
1926
1959
  break;
1927
1960
  // 변경추적 — 삭제 구간(deleteBegin~End)의 텍스트는 출력 제외 (최종본 상태 재현)
1928
1961
  case "deleteBegin":
@@ -2035,12 +2068,10 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2035
2068
  case "ctrl":
2036
2069
  handleCtrl(child);
2037
2070
  break;
2038
- // run 직계 fieldBegin (비표준 경로) — 하이퍼링크 URL 추출
2039
- case "fieldBegin": {
2040
- const url = extractHyperlinkHref(child);
2041
- if (url && !href) href = url;
2071
+ // run 직계 fieldBegin (비표준 경로) — 하이퍼링크 URL·extent 추적
2072
+ case "fieldBegin":
2073
+ onFieldBegin(child);
2042
2074
  break;
2043
- }
2044
2075
  // run 직계 변경추적 마커 (비표준 경로)
2045
2076
  case "deleteBegin":
2046
2077
  if (ctx) ctx.shared.track.deleteDepth++;
@@ -2052,6 +2083,8 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2052
2083
  case "insertEnd":
2053
2084
  break;
2054
2085
  case "fieldEnd":
2086
+ onFieldEnd();
2087
+ break;
2055
2088
  case "parameters":
2056
2089
  case "stringParam":
2057
2090
  case "integerParam":
@@ -2100,6 +2133,18 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2100
2133
  }
2101
2134
  };
2102
2135
  walk(para2);
2136
+ {
2137
+ const applied = [];
2138
+ const closed = linkRanges.filter((r) => r.end !== void 0 && r.end > r.start).sort((a, b) => b.start - a.start);
2139
+ for (const r of closed) {
2140
+ if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
2141
+ const anchor = text.slice(r.start, r.end);
2142
+ if (!anchor.trim() || /[\n\x1F\[\]]/.test(anchor)) continue;
2143
+ text = text.slice(0, r.start) + `[${anchor}](${r.url})` + text.slice(r.end);
2144
+ applied.push([r.start, r.end]);
2145
+ }
2146
+ if (applied.length) href = void 0;
2147
+ }
2103
2148
  const leaderIdx = text.indexOf("");
2104
2149
  if (leaderIdx >= 0) text = text.substring(0, leaderIdx);
2105
2150
  let cleanText = text.replace(/[ \t]+/g, " ").trim();
@@ -16920,8 +16965,50 @@ function decodeJohab(ch) {
16920
16965
  }
16921
16966
  const hit = lookupSymbol(ch);
16922
16967
  if (hit !== null) return hit;
16968
+ return JOHAB_UNMAPPED;
16969
+ }
16970
+ return decodeHwp3Extra(ch);
16971
+ }
16972
+ function decodeHwp3Extra(ch) {
16973
+ if (ch >= 13712 && ch <= 13721) return 8544 + (ch - 13712);
16974
+ if (ch >= 14055 && ch <= 14064) return 9312 + (ch - 14055);
16975
+ switch (ch) {
16976
+ case 129:
16977
+ return 8220;
16978
+ // 왼쪽 큰따옴표
16979
+ case 130:
16980
+ return 8221;
16981
+ // 오른쪽 큰따옴표
16982
+ case 12316:
16983
+ return 9473;
16984
+ // ━ 굵은 가로선 (rhwp: U+F080F, 표시값 직행)
16985
+ case 12349:
16986
+ return 9632;
16987
+ // ■ (rhwp: U+F0827, 표시값 직행)
16988
+ case 13158:
16989
+ return 9633;
16990
+ // □ 글머리 (rhwp: U+F03C5, 한컴 표시값 직행)
16991
+ case 13316:
16992
+ return 8228;
16993
+ // 한 점 리더
16994
+ case 13377:
16995
+ return 9632;
16996
+ // ■
16997
+ case 13382:
16998
+ return 8594;
16999
+ // → 오른쪽 화살표
17000
+ case 13793:
17001
+ return 9472;
17002
+ // ─ 상자 그리기 가로선
17003
+ case 13433:
17004
+ return 9655;
17005
+ // ▷
17006
+ case 13434:
17007
+ return 9654;
17008
+ // ▶
17009
+ default:
17010
+ return JOHAB_UNMAPPED;
16923
17011
  }
16924
- return JOHAB_UNMAPPED;
16925
17012
  }
16926
17013
  function decodeHcharString(bytes) {
16927
17014
  let out = "";
@@ -17041,7 +17128,7 @@ var PARA_SHAPE_SIZE = 187;
17041
17128
  var LINE_INFO_SIZE = 14;
17042
17129
  var INLINE_CHAR_SHAPE_SIZE = 31;
17043
17130
  var SIMPLE_CTRL = /* @__PURE__ */ new Map([
17044
- [9, { extraBytes: 0, extraHchar: 0, emit: " " }],
17131
+ [9, { extraBytes: 6, extraHchar: 3, emit: " " }],
17045
17132
  [7, { extraBytes: 6, extraHchar: 3, emit: "\uFFFC" }],
17046
17133
  [8, { extraBytes: 6, extraHchar: 3, emit: "\uFFFC" }],
17047
17134
  [18, { extraBytes: 6, extraHchar: 3, emit: " " }],
@@ -17217,6 +17304,12 @@ function parseCharStream(reader, charCount, ctx) {
17217
17304
  parseParagraphList2(reader, ctx);
17218
17305
  break;
17219
17306
  }
17307
+ case 5:
17308
+ if (headerVal1 > 0 && headerVal1 < 1e6) reader.skip(headerVal1);
17309
+ break;
17310
+ case 6:
17311
+ reader.skip(34);
17312
+ break;
17220
17313
  case 29:
17221
17314
  if (headerVal1 < 1e6) reader.skip(headerVal1);
17222
17315
  break;
@@ -17494,7 +17587,7 @@ function parseWorksheet(xml, sharedStrings, dateXfs, date1904) {
17494
17587
  }
17495
17588
  return { grid, merges, maxRow, maxCol };
17496
17589
  }
17497
- function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
17590
+ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex, keepAnchoredEmptyCols) {
17498
17591
  const blocks = [];
17499
17592
  if (sheetName) {
17500
17593
  blocks.push({
@@ -17546,7 +17639,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
17546
17639
  cellRows.push(row);
17547
17640
  }
17548
17641
  if (cellRows.length > 0) {
17549
- const table2 = buildTable(cellRows);
17642
+ const table2 = buildTable(cellRows, { keepAnchoredEmptyCols });
17550
17643
  if (table2.rows > 0) {
17551
17644
  blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
17552
17645
  }
@@ -17616,7 +17709,7 @@ async function parseXlsxDocument(buffer, options) {
17616
17709
  try {
17617
17710
  const sheetXml = await sheetFile.async("text");
17618
17711
  const { grid, merges, maxRow, maxCol } = parseWorksheet(sheetXml, sharedStrings, dateXfs, date1904);
17619
- const sheetBlocks = sheetToBlocks(sheet.name, grid, merges, maxRow, maxCol, i);
17712
+ const sheetBlocks = sheetToBlocks(sheet.name, grid, merges, maxRow, maxCol, i, options?.keepTrailingEmptyCols);
17620
17713
  blocks.push(...sheetBlocks);
17621
17714
  } catch (err) {
17622
17715
  warnings.push({
@@ -18165,7 +18258,7 @@ function cellValueToText(v) {
18165
18258
  if (typeof v === "boolean") return v ? "TRUE" : "FALSE";
18166
18259
  return v;
18167
18260
  }
18168
- function sheetToBlocks2(sheetName, sheet, sheetIndex) {
18261
+ function sheetToBlocks2(sheetName, sheet, sheetIndex, keepAnchoredEmptyCols) {
18169
18262
  const blocks = [];
18170
18263
  if (sheetName) {
18171
18264
  blocks.push({
@@ -18238,7 +18331,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
18238
18331
  cellRows.push(row);
18239
18332
  }
18240
18333
  if (cellRows.length > 0) {
18241
- const table2 = buildTable(cellRows);
18334
+ const table2 = buildTable(cellRows, { keepAnchoredEmptyCols });
18242
18335
  if (table2.rows > 0) {
18243
18336
  blocks.push({ type: "table", table: table2, pageNumber: sheetIndex + 1 });
18244
18337
  }
@@ -18319,7 +18412,7 @@ async function parseXlsDocument(buffer, options) {
18319
18412
  }
18320
18413
  try {
18321
18414
  const { sheet } = extractSheetCells(records, bofIdx, globals.sst, convertNum);
18322
- const blocks = sheetToBlocks2(meta.name, sheet, i);
18415
+ const blocks = sheetToBlocks2(meta.name, sheet, i, options?.keepTrailingEmptyCols);
18323
18416
  allBlocks.push(...blocks);
18324
18417
  } catch (e) {
18325
18418
  warnings.push({
@@ -19540,8 +19633,8 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings, keep) {
19540
19633
  for (let j = 0; j < rowCells.length; j++) {
19541
19634
  const cellEl = rowCells[j];
19542
19635
  if (cellEl.nodeType !== 1 || localName(cellEl) !== "CELL") continue;
19543
- const colAddr = parseInt(cellEl.getAttribute("ColAddr") ?? "0", 10);
19544
- const rowAddr = parseInt(cellEl.getAttribute("RowAddr") ?? "0", 10);
19636
+ const colAddr = parseInt(cellEl.getAttribute("ColAddr") ?? "0", 10) || 0;
19637
+ const rowAddr = parseInt(cellEl.getAttribute("RowAddr") ?? "0", 10) || 0;
19545
19638
  const colSpan = Math.min(Math.max(1, parseInt(cellEl.getAttribute("ColSpan") ?? "1", 10) || 1), MAX_TABLE_COLS);
19546
19639
  const rowSpan = Math.min(Math.max(1, parseInt(cellEl.getAttribute("RowSpan") ?? "1", 10) || 1), MAX_TABLE_ROWS);
19547
19640
  const cellText = extractCellText(cellEl);
@@ -19549,24 +19642,11 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings, keep) {
19549
19642
  }
19550
19643
  }
19551
19644
  if (cells.length === 0) return;
19552
- const grid = Array.from({ length: rowCount }, () => Array(colCount).fill(null));
19645
+ const cellRows = Array.from({ length: rowCount }, () => []);
19553
19646
  for (const cell2 of cells) {
19554
- const r = cell2.rowAddr ?? 0;
19555
- const c = cell2.colAddr ?? 0;
19556
- if (isNaN(r) || isNaN(c) || r >= rowCount || c >= colCount) continue;
19557
- grid[r][c] = cell2;
19558
- for (let dr = 0; dr < cell2.rowSpan; dr++) {
19559
- for (let dc = 0; dc < cell2.colSpan; dc++) {
19560
- if (dr === 0 && dc === 0) continue;
19561
- if (r + dr < rowCount && c + dc < colCount) {
19562
- grid[r + dr][c + dc] = { text: "", colSpan: 1, rowSpan: 1 };
19563
- }
19564
- }
19565
- }
19647
+ const r = Math.min(Math.max(cell2.rowAddr ?? 0, 0), rowCount - 1);
19648
+ cellRows[r].push(cell2);
19566
19649
  }
19567
- const cellRows = grid.map(
19568
- (row) => row.map((cell2) => cell2 ?? { text: "", colSpan: 1, rowSpan: 1 })
19569
- );
19570
19650
  const table2 = buildTable(cellRows, { keepAnchoredEmptyCols: keep });
19571
19651
  const caption = extractShapeCaption(el);
19572
19652
  if (caption.text && caption.before) {
@@ -27473,7 +27553,7 @@ async function parseHwp(buffer, options) {
27473
27553
  async function parsePdf(buffer, options) {
27474
27554
  let parsePdfDocument;
27475
27555
  try {
27476
- const mod = await import("./parser-PEOYBXBO.js");
27556
+ const mod = await import("./parser-RBZHA6SY.js");
27477
27557
  parsePdfDocument = mod.parsePdfDocument;
27478
27558
  } catch {
27479
27559
  return {
@@ -27606,4 +27686,4 @@ export {
27606
27686
  parseHwpml,
27607
27687
  fillForm
27608
27688
  };
27609
- //# sourceMappingURL=chunk-L2XQQTOY.js.map
27689
+ //# sourceMappingURL=chunk-IGGRLWT5.js.map