kordoc 4.16.2 → 4.17.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 (150) hide show
  1. package/README.md +14 -13
  2. package/dist/{-4G6MA4X6.js → -PRAKO6M4.js} +11 -11
  3. package/dist/{chunk-AUWGDP4G.js → chunk-2KF5WZCR.js} +2 -2
  4. package/dist/{chunk-UTP2WCHS.js → chunk-4GSF2R7T.js} +4 -4
  5. package/dist/{chunk-TXUKTOG2.js → chunk-4XVNQAK5.js} +219 -23
  6. package/dist/chunk-4XVNQAK5.js.map +1 -0
  7. package/dist/chunk-5CDUL6PH.js +250 -0
  8. package/dist/chunk-5CDUL6PH.js.map +1 -0
  9. package/dist/{chunk-4VODJKFL.js → chunk-6RGGYQQC.js} +3 -3
  10. package/dist/{chunk-DES2LGFZ.js → chunk-A55JGNKD.js} +2 -2
  11. package/dist/chunk-AKB72TEH.cjs +248 -0
  12. package/dist/chunk-AKB72TEH.cjs.map +1 -0
  13. package/dist/{chunk-LEIAEWZ7.js → chunk-BFT5IM2R.js} +2 -2
  14. package/dist/{chunk-KIOQ4N37.js → chunk-BLPR4HRF.js} +2 -2
  15. package/dist/{chunk-JELRWAZC.js → chunk-BZG7K44Z.js} +2 -2
  16. package/dist/{chunk-F4NRLLY4.js → chunk-EFO6JZY6.js} +2 -2
  17. package/dist/chunk-GS7T56RP.cjs.map +1 -1
  18. package/dist/{chunk-JFLAM3MM.js → chunk-I5DJOP62.js} +2 -2
  19. package/dist/chunk-I5DJOP62.js.map +1 -0
  20. package/dist/chunk-J55UQC5H.cjs.map +1 -1
  21. package/dist/{chunk-QOCS7W7R.js → chunk-K2VYABZ3.js} +86 -43
  22. package/dist/chunk-K2VYABZ3.js.map +1 -0
  23. package/dist/chunk-MJBCXW5R.js +248 -0
  24. package/dist/chunk-MJBCXW5R.js.map +1 -0
  25. package/dist/{chunk-MLIS253L.js → chunk-ML4NHUR7.js} +2 -2
  26. package/dist/{chunk-GO5IFOUF.js → chunk-N6V7LQBL.js} +2 -2
  27. package/dist/{chunk-FKUDAIJI.cjs → chunk-O7OUX6NU.cjs} +12 -12
  28. package/dist/chunk-O7OUX6NU.cjs.map +1 -0
  29. package/dist/{chunk-S2PL227Q.js → chunk-PHID6WNG.js} +2 -2
  30. package/dist/{chunk-IQGIT2VX.js → chunk-QJWVMPB6.js} +34 -17
  31. package/dist/chunk-QJWVMPB6.js.map +1 -0
  32. package/dist/{chunk-STM3ORY7.cjs → chunk-QNJLLF4J.cjs} +2 -2
  33. package/dist/chunk-QNJLLF4J.cjs.map +1 -0
  34. package/dist/{chunk-FSDJLAOW.js → chunk-QPJXYJIK.js} +55 -1
  35. package/dist/chunk-QPJXYJIK.js.map +1 -0
  36. package/dist/{chunk-XTFN5WKS.cjs → chunk-R2BUANHQ.cjs} +6 -6
  37. package/dist/chunk-R2BUANHQ.cjs.map +1 -0
  38. package/dist/{chunk-OXLPVQYK.js → chunk-TDQ6XDB3.js} +3 -3
  39. package/dist/{chunk-SFEQYKYJ.js → chunk-WN6OD2CQ.js} +218 -22
  40. package/dist/chunk-WN6OD2CQ.js.map +1 -0
  41. package/dist/{chunk-5KS5PWJR.js → chunk-WY5JAR4O.js} +2 -2
  42. package/dist/{chunk-CEIATRDW.cjs → chunk-WYON5ANU.cjs} +3 -3
  43. package/dist/chunk-WYON5ANU.cjs.map +1 -0
  44. package/dist/{chunk-WDQTFAXY.cjs → chunk-XEPKOC2O.cjs} +240 -44
  45. package/dist/chunk-XEPKOC2O.cjs.map +1 -0
  46. package/dist/{chunk-7KNGSQU7.js → chunk-YZ5HHS6A.js} +2 -2
  47. package/dist/{chunk-P6ZDXTV6.js → chunk-ZF6KHPB7.js} +2 -2
  48. package/dist/chunks-YBFBLJ4G.js +10 -0
  49. package/dist/cli.js +36 -54
  50. package/dist/cli.js.map +1 -1
  51. package/dist/{formula-NARUOXRX.js → formula-7MMFBRGJ.js} +4 -4
  52. package/dist/{formula-WIMV5TUX.cjs → formula-ECNOZT36.cjs} +9 -9
  53. package/dist/formula-ECNOZT36.cjs.map +1 -0
  54. package/dist/{formula-EPKLPDU7.js → formula-SHBXRXOJ.js} +3 -3
  55. package/dist/{image-ocr-3WJ4QH3T.js → image-ocr-P6ECJCT2.js} +8 -8
  56. package/dist/{image-ocr-5BUJQ4TK.js → image-ocr-QCT3A7X5.js} +6 -6
  57. package/dist/{image-ocr-AXWXR6JV.cjs → image-ocr-VUDSP2B4.cjs} +15 -15
  58. package/dist/image-ocr-VUDSP2B4.cjs.map +1 -0
  59. package/dist/index.cjs +768 -710
  60. package/dist/index.cjs.map +1 -1
  61. package/dist/index.d.cts +4 -0
  62. package/dist/index.d.ts +4 -0
  63. package/dist/index.js +106 -48
  64. package/dist/index.js.map +1 -1
  65. package/dist/mcp.js +38 -43
  66. package/dist/mcp.js.map +1 -1
  67. package/dist/{model-bundle-IMBW7D2Z.js → model-bundle-OUHGCEZY.js} +5 -5
  68. package/dist/{models-SY75IBOE.js → models-6D6LMOTH.js} +5 -5
  69. package/dist/page-range-QHHFTL7X.cjs.map +1 -1
  70. package/dist/{parser-ZQM3664Z.js → parser-CTRB7PKD.js} +257 -46
  71. package/dist/parser-CTRB7PKD.js.map +1 -0
  72. package/dist/{parser-2LU4EVU3.cjs → parser-RQ4PJRTJ.cjs} +411 -200
  73. package/dist/parser-RQ4PJRTJ.cjs.map +1 -0
  74. package/dist/{parser-N6476XAC.js → parser-ZPRQ3SSU.js} +260 -49
  75. package/dist/parser-ZPRQ3SSU.js.map +1 -0
  76. package/dist/pdf-ocr-462ZFSHX.js +15 -0
  77. package/dist/pdf-ocr-L35FQYGP.js +18 -0
  78. package/dist/pdf-ocr-STK5EQFF.cjs +16 -0
  79. package/dist/pdf-ocr-STK5EQFF.cjs.map +1 -0
  80. package/dist/{profile-io-GJPKCYPT.js → profile-io-YZUW6MAN.js} +3 -3
  81. package/dist/{rasterize-UOALJQDS.js → rasterize-OUR2QJXX.js} +3 -3
  82. package/dist/{redact-doc-22SYW3KH.js → redact-doc-4OQKG4SM.js} +11 -11
  83. package/dist/{render-MJ4H3R23.js → render-XNO6PZJO.js} +7 -7
  84. package/dist/seal-CJ7C44JN.js +10 -0
  85. package/dist/{setup-2URYVUEO.js → setup-UU3EIHNI.js} +3 -3
  86. package/dist/visual-QRMRFPUK.js +20 -0
  87. package/dist/{watch-ALXZGTOB.js → watch-SR6Q5SQN.js} +12 -12
  88. package/package.json +2 -2
  89. package/dist/chunk-3IB7LBHC.js +0 -57
  90. package/dist/chunk-3IB7LBHC.js.map +0 -1
  91. package/dist/chunk-62W7QCEX.cjs +0 -57
  92. package/dist/chunk-62W7QCEX.cjs.map +0 -1
  93. package/dist/chunk-CEIATRDW.cjs.map +0 -1
  94. package/dist/chunk-FKUDAIJI.cjs.map +0 -1
  95. package/dist/chunk-FSDJLAOW.js.map +0 -1
  96. package/dist/chunk-IQGIT2VX.js.map +0 -1
  97. package/dist/chunk-J3IF6KGW.js +0 -59
  98. package/dist/chunk-J3IF6KGW.js.map +0 -1
  99. package/dist/chunk-JFLAM3MM.js.map +0 -1
  100. package/dist/chunk-QOCS7W7R.js.map +0 -1
  101. package/dist/chunk-SFEQYKYJ.js.map +0 -1
  102. package/dist/chunk-STM3ORY7.cjs.map +0 -1
  103. package/dist/chunk-TXUKTOG2.js.map +0 -1
  104. package/dist/chunk-WDQTFAXY.cjs.map +0 -1
  105. package/dist/chunk-XTFN5WKS.cjs.map +0 -1
  106. package/dist/chunks-NUNIKS2J.js +0 -10
  107. package/dist/formula-WIMV5TUX.cjs.map +0 -1
  108. package/dist/image-ocr-AXWXR6JV.cjs.map +0 -1
  109. package/dist/parser-2LU4EVU3.cjs.map +0 -1
  110. package/dist/parser-N6476XAC.js.map +0 -1
  111. package/dist/parser-ZQM3664Z.js.map +0 -1
  112. package/dist/pdf-ocr-6DEE23IP.js +0 -15
  113. package/dist/pdf-ocr-GHEJVPX2.cjs +0 -16
  114. package/dist/pdf-ocr-GHEJVPX2.cjs.map +0 -1
  115. package/dist/pdf-ocr-MQTWODVU.js +0 -18
  116. package/dist/seal-XWMRUTI4.js +0 -10
  117. package/dist/visual-USPS4QRC.js +0 -20
  118. /package/dist/{-4G6MA4X6.js.map → -PRAKO6M4.js.map} +0 -0
  119. /package/dist/{chunk-AUWGDP4G.js.map → chunk-2KF5WZCR.js.map} +0 -0
  120. /package/dist/{chunk-UTP2WCHS.js.map → chunk-4GSF2R7T.js.map} +0 -0
  121. /package/dist/{chunk-4VODJKFL.js.map → chunk-6RGGYQQC.js.map} +0 -0
  122. /package/dist/{chunk-DES2LGFZ.js.map → chunk-A55JGNKD.js.map} +0 -0
  123. /package/dist/{chunk-LEIAEWZ7.js.map → chunk-BFT5IM2R.js.map} +0 -0
  124. /package/dist/{chunk-KIOQ4N37.js.map → chunk-BLPR4HRF.js.map} +0 -0
  125. /package/dist/{chunk-JELRWAZC.js.map → chunk-BZG7K44Z.js.map} +0 -0
  126. /package/dist/{chunk-F4NRLLY4.js.map → chunk-EFO6JZY6.js.map} +0 -0
  127. /package/dist/{chunk-MLIS253L.js.map → chunk-ML4NHUR7.js.map} +0 -0
  128. /package/dist/{chunk-GO5IFOUF.js.map → chunk-N6V7LQBL.js.map} +0 -0
  129. /package/dist/{chunk-S2PL227Q.js.map → chunk-PHID6WNG.js.map} +0 -0
  130. /package/dist/{chunk-OXLPVQYK.js.map → chunk-TDQ6XDB3.js.map} +0 -0
  131. /package/dist/{chunk-5KS5PWJR.js.map → chunk-WY5JAR4O.js.map} +0 -0
  132. /package/dist/{chunk-7KNGSQU7.js.map → chunk-YZ5HHS6A.js.map} +0 -0
  133. /package/dist/{chunk-P6ZDXTV6.js.map → chunk-ZF6KHPB7.js.map} +0 -0
  134. /package/dist/{chunks-NUNIKS2J.js.map → chunks-YBFBLJ4G.js.map} +0 -0
  135. /package/dist/{formula-NARUOXRX.js.map → formula-7MMFBRGJ.js.map} +0 -0
  136. /package/dist/{formula-EPKLPDU7.js.map → formula-SHBXRXOJ.js.map} +0 -0
  137. /package/dist/{image-ocr-3WJ4QH3T.js.map → image-ocr-P6ECJCT2.js.map} +0 -0
  138. /package/dist/{image-ocr-5BUJQ4TK.js.map → image-ocr-QCT3A7X5.js.map} +0 -0
  139. /package/dist/{model-bundle-IMBW7D2Z.js.map → model-bundle-OUHGCEZY.js.map} +0 -0
  140. /package/dist/{models-SY75IBOE.js.map → models-6D6LMOTH.js.map} +0 -0
  141. /package/dist/{pdf-ocr-6DEE23IP.js.map → pdf-ocr-462ZFSHX.js.map} +0 -0
  142. /package/dist/{pdf-ocr-MQTWODVU.js.map → pdf-ocr-L35FQYGP.js.map} +0 -0
  143. /package/dist/{profile-io-GJPKCYPT.js.map → profile-io-YZUW6MAN.js.map} +0 -0
  144. /package/dist/{rasterize-UOALJQDS.js.map → rasterize-OUR2QJXX.js.map} +0 -0
  145. /package/dist/{redact-doc-22SYW3KH.js.map → redact-doc-4OQKG4SM.js.map} +0 -0
  146. /package/dist/{render-MJ4H3R23.js.map → render-XNO6PZJO.js.map} +0 -0
  147. /package/dist/{seal-XWMRUTI4.js.map → seal-CJ7C44JN.js.map} +0 -0
  148. /package/dist/{setup-2URYVUEO.js.map → setup-UU3EIHNI.js.map} +0 -0
  149. /package/dist/{visual-USPS4QRC.js.map → visual-QRMRFPUK.js.map} +0 -0
  150. /package/dist/{watch-ALXZGTOB.js.map → watch-SR6Q5SQN.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  blocksToPages
4
- } from "./chunk-AUWGDP4G.js";
4
+ } from "./chunk-2KF5WZCR.js";
5
5
  import {
6
6
  allLinesegRemovalSplices,
7
7
  applySplices,
@@ -15,7 +15,7 @@ import {
15
15
  paraTextPureT,
16
16
  patchZipEntries,
17
17
  scanSectionXml
18
- } from "./chunk-4VODJKFL.js";
18
+ } from "./chunk-6RGGYQQC.js";
19
19
  import {
20
20
  CONVERT_MAP,
21
21
  FLAG_COMPRESSED,
@@ -61,16 +61,18 @@ import {
61
61
  renderDocumentToScene,
62
62
  romanNumeral,
63
63
  simulateWrap
64
- } from "./chunk-IQGIT2VX.js";
64
+ } from "./chunk-QJWVMPB6.js";
65
65
  import {
66
+ CELL_EDGES,
66
67
  HEADING_RATIO_H1,
67
68
  HEADING_RATIO_H2,
68
69
  HEADING_RATIO_H3,
69
70
  plainScripts,
70
71
  stripScriptTags,
71
72
  tidyScriptTags,
73
+ unframeLayoutTables,
72
74
  wrapScript
73
- } from "./chunk-J3IF6KGW.js";
75
+ } from "./chunk-5CDUL6PH.js";
74
76
  import {
75
77
  parsePageRange
76
78
  } from "./chunk-VQFA55IC.js";
@@ -89,7 +91,7 @@ import {
89
91
  findChildByLocalName,
90
92
  localName,
91
93
  rawTextContent
92
- } from "./chunk-JFLAM3MM.js";
94
+ } from "./chunk-I5DJOP62.js";
93
95
  import {
94
96
  MAX_COLS,
95
97
  MAX_ROWS,
@@ -104,7 +106,7 @@ import {
104
106
  hasStructuredCellContent,
105
107
  mapPuaText,
106
108
  noteSuffix
107
- } from "./chunk-LEIAEWZ7.js";
109
+ } from "./chunk-BFT5IM2R.js";
108
110
  import {
109
111
  KordocError,
110
112
  classifyError,
@@ -119,7 +121,7 @@ import {
119
121
  toArrayBuffer,
120
122
  unescapeHtml,
121
123
  unzipLimitBytes
122
- } from "./chunk-P6ZDXTV6.js";
124
+ } from "./chunk-ZF6KHPB7.js";
123
125
 
124
126
  // src/table/visual.ts
125
127
  import { readFile as readFile2 } from "fs/promises";
@@ -420,7 +422,8 @@ async function extractHwpxStyles(zip, decompressed) {
420
422
  numberings: /* @__PURE__ */ new Map(),
421
423
  bullets: /* @__PURE__ */ new Map(),
422
424
  paraHeadings: /* @__PURE__ */ new Map(),
423
- paraIndents: /* @__PURE__ */ new Map()
425
+ paraIndents: /* @__PURE__ */ new Map(),
426
+ borderEdges: /* @__PURE__ */ new Map()
424
427
  };
425
428
  const headerPaths = ["Contents/header.xml", "header.xml", "Contents/head.xml", "head.xml"];
426
429
  for (const hp of headerPaths) {
@@ -443,6 +446,7 @@ async function extractHwpxStyles(zip, decompressed) {
443
446
  parseBullets(domDoc, result.bullets);
444
447
  parseParaHeadings(domDoc, result.paraHeadings);
445
448
  parseParaIndents(domDoc, result.paraIndents);
449
+ parseBorderEdges(domDoc, result.borderEdges);
446
450
  break;
447
451
  } catch {
448
452
  continue;
@@ -580,6 +584,26 @@ function parseParaIndents(doc, map) {
580
584
  if (map.size > 0) break;
581
585
  }
582
586
  }
587
+ function parseBorderEdges(doc, map) {
588
+ const tagNames = ["hh:borderFill", "borderFill"];
589
+ for (const tagName of tagNames) {
590
+ const elements = doc.getElementsByTagName(tagName);
591
+ for (let i = 0; i < elements.length; i++) {
592
+ const el = elements[i];
593
+ const id = el.getAttribute("id") || "";
594
+ if (!id) continue;
595
+ const seen = (name) => {
596
+ const b = findChildByLocalName(el, name);
597
+ if (!b) return false;
598
+ const type = b.getAttribute("type") || "NONE";
599
+ const color = (b.getAttribute("color") || "#000000").toUpperCase();
600
+ return type !== "NONE" && color !== "#FFFFFF";
601
+ };
602
+ map.set(id, { t: seen("topBorder"), b: seen("bottomBorder"), l: seen("leftBorder"), r: seen("rightBorder") });
603
+ }
604
+ if (map.size > 0) break;
605
+ }
606
+ }
583
607
  function parseParaHeadings(doc, map) {
584
608
  const tagNames = ["hh:paraPr", "paraPr"];
585
609
  for (const tagName of tagNames) {
@@ -744,6 +768,13 @@ function buildTableWithCellMeta(state, keepAnchoredEmptyCols, keepEmptyParagraph
744
768
  }
745
769
  const srcCount = state.rows.reduce((s, r) => s + r.length, 0);
746
770
  const ordinalReliable = anchors2.length === srcCount;
771
+ for (const row of state.rows) {
772
+ for (const src of row) {
773
+ if (!src.edges || src.rowAddr === void 0 || src.colAddr === void 0) continue;
774
+ const cand = table2.cells[src.rowAddr]?.[src.colAddr];
775
+ if (cand && anchors2.includes(cand)) CELL_EDGES.set(cand, src.edges);
776
+ }
777
+ }
747
778
  const claimed = /* @__PURE__ */ new Set();
748
779
  let flatIdx = -1;
749
780
  for (const row of state.rows) {
@@ -1186,6 +1217,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
1186
1217
  if (tableCtx) {
1187
1218
  tableCtx.cell = { text: "", colSpan: 1, rowSpan: 1 };
1188
1219
  if (el.getAttribute("header") === "1" || el.getAttribute("header") === "true") tableCtx.cell.isHeader = true;
1220
+ const edges = ctx.styleMap?.borderEdges.get(el.getAttribute("borderFillIDRef") ?? "");
1221
+ if (edges) tableCtx.cell.edges = edges;
1189
1222
  walkSection(el, blocks, tableCtx, tableStack, ctx, depth + 1);
1190
1223
  if (tableCtx.cell) {
1191
1224
  tableCtx.currentRow.push(tableCtx.cell);
@@ -1862,15 +1895,13 @@ function extractParagraphInfo(para2, styleMap, ctx) {
1862
1895
  walk(child, depth + 1);
1863
1896
  break;
1864
1897
  // 자식 순회 (tab 등 하위 요소 처리)
1865
- case "tab": {
1866
- const leader = child.getAttribute("leader");
1867
- if (leader && leader !== "0") {
1868
- text += "";
1869
- } else {
1870
- text += " ";
1871
- }
1898
+ // 탭 — 채움(leader≠0, 목차 점선) 탭도 보통 탭. 채움선은 글이 아니라 내지 않고 뒤 글은 남긴다(PDF tab-leaders 가
1899
+ // 점 채움을 탭 하나로 바꾸고 쪽 번호를 남기는 것과 같다). 종전엔 채움 탭 뒤를 쪽 번호로 보고 잘라, 목차 쪽 번호만이 아니라
1900
+ // 일정표 "사용자 의견조사 ····· '26년 8~9월"(gate-fill 36646162)의 일정, 줄바꿈 뒤 다음 목차 항목
1901
+ // "<참고2> 직종별사업체노동력조사 개요"(rhwp issue6044)까지 사라졌다
1902
+ case "tab":
1903
+ text += " ";
1872
1904
  break;
1873
- }
1874
1905
  case "br":
1875
1906
  if ((child.getAttribute("type") || "line") === "line") text += "\n";
1876
1907
  break;
@@ -1992,7 +2023,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
1992
2023
  walk(child, depth + 1);
1993
2024
  if (script && linkRanges.length === nLinks && openFields.length === nOpen && runHasOnlyText(child)) {
1994
2025
  const added = text.slice(start);
1995
- if (added && !/[\x1E\x1F\n$]/.test(added)) text = text.slice(0, start) + wrapScript(added, script);
2026
+ if (added && !/[\x1E\n$]/.test(added)) text = text.slice(0, start) + wrapScript(added, script);
1996
2027
  }
1997
2028
  break;
1998
2029
  }
@@ -2009,14 +2040,12 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2009
2040
  for (const r of closed) {
2010
2041
  if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
2011
2042
  const anchor = text.slice(r.start, r.end);
2012
- if (!anchor.trim() || /[\n\x1F\x1E\[\]]/.test(anchor)) continue;
2043
+ if (!anchor.trim() || /[\n\x1E\[\]]/.test(anchor)) continue;
2013
2044
  text = text.slice(0, r.start) + `[${anchor}](${r.url})` + text.slice(r.end);
2014
2045
  applied.push([r.start, r.end]);
2015
2046
  }
2016
2047
  if (applied.length) href = void 0;
2017
2048
  }
2018
- const leaderIdx = text.indexOf("");
2019
- if (leaderIdx >= 0) text = text.substring(0, leaderIdx);
2020
2049
  text = tidyScriptTags(text);
2021
2050
  const cleanParaText = (raw) => {
2022
2051
  let t = raw.replace(/[ \t]+/g, " ").trim();
@@ -2529,10 +2558,11 @@ async function parseHwpxDocument(buffer, options) {
2529
2558
  const blocks = allBlocks;
2530
2559
  applyPageText(blocks, shared);
2531
2560
  const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !options?.pages);
2532
- detectHwpxHeadings(blocks, styleMap);
2533
- const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
2534
- const markdown = blocksToMarkdown(blocks);
2535
- return { markdown, blocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
2561
+ const shown = options?.layoutTables === "keep" ? blocks : unframeLayoutTables(blocks, !!options?.keepTrailingEmptyCols);
2562
+ detectHwpxHeadings(shown, styleMap);
2563
+ const outline = shown.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
2564
+ const markdown = blocksToMarkdown(shown);
2565
+ return { markdown, blocks: shown, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
2536
2566
  }
2537
2567
 
2538
2568
  // src/hwp3/parser.ts
@@ -15104,7 +15134,6 @@ var MAX_DECOMPRESS_SIZE2 = 100 * 1024 * 1024;
15104
15134
  var PIC_TYPE_DRAWING = 3;
15105
15135
  var OBJ_EQUATION = 2;
15106
15136
  var OPT_HYPERTEXT = 16;
15107
- var LEADER_TAB_MARK = "";
15108
15137
  var OUTLINE_FORMATS = [
15109
15138
  { fmt: "romanUpper", before: "", after: "." },
15110
15139
  { fmt: "digit", before: "", after: ")" },
@@ -15244,8 +15273,6 @@ function parseParagraphList(reader, ctx, sink) {
15244
15273
  }
15245
15274
  function emitHwp3Paragraph(para2) {
15246
15275
  let text = para2.text;
15247
- const leaderAt = text.indexOf(LEADER_TAB_MARK);
15248
- if (leaderAt >= 0) text = text.slice(0, leaderAt);
15249
15276
  let headMarker = null;
15250
15277
  if (para2.outline) {
15251
15278
  const { level, numbers } = para2.outline;
@@ -15273,11 +15300,9 @@ function parseCharStream(reader, charCount, ctx, para2) {
15273
15300
  continue;
15274
15301
  }
15275
15302
  if (ch === 9) {
15276
- reader.skip(2);
15277
- const leader = reader.readU16();
15278
- reader.skip(2);
15303
+ reader.skip(6);
15279
15304
  i += 3;
15280
- para2.text += leader ? LEADER_TAB_MARK : " ";
15305
+ para2.text += " ";
15281
15306
  continue;
15282
15307
  }
15283
15308
  if (ch === 18) {
@@ -17825,8 +17850,10 @@ function collectCharText(node, parts, depth = 0) {
17825
17850
  if (el.nodeType !== 1) continue;
17826
17851
  const tag = localName(el);
17827
17852
  if (tag === "CHAR") {
17828
- const t = rawTextContent(el);
17829
- if (t) parts.push(t);
17853
+ for (const c of Array.from(el.childNodes)) {
17854
+ const t = c.nodeType === 1 ? localName(c) === "TAB" ? " " : rawTextContent(c) : c.nodeType === 3 || c.nodeType === 4 ? c.nodeValue ?? "" : "";
17855
+ if (t) parts.push(t);
17856
+ }
17830
17857
  } else if (tag === "TABLE" || tag === "PICTURE" || tag === "SHAPEOBJECT") {
17831
17858
  } else if (tag === "AUTONUM") {
17832
17859
  } else {
@@ -22428,6 +22455,18 @@ function removeNestedTables(html) {
22428
22455
  if (depth === 0) result += html.slice(last);
22429
22456
  return result;
22430
22457
  }
22458
+ var LAYOUT_MODE_MISMATCH = '\uD3B8\uC9D1 \uB9C8\uD06C\uB2E4\uC6B4\uC774 \uAE30\uBCF8(\uBCF4\uC774\uB294 \uB300\uB85C) \uCD9C\uB825\uC5D0\uC11C \uB098\uC654\uC2B5\uB2C8\uB2E4. \uC774 \uBB38\uC11C\uC5D0\uB294 \uD14C\uB450\uB9AC\uAC00 \uC548 \uBCF4\uC774\uB294 \uD2C0 \uD45C\uAC00 \uC788\uC5B4 \uADF8 \uCD9C\uB825\uC73C\uB85C\uB294 \uC6D0\uBCF8 \uC704\uCE58\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 `kordoc <\uC6D0\uBCF8> --keep-layout-tables`(API: parse(\uC6D0\uBCF8, { layoutTables: "keep" }))\uB85C \uBF51\uC740 \uB9C8\uD06C\uB2E4\uC6B4\uC744 \uACE0\uCCD0 \uB2E4\uC2DC \uD328\uCE58\uD558\uC138\uC694';
22459
+ function editedFromVisual(keepMarkdown, visualMarkdown, editedMarkdown) {
22460
+ if (keepMarkdown === visualMarkdown) return false;
22461
+ const keep = new Set(splitMarkdownUnits(keepMarkdown).map((u) => u.raw));
22462
+ const visual = new Set(splitMarkdownUnits(visualMarkdown).map((u) => u.raw));
22463
+ let k = 0, v = 0;
22464
+ for (const u of splitMarkdownUnits(editedMarkdown)) {
22465
+ if (keep.has(u.raw)) k++;
22466
+ if (visual.has(u.raw)) v++;
22467
+ }
22468
+ return v > k;
22469
+ }
22431
22470
 
22432
22471
  // src/hwpx/gen-table-bf.ts
22433
22472
  var THIN = ["0.12 mm", "#000000"];
@@ -27885,7 +27924,9 @@ async function patchHwp(original, editedMarkdown, options) {
27885
27924
  const compressed = (flags & FLAG_COMPRESSED) !== 0;
27886
27925
  let origBlocks;
27887
27926
  try {
27888
- origBlocks = parseHwp5Document(originalBuf).blocks;
27927
+ const kept = parseHwp5Document(originalBuf, { layoutTables: "keep" });
27928
+ origBlocks = kept.blocks;
27929
+ if (editedFromVisual(kept.markdown, parseHwp5Document(originalBuf).markdown, editedMarkdown)) return fail(LAYOUT_MODE_MISMATCH);
27889
27930
  } catch (err) {
27890
27931
  return fail(`\uC6D0\uBCF8 HWP \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
27891
27932
  }
@@ -27947,7 +27988,7 @@ async function patchHwp(original, editedMarkdown, options) {
27947
27988
  let verification;
27948
27989
  if (options?.verify !== false) {
27949
27990
  try {
27950
- const reparsed = parseHwp5Document(Buffer.from(data));
27991
+ const reparsed = parseHwp5Document(Buffer.from(data), { layoutTables: "keep" });
27951
27992
  const normBr = (u) => ({ ...u, raw: u.raw.replace(/<br\s*\/?\s*>/gi, "\n") });
27952
27993
  verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown).map(normBr), editedUnits.map(normBr));
27953
27994
  } catch (err) {
@@ -28546,8 +28587,10 @@ async function patchHwpx(original, editedMarkdown, options) {
28546
28587
  }
28547
28588
  let origBlocks;
28548
28589
  try {
28549
- const parsed = await parseHwpxDocument(u8ToArrayBuffer(original));
28590
+ const parsed = await parseHwpxDocument(u8ToArrayBuffer(original), { layoutTables: "keep" });
28550
28591
  origBlocks = parsed.blocks;
28592
+ const visual = await parseHwpxDocument(u8ToArrayBuffer(original));
28593
+ if (editedFromVisual(parsed.markdown, visual.markdown, editedMarkdown)) return { success: false, applied: 0, skipped, error: LAYOUT_MODE_MISMATCH };
28551
28594
  } catch (err) {
28552
28595
  return { success: false, applied: 0, skipped, error: `\uC6D0\uBCF8 HWPX \uD30C\uC2F1 \uC2E4\uD328: ${err instanceof Error ? err.message : String(err)}` };
28553
28596
  }
@@ -28631,7 +28674,7 @@ async function patchHwpx(original, editedMarkdown, options) {
28631
28674
  let verification;
28632
28675
  if (options?.verify !== false) {
28633
28676
  try {
28634
- const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
28677
+ const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data), { layoutTables: "keep" });
28635
28678
  verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
28636
28679
  } catch (err) {
28637
28680
  return { success: false, applied, skipped, error: `\uD328\uCE58\uBCF8 \uC7AC\uD30C\uC2F1 \uC2E4\uD328 \u2014 \uD328\uCE58 \uC911\uB2E8: ${err instanceof Error ? err.message : String(err)}` };
@@ -29088,7 +29131,7 @@ import JSZip11 from "jszip";
29088
29131
  async function buildState(bytes) {
29089
29132
  const format2 = detectFormat(new Uint8Array(bytes.subarray(0, 512)).buffer);
29090
29133
  if (format2 !== "hwpx") throw new Error(`HWPX \uC138\uC158\uC740 HWPX \uBB38\uC11C\uB9CC \uC5FD\uB2C8\uB2E4 (\uAC10\uC9C0\uB41C \uD3EC\uB9F7: ${format2}) \u2014 HWP 5.x \uB294 patchHwp \uB85C \uD328\uCE58\uD558\uC138\uC694`);
29091
- const parsed = await parseHwpxDocument(u8ToArrayBuffer2(bytes));
29134
+ const parsed = await parseHwpxDocument(u8ToArrayBuffer2(bytes), { layoutTables: "keep" });
29092
29135
  const zip = await JSZip11.loadAsync(bytes);
29093
29136
  const sectionPaths = await resolveSectionEntryNames(zip);
29094
29137
  if (sectionPaths.length === 0) {
@@ -29519,7 +29562,7 @@ function scriptsOff(r, off) {
29519
29562
  }
29520
29563
  async function parseImage(buffer, options) {
29521
29564
  try {
29522
- const { parseImageDocument } = await import("./image-ocr-3WJ4QH3T.js");
29565
+ const { parseImageDocument } = await import("./image-ocr-P6ECJCT2.js");
29523
29566
  const { blocks, warnings } = await parseImageDocument(buffer, options);
29524
29567
  stripScriptTags({ blocks });
29525
29568
  return {
@@ -29579,7 +29622,7 @@ async function parseHwp(buffer, options) {
29579
29622
  async function parsePdf(buffer, options) {
29580
29623
  let parsePdfDocument;
29581
29624
  try {
29582
- const mod = await import("./parser-N6476XAC.js");
29625
+ const mod = await import("./parser-ZPRQ3SSU.js");
29583
29626
  parsePdfDocument = mod.parsePdfDocument;
29584
29627
  } catch {
29585
29628
  return {
@@ -29656,7 +29699,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
29656
29699
  fill: { filled: hwpxResult.filled, unmatched: hwpxResult.unmatched }
29657
29700
  };
29658
29701
  }
29659
- const parsed = await parse(buffer);
29702
+ const parsed = await parse(buffer, { layoutTables: "keep" });
29660
29703
  if (!parsed.success) {
29661
29704
  throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
29662
29705
  }
@@ -29679,7 +29722,7 @@ function wantsCrop(kind, policy) {
29679
29722
  async function extractTables(input, options = {}) {
29680
29723
  const policy = options.policy ?? "non-tabular-and-uncertain";
29681
29724
  const buffer = typeof input === "string" ? toArrayBuffer(await readFile2(input)) : Buffer.isBuffer(input) ? toArrayBuffer(input) : input;
29682
- const parsed = await parse(buffer, { classifyTables: true });
29725
+ const parsed = await parse(buffer, { classifyTables: true, layoutTables: "keep" });
29683
29726
  if (!parsed.success) throw new KordocError(`\uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
29684
29727
  const blocks = collectTableBlocks(parsed.blocks);
29685
29728
  const out = blocks.map((b, i) => ({
@@ -29791,4 +29834,4 @@ export {
29791
29834
  parseHwpml,
29792
29835
  fillForm
29793
29836
  };
29794
- //# sourceMappingURL=chunk-QOCS7W7R.js.map
29837
+ //# sourceMappingURL=chunk-K2VYABZ3.js.map