kordoc 4.18.2 → 4.18.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 (152) hide show
  1. package/dist/{-I3CP33G4.js → -DDAVBMHD.js} +11 -11
  2. package/dist/{chunk-O2DI4GHD.js → chunk-274ZPMHK.js} +2 -2
  3. package/dist/{chunk-QGFZU3JE.cjs → chunk-3WLZOJIE.cjs} +10 -8
  4. package/dist/chunk-3WLZOJIE.cjs.map +1 -0
  5. package/dist/{chunk-UZGZRGYM.cjs → chunk-3XSP7V5P.cjs} +10 -5
  6. package/dist/chunk-3XSP7V5P.cjs.map +1 -0
  7. package/dist/{chunk-GM7XIZF2.js → chunk-4IBY5LTJ.js} +2 -2
  8. package/dist/chunk-6H25SXDI.js +11 -0
  9. package/dist/chunk-6H25SXDI.js.map +1 -0
  10. package/dist/{chunk-N5DQFA7L.js → chunk-7GR2GCJF.js} +10 -5
  11. package/dist/chunk-7GR2GCJF.js.map +1 -0
  12. package/dist/{chunk-YNLW6EGU.cjs → chunk-AVIZ55NQ.cjs} +3 -3
  13. package/dist/chunk-AVIZ55NQ.cjs.map +1 -0
  14. package/dist/chunk-DC6CTQTK.js +9 -0
  15. package/dist/chunk-DC6CTQTK.js.map +1 -0
  16. package/dist/{chunk-L5RLJPI3.js → chunk-DUV7Y6IQ.js} +3 -3
  17. package/dist/{chunk-KDMAYOWH.cjs → chunk-E2644XCO.cjs} +698 -189
  18. package/dist/chunk-E2644XCO.cjs.map +1 -0
  19. package/dist/{chunk-LSOD2A6N.js → chunk-ELOPDQES.js} +2 -2
  20. package/dist/{chunk-M4P7YS2N.js → chunk-F2GDLA45.js} +81 -61
  21. package/dist/chunk-F2GDLA45.js.map +1 -0
  22. package/dist/{chunk-OBILAVWC.js → chunk-F5YVCJVF.js} +10 -5
  23. package/dist/chunk-F5YVCJVF.js.map +1 -0
  24. package/dist/chunk-GS7T56RP.cjs.map +1 -1
  25. package/dist/{chunk-4B2EXELH.js → chunk-HRJJDNRD.js} +2 -2
  26. package/dist/{chunk-CKUIFTXJ.js → chunk-IAXGGQGD.js} +2 -2
  27. package/dist/{chunk-BL7KRE6X.js → chunk-IBQCK4F3.js} +7 -3
  28. package/dist/chunk-IBQCK4F3.js.map +1 -0
  29. package/dist/chunk-J55UQC5H.cjs.map +1 -1
  30. package/dist/{chunk-OGAYGUJF.js → chunk-KUUSP6OS.js} +581 -72
  31. package/dist/chunk-KUUSP6OS.js.map +1 -0
  32. package/dist/{chunk-LACO375L.js → chunk-LGF2IO66.js} +4 -3
  33. package/dist/chunk-LGF2IO66.js.map +1 -0
  34. package/dist/{chunk-L64QRUMK.js → chunk-MXA6YW2W.js} +582 -73
  35. package/dist/chunk-MXA6YW2W.js.map +1 -0
  36. package/dist/{chunk-OI5ZSSIC.cjs → chunk-OIUSF2VA.cjs} +16 -12
  37. package/dist/chunk-OIUSF2VA.cjs.map +1 -0
  38. package/dist/{chunk-6OKBTY72.js → chunk-QVCHFCT2.js} +2 -2
  39. package/dist/{chunk-C2CVOC5K.js → chunk-RCI7LY4N.js} +8 -4
  40. package/dist/chunk-RCI7LY4N.js.map +1 -0
  41. package/dist/{chunk-W2YYBPW5.cjs → chunk-SVNBZEL6.cjs} +3 -3
  42. package/dist/chunk-SVNBZEL6.cjs.map +1 -0
  43. package/dist/{chunk-VSY5PAJ5.js → chunk-T2BJPT6D.js} +3 -3
  44. package/dist/{chunk-VSY5PAJ5.js.map → chunk-T2BJPT6D.js.map} +1 -1
  45. package/dist/chunk-TK3FDAEE.cjs +9 -0
  46. package/dist/chunk-TK3FDAEE.cjs.map +1 -0
  47. package/dist/{chunk-F5HING4Y.js → chunk-TMJVD6FW.js} +5 -4
  48. package/dist/chunk-TMJVD6FW.js.map +1 -0
  49. package/dist/{chunk-T4MXCSBP.js → chunk-V5X4LLVM.js} +71 -47
  50. package/dist/chunk-V5X4LLVM.js.map +1 -0
  51. package/dist/{chunk-IA3UKDHA.js → chunk-VTVK2JMI.js} +3 -2
  52. package/dist/{chunk-IA3UKDHA.js.map → chunk-VTVK2JMI.js.map} +1 -1
  53. package/dist/{chunk-B2E6C2LH.js → chunk-XG4SYOZL.js} +6 -4
  54. package/dist/chunk-XG4SYOZL.js.map +1 -0
  55. package/dist/{chunk-QP7IXF7R.js → chunk-YCY2R4FM.js} +2 -2
  56. package/dist/{chunk-NZM2SSI4.js → chunk-Z2PPDQK2.js} +2 -2
  57. package/dist/chunks-5QTTAT5T.js +10 -0
  58. package/dist/cli.js +179 -119
  59. package/dist/cli.js.map +1 -1
  60. package/dist/{formula-E3N7KDDG.js → formula-7ZOZ5QJ6.js} +8 -4
  61. package/dist/{formula-E3N7KDDG.js.map → formula-7ZOZ5QJ6.js.map} +1 -1
  62. package/dist/{formula-AQZODKZF.js → formula-HQFZEXFF.js} +7 -3
  63. package/dist/{formula-AQZODKZF.js.map → formula-HQFZEXFF.js.map} +1 -1
  64. package/dist/{formula-VY4ITOMN.cjs → formula-YYJQBKEN.cjs} +13 -9
  65. package/dist/formula-YYJQBKEN.cjs.map +1 -0
  66. package/dist/{image-ocr-IMYXOHHV.js → image-ocr-4BGX2EJJ.js} +7 -6
  67. package/dist/{image-ocr-IMYXOHHV.js.map → image-ocr-4BGX2EJJ.js.map} +1 -1
  68. package/dist/{image-ocr-6LYEBMVR.cjs → image-ocr-CC26Q5KG.cjs} +16 -15
  69. package/dist/image-ocr-CC26Q5KG.cjs.map +1 -0
  70. package/dist/{image-ocr-LN3GSQPW.js → image-ocr-RK3HJVCI.js} +10 -9
  71. package/dist/{image-ocr-LN3GSQPW.js.map → image-ocr-RK3HJVCI.js.map} +1 -1
  72. package/dist/index.cjs +860 -817
  73. package/dist/index.cjs.map +1 -1
  74. package/dist/index.js +141 -98
  75. package/dist/index.js.map +1 -1
  76. package/dist/mcp.js +26 -26
  77. package/dist/mcp.js.map +1 -1
  78. package/dist/{model-bundle-IHKNDLOT.js → model-bundle-VHRXG63R.js} +5 -5
  79. package/dist/{models-YXITRAMR.js → models-G3WA24SY.js} +5 -5
  80. package/dist/page-range-QHHFTL7X.cjs.map +1 -1
  81. package/dist/{parser-7KECZTTP.cjs → parser-BGORCLIU.cjs} +461 -243
  82. package/dist/parser-BGORCLIU.cjs.map +1 -0
  83. package/dist/{parser-M3T2EWUN.js → parser-GFDGAVLV.js} +255 -37
  84. package/dist/parser-GFDGAVLV.js.map +1 -0
  85. package/dist/{parser-KB4BYQBZ.js → parser-SOWTUOMK.js} +258 -40
  86. package/dist/parser-SOWTUOMK.js.map +1 -0
  87. package/dist/pdf-ocr-7IOOVR2I.js +20 -0
  88. package/dist/pdf-ocr-EJ2HNZN6.cjs +17 -0
  89. package/dist/pdf-ocr-EJ2HNZN6.cjs.map +1 -0
  90. package/dist/pdf-ocr-RACAZU3N.js +16 -0
  91. package/dist/{profile-io-GQWQR7YQ.js → profile-io-Q2T47RVH.js} +3 -3
  92. package/dist/{rasterize-Y6TVFQ3M.js → rasterize-OAVMUTE6.js} +3 -3
  93. package/dist/{redact-doc-TRPZ3HNW.js → redact-doc-ECFOVR4X.js} +11 -11
  94. package/dist/{render-GHT5HKBO.js → render-NSKWZVTD.js} +7 -7
  95. package/dist/seal-A4MG7MPQ.js +10 -0
  96. package/dist/{setup-AGSCEHDB.js → setup-REH2KZP2.js} +3 -3
  97. package/dist/visual-B56WQAGW.js +20 -0
  98. package/dist/{watch-ALSEW4GB.js → watch-JXDUZYBY.js} +13 -13
  99. package/dist/watch-JXDUZYBY.js.map +1 -0
  100. package/package.json +1 -1
  101. package/dist/chunk-B2E6C2LH.js.map +0 -1
  102. package/dist/chunk-BL7KRE6X.js.map +0 -1
  103. package/dist/chunk-C2CVOC5K.js.map +0 -1
  104. package/dist/chunk-F5HING4Y.js.map +0 -1
  105. package/dist/chunk-KDMAYOWH.cjs.map +0 -1
  106. package/dist/chunk-L64QRUMK.js.map +0 -1
  107. package/dist/chunk-LACO375L.js.map +0 -1
  108. package/dist/chunk-M4P7YS2N.js.map +0 -1
  109. package/dist/chunk-N5DQFA7L.js.map +0 -1
  110. package/dist/chunk-OBILAVWC.js.map +0 -1
  111. package/dist/chunk-OGAYGUJF.js.map +0 -1
  112. package/dist/chunk-OI5ZSSIC.cjs.map +0 -1
  113. package/dist/chunk-QGFZU3JE.cjs.map +0 -1
  114. package/dist/chunk-T4MXCSBP.js.map +0 -1
  115. package/dist/chunk-UZGZRGYM.cjs.map +0 -1
  116. package/dist/chunk-W2YYBPW5.cjs.map +0 -1
  117. package/dist/chunk-YNLW6EGU.cjs.map +0 -1
  118. package/dist/chunks-IFFRC5IQ.js +0 -10
  119. package/dist/formula-VY4ITOMN.cjs.map +0 -1
  120. package/dist/image-ocr-6LYEBMVR.cjs.map +0 -1
  121. package/dist/parser-7KECZTTP.cjs.map +0 -1
  122. package/dist/parser-KB4BYQBZ.js.map +0 -1
  123. package/dist/parser-M3T2EWUN.js.map +0 -1
  124. package/dist/pdf-ocr-4S2OAHUX.js +0 -15
  125. package/dist/pdf-ocr-IGYCZ7G2.cjs +0 -16
  126. package/dist/pdf-ocr-IGYCZ7G2.cjs.map +0 -1
  127. package/dist/pdf-ocr-YEBFWU2K.js +0 -19
  128. package/dist/seal-3YTXSABW.js +0 -10
  129. package/dist/visual-R3E35Q2K.js +0 -20
  130. package/dist/watch-ALSEW4GB.js.map +0 -1
  131. /package/dist/{-I3CP33G4.js.map → -DDAVBMHD.js.map} +0 -0
  132. /package/dist/{chunk-O2DI4GHD.js.map → chunk-274ZPMHK.js.map} +0 -0
  133. /package/dist/{chunk-GM7XIZF2.js.map → chunk-4IBY5LTJ.js.map} +0 -0
  134. /package/dist/{chunk-L5RLJPI3.js.map → chunk-DUV7Y6IQ.js.map} +0 -0
  135. /package/dist/{chunk-LSOD2A6N.js.map → chunk-ELOPDQES.js.map} +0 -0
  136. /package/dist/{chunk-4B2EXELH.js.map → chunk-HRJJDNRD.js.map} +0 -0
  137. /package/dist/{chunk-CKUIFTXJ.js.map → chunk-IAXGGQGD.js.map} +0 -0
  138. /package/dist/{chunk-6OKBTY72.js.map → chunk-QVCHFCT2.js.map} +0 -0
  139. /package/dist/{chunk-QP7IXF7R.js.map → chunk-YCY2R4FM.js.map} +0 -0
  140. /package/dist/{chunk-NZM2SSI4.js.map → chunk-Z2PPDQK2.js.map} +0 -0
  141. /package/dist/{chunks-IFFRC5IQ.js.map → chunks-5QTTAT5T.js.map} +0 -0
  142. /package/dist/{model-bundle-IHKNDLOT.js.map → model-bundle-VHRXG63R.js.map} +0 -0
  143. /package/dist/{models-YXITRAMR.js.map → models-G3WA24SY.js.map} +0 -0
  144. /package/dist/{pdf-ocr-4S2OAHUX.js.map → pdf-ocr-7IOOVR2I.js.map} +0 -0
  145. /package/dist/{pdf-ocr-YEBFWU2K.js.map → pdf-ocr-RACAZU3N.js.map} +0 -0
  146. /package/dist/{profile-io-GQWQR7YQ.js.map → profile-io-Q2T47RVH.js.map} +0 -0
  147. /package/dist/{rasterize-Y6TVFQ3M.js.map → rasterize-OAVMUTE6.js.map} +0 -0
  148. /package/dist/{redact-doc-TRPZ3HNW.js.map → redact-doc-ECFOVR4X.js.map} +0 -0
  149. /package/dist/{render-GHT5HKBO.js.map → render-NSKWZVTD.js.map} +0 -0
  150. /package/dist/{seal-3YTXSABW.js.map → seal-A4MG7MPQ.js.map} +0 -0
  151. /package/dist/{setup-AGSCEHDB.js.map → setup-REH2KZP2.js.map} +0 -0
  152. /package/dist/{visual-R3E35Q2K.js.map → visual-B56WQAGW.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  KordocError
3
- } from "./chunk-N5DQFA7L.js";
3
+ } from "./chunk-7GR2GCJF.js";
4
4
 
5
5
  // src/pdf/formula/models.ts
6
6
  import { createHash as createHash2 } from "crypto";
@@ -308,4 +308,4 @@ export {
308
308
  ensureFormulaModels,
309
309
  ensureSingleModel
310
310
  };
311
- //# sourceMappingURL=chunk-LSOD2A6N.js.map
311
+ //# sourceMappingURL=chunk-ELOPDQES.js.map
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  blocksToPages
4
- } from "./chunk-GM7XIZF2.js";
4
+ } from "./chunk-4IBY5LTJ.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-L5RLJPI3.js";
18
+ } from "./chunk-DUV7Y6IQ.js";
19
19
  import {
20
20
  CONVERT_MAP,
21
21
  FLAG_COMPRESSED,
@@ -65,7 +65,7 @@ import {
65
65
  romanNumeral,
66
66
  simulateWrap,
67
67
  takeTocLeaders
68
- } from "./chunk-T4MXCSBP.js";
68
+ } from "./chunk-V5X4LLVM.js";
69
69
  import {
70
70
  CELL_EDGES,
71
71
  HEADING_RATIO_H1,
@@ -77,7 +77,7 @@ import {
77
77
  tidyScriptTags,
78
78
  unframeLayoutTables,
79
79
  wrapScript
80
- } from "./chunk-F5HING4Y.js";
80
+ } from "./chunk-TMJVD6FW.js";
81
81
  import {
82
82
  parsePageRange
83
83
  } from "./chunk-VQFA55IC.js";
@@ -96,7 +96,7 @@ import {
96
96
  findChildByLocalName,
97
97
  localName,
98
98
  rawTextContent
99
- } from "./chunk-LACO375L.js";
99
+ } from "./chunk-LGF2IO66.js";
100
100
  import {
101
101
  MAX_COLS,
102
102
  MAX_ROWS,
@@ -111,7 +111,7 @@ import {
111
111
  hasStructuredCellContent,
112
112
  mapPuaText,
113
113
  noteSuffix
114
- } from "./chunk-IA3UKDHA.js";
114
+ } from "./chunk-VTVK2JMI.js";
115
115
  import {
116
116
  KordocError,
117
117
  classifyError,
@@ -119,6 +119,7 @@ import {
119
119
  escapeHtml,
120
120
  isPathTraversal,
121
121
  normalizeSectionHref,
122
+ partExtension,
122
123
  precheckZipSize,
123
124
  sanitizeError,
124
125
  sanitizeHref,
@@ -126,7 +127,7 @@ import {
126
127
  toArrayBuffer,
127
128
  unescapeHtml,
128
129
  unzipLimitBytes
129
- } from "./chunk-OBILAVWC.js";
130
+ } from "./chunk-F5YVCJVF.js";
130
131
 
131
132
  // src/table/visual.ts
132
133
  import { readFile as readFile2 } from "fs/promises";
@@ -632,7 +633,7 @@ function parseParaHeadings(doc, map) {
632
633
  if (map.size > 0) break;
633
634
  }
634
635
  }
635
- function detectHwpxHeadings(blocks, styleMap) {
636
+ function detectHwpxHeadings(blocks, styleMap, tocTexts) {
636
637
  if (blocks.some((b) => b.type === "heading")) return;
637
638
  let baseFontSize = 0;
638
639
  const sizeFreq = /* @__PURE__ */ new Map();
@@ -649,7 +650,7 @@ function detectHwpxHeadings(blocks, styleMap) {
649
650
  }
650
651
  }
651
652
  for (const block of blocks) {
652
- if (block.type !== "paragraph" || !block.text || TOC_ENTRY_BLOCKS.has(block)) continue;
653
+ if (block.type !== "paragraph" || !block.text || TOC_ENTRY_BLOCKS.has(block) || tocTexts?.has(block.text.trim())) continue;
653
654
  const text = block.text.trim();
654
655
  if (text.length === 0 || text.length > 200 || /^\d+$/.test(text)) continue;
655
656
  let level = 0;
@@ -1301,13 +1302,13 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
1301
1302
  }
1302
1303
  if (tableCtx) tableStack.push(tableCtx);
1303
1304
  const newTable = { rows: [], currentRow: [], cell: null, sourceId: el.getAttribute("id") ?? void 0 };
1304
- walkSection(el, blocks, newTable, tableStack, ctx, depth + 1);
1305
+ inIndependentDeletionStory(ctx.shared.track, () => walkSection(el, blocks, newTable, tableStack, ctx, depth + 1));
1305
1306
  tableCtx = completeTable(newTable, tableStack, blocks, ctx);
1306
1307
  break;
1307
1308
  }
1308
1309
  // 표/도표 캡션 — IRTable.caption으로 보존 (v3.0, 기존 무음 드롭 수정)
1309
1310
  case "caption": {
1310
- const cap = collectSubListContent(el, ctx);
1311
+ const cap = inIndependentDeletionStory(ctx.shared.track, () => collectSubListContent(el, ctx));
1311
1312
  if (cap.text) {
1312
1313
  if (tableCtx) {
1313
1314
  tableCtx.caption = (tableCtx.caption ? tableCtx.caption + "\n" : "") + cap.text;
@@ -1367,6 +1368,9 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
1367
1368
  if (text) {
1368
1369
  if (ph?.prefix) text = ph.prefix + " " + text;
1369
1370
  headingLevel = tocEntry ? void 0 : ph?.headingLevel;
1371
+ if (tocEntry) {
1372
+ for (const line of text.split("\n")) if (line.trim()) ctx.shared.tocTexts.add(line.trim());
1373
+ }
1370
1374
  }
1371
1375
  if (segments) {
1372
1376
  const cell2 = tableCtx?.cell ?? null;
@@ -1452,6 +1456,15 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
1452
1456
  if (spanMode !== "foreign" && el.getAttribute("paraPrIDRef") === KORDOC_PARA_QUOTE) block.quote = true;
1453
1457
  }
1454
1458
  if (!headingLevel && !block.spans && placeholderSpans) block.spans = withPrefixSpan(placeholderSpans, ph?.prefix);
1459
+ if (headingLevel && placeholderSpans) {
1460
+ const shown = withPrefixSpan(placeholderSpans.filter((s) => !s.placeholder), ph?.prefix).map((s) => s.text).join("").trim();
1461
+ if (shown) block.text = shown;
1462
+ else {
1463
+ block.type = "paragraph";
1464
+ delete block.level;
1465
+ block.spans = withPrefixSpan(placeholderSpans, ph?.prefix);
1466
+ }
1467
+ }
1455
1468
  blocks.push(block);
1456
1469
  } else {
1457
1470
  blocks.push({ type: "paragraph", text, pageNumber: ctx.page });
@@ -1693,10 +1706,10 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
1693
1706
  }
1694
1707
  if (tableCtx) tableStack.push(tableCtx);
1695
1708
  const newTable = { rows: [], currentRow: [], cell: null, inline: isInlineTbl(el), sourceId: el.getAttribute("id") ?? void 0 };
1696
- walkSection(el, blocks, newTable, tableStack, ctx, d + 1);
1709
+ inIndependentDeletionStory(ctx.shared.track, () => walkSection(el, blocks, newTable, tableStack, ctx, d + 1));
1697
1710
  tableCtx = completeTable(newTable, tableStack, blocks, ctx);
1698
1711
  } else if (localTag === "caption" && !inShape) {
1699
- const cap = collectSubListContent(el, ctx);
1712
+ const cap = inIndependentDeletionStory(ctx.shared.track, () => collectSubListContent(el, ctx));
1700
1713
  if (cap.text) {
1701
1714
  if (tableCtx?.cell) mergeBlocksIntoCell(tableCtx.cell, [{ type: "paragraph", text: cap.text, pageNumber: ctx.page }]);
1702
1715
  else if (tableCtx) {
@@ -1892,7 +1905,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
1892
1905
  // 아니므로 방출하지 않는다
1893
1906
  case "header":
1894
1907
  case "footer": {
1895
- if (!ctx) break;
1908
+ if (!ctx || isInDeletedRange(ctx)) break;
1896
1909
  const t = collectSubListText(k, ctx);
1897
1910
  if (t && hasPageAutoNum(k) && !/\p{L}/u.test(t)) break;
1898
1911
  if (t) {
@@ -2014,9 +2027,10 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2014
2027
  if (isInlineTbl(child)) text += "";
2015
2028
  break;
2016
2029
  // 양식 선택 상자·라디오 단추 — 한컴이 그리는 상자 기호와 캡션 글 (종전엔 통째로 빠졌다: form-002 "원천기술형"·서울 결재 "부분공개")
2030
+ // 지운 구간의 양식 단추·수식은 글처럼 내지 않는다 (최종본)
2017
2031
  case "checkBtn":
2018
2032
  case "radioBtn":
2019
- text += formButtonText(child, tag === "radioBtn");
2033
+ if (!isInDeletedRange(ctx)) text += formButtonText(child, tag === "radioBtn");
2020
2034
  break;
2021
2035
  // 하이퍼링크
2022
2036
  case "hyperlink": {
@@ -2086,6 +2100,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
2086
2100
  // 스크립트가 담겨 있음. hml-equation-parser 로 LaTeX 변환 후 `$...$`
2087
2101
  // 로 래핑. 실패/빈 스크립트면 무시 (대체 텍스트 누출 방지).
2088
2102
  case "equation": {
2103
+ if (isInDeletedRange(ctx)) break;
2089
2104
  const script = findChildByLocalName(child, "script");
2090
2105
  const raw = script ? extractTextFromNode(script) : "";
2091
2106
  if (raw.trim()) {
@@ -2435,8 +2450,11 @@ async function resolveSectionPaths(zip) {
2435
2450
  function parseSectionPathsFromManifest(xml) {
2436
2451
  const parser = createXmlParser();
2437
2452
  const doc = parser.parseFromString(stripDtd(xml), "text/xml");
2438
- const items = doc.getElementsByTagName("opf:item");
2439
- const spine = doc.getElementsByTagName("opf:itemref");
2453
+ const opf = "http://www.idpf.org/2007/opf/";
2454
+ const namespacedItems = doc.getElementsByTagNameNS(opf, "item");
2455
+ const namespacedSpine = doc.getElementsByTagNameNS(opf, "itemref");
2456
+ const items = namespacedItems.length ? namespacedItems : doc.getElementsByTagName("opf:item");
2457
+ const spine = namespacedSpine.length ? namespacedSpine : doc.getElementsByTagName("opf:itemref");
2440
2458
  const idToHref = /* @__PURE__ */ new Map();
2441
2459
  for (let i = 0; i < items.length; i++) {
2442
2460
  const item = items[i];
@@ -2656,7 +2674,7 @@ async function parseHwpxDocument(buffer, options) {
2656
2674
  applyPageText(blocks, shared);
2657
2675
  const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !options?.pages, shared.track.deletedImageRefs);
2658
2676
  const shown = options?.layoutTables === "keep" ? blocks : unframeLayoutTables(blocks, !!options?.keepTrailingEmptyCols);
2659
- detectHwpxHeadings(shown, styleMap);
2677
+ detectHwpxHeadings(shown, styleMap, shared.tocTexts);
2660
2678
  const outline = shown.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
2661
2679
  const markdown = blocksToMarkdown(shown);
2662
2680
  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 };
@@ -15741,7 +15759,7 @@ function collectRichText(root) {
15741
15759
  const el = children[i];
15742
15760
  const local = el.localName || el.tagName?.replace(/^[^:]+:/, "") || "";
15743
15761
  if (local === "rPh") continue;
15744
- if (local === "t") out += escapeLiteralTags(el.textContent ?? "");
15762
+ if (local === "t") out += escapeLiteralTags(escapeLiteralDollar(el.textContent ?? ""));
15745
15763
  else walk(el);
15746
15764
  }
15747
15765
  };
@@ -16365,14 +16383,14 @@ function extractSheetCells(records, bofIndex, sst, convertNum) {
16365
16383
  const h = readCellHeader(rec.data);
16366
16384
  if (h && rec.data.length >= 10) {
16367
16385
  const isst = rec.data.readUInt32LE(6);
16368
- cells.push({ row: h.row, col: h.col, value: escapeLiteralTags(sst[isst] ?? "") });
16386
+ cells.push({ row: h.row, col: h.col, value: escapeLiteralTags(escapeLiteralDollar(sst[isst] ?? "")) });
16369
16387
  }
16370
16388
  break;
16371
16389
  }
16372
16390
  case OP_LABEL: {
16373
16391
  const h = readCellHeader(rec.data);
16374
16392
  if (h) {
16375
- cells.push({ row: h.row, col: h.col, value: escapeLiteralTags(decodeLabelString(rec.data)) });
16393
+ cells.push({ row: h.row, col: h.col, value: escapeLiteralTags(escapeLiteralDollar(decodeLabelString(rec.data))) });
16376
16394
  }
16377
16395
  break;
16378
16396
  }
@@ -16388,7 +16406,7 @@ function extractSheetCells(records, bofIndex, sst, convertNum) {
16388
16406
  cells.push({
16389
16407
  row: h.row,
16390
16408
  col: h.col,
16391
- value: escapeLiteralTags(decodeFormulaStringRecord(next.data))
16409
+ value: escapeLiteralTags(escapeLiteralDollar(decodeFormulaStringRecord(next.data)))
16392
16410
  });
16393
16411
  i = j;
16394
16412
  } else {
@@ -17100,6 +17118,7 @@ function isDisplayMath(el) {
17100
17118
  // src/docx/parser.ts
17101
17119
  var MAX_DECOMPRESS_SIZE4 = unzipLimitBytes(100 * 1024 * 1024);
17102
17120
  var MEDIA_PART_RE = /^word\/(?:media|embeddings)\//;
17121
+ var NEVER_READ_RE = /^word\/(?:embeddings\/.*|media\/.+\.(?:mp4|m4v|mov|avi|wmv|mpe?g|mkv|webm|mp3|wav|m4a|wma|aac|ogg|flac|mid|bin))$/i;
17103
17122
  function matchesLocal(el, localName3) {
17104
17123
  return el.localName === localName3 || (el.tagName?.endsWith(`:${localName3}`) ?? false);
17105
17124
  }
@@ -17291,7 +17310,7 @@ function parseFootnotes(xml) {
17291
17310
  const runs = findElements(p, "r");
17292
17311
  for (const r of runs) {
17293
17312
  const tElements = getChildElements(r, "t");
17294
- for (const t of tElements) texts.push(escapeLiteralTags(t.textContent ?? ""));
17313
+ for (const t of tElements) texts.push(escapeLiteralTags(escapeLiteralDollar(t.textContent ?? "")));
17295
17314
  }
17296
17315
  }
17297
17316
  notes.set(id, texts.join("").trim());
@@ -17322,7 +17341,7 @@ function collectOmmlRoots(p) {
17322
17341
  function extractRun(r) {
17323
17342
  let text = "";
17324
17343
  for (const el of effectiveChildElements(r)) {
17325
- if (matchesLocal(el, "t")) text += escapeLiteralTags(el.textContent ?? "");
17344
+ if (matchesLocal(el, "t")) text += escapeLiteralTags(escapeLiteralDollar(el.textContent ?? ""));
17326
17345
  else if (matchesLocal(el, "br") || matchesLocal(el, "cr")) text += "\n";
17327
17346
  else if (matchesLocal(el, "tab")) text += " ";
17328
17347
  else if (matchesLocal(el, "sym")) text += symbolChar(getAttr(el, "font"), getAttr(el, "char"));
@@ -17618,7 +17637,7 @@ async function buildImageMap(zip, rels, doc, warnings, readBytes) {
17618
17637
  let data = null;
17619
17638
  if (readBytes) data = await imgFile.async("uint8array");
17620
17639
  imgIdx++;
17621
- const ext = imgPath.split(".").pop()?.toLowerCase() ?? "png";
17640
+ const ext = partExtension(imgPath);
17622
17641
  const mimeMap = {
17623
17642
  png: "image/png",
17624
17643
  jpg: "image/jpeg",
@@ -17717,7 +17736,7 @@ async function parseHeaderFooterBlocks(zip, doc, rels, kind, styles, numbering,
17717
17736
  }
17718
17737
  async function parseDocxDocument(buffer, options) {
17719
17738
  const readImages = options?.images !== false;
17720
- precheckZipSize(buffer, MAX_DECOMPRESS_SIZE4, void 0, { re: MEDIA_PART_RE, skip: !readImages });
17739
+ precheckZipSize(buffer, MAX_DECOMPRESS_SIZE4, void 0, { re: MEDIA_PART_RE, skip: !readImages, never: NEVER_READ_RE });
17721
17740
  const zip = await JSZip4.loadAsync(buffer);
17722
17741
  const warnings = [];
17723
17742
  const docFile = zip.file("word/document.xml");
@@ -17838,6 +17857,7 @@ import JSZip5 from "jszip";
17838
17857
  import { DOMParser as DOMParser3 } from "@xmldom/xmldom";
17839
17858
  var MAX_DECOMPRESS_SIZE5 = unzipLimitBytes(100 * 1024 * 1024);
17840
17859
  var MEDIA_PART_RE2 = /^ppt\/(?:media|embeddings)\//;
17860
+ var NEVER_READ_RE2 = /^ppt\/(?:embeddings\/.*|media\/.+\.(?:mp4|m4v|mov|avi|wmv|mpe?g|mkv|webm|mp3|wav|m4a|wma|aac|ogg|flac|mid|bin))$/i;
17841
17861
  var MAX_ZIP_ENTRIES2 = 1e4;
17842
17862
  var MAX_SLIDES = 2e3;
17843
17863
  var SKIP_PLACEHOLDERS = /* @__PURE__ */ new Set(["sldNum", "dt", "ftr", "hdr", "sldImg"]);
@@ -17934,12 +17954,14 @@ function paragraphText(p) {
17934
17954
  const name = localName(child);
17935
17955
  if (name === "r" || name === "fld") {
17936
17956
  const t = findChildByLocalName(child, "t");
17937
- if (t) text += escapeLiteralTags(escapeLiteralDollar(rawTextContent(t)));
17957
+ const rPr = findChildByLocalName(child, "rPr");
17958
+ const baseline = Number(rPr ? getAttr2(rPr, "baseline") ?? 0 : 0);
17959
+ if (t) text += wrapScript(escapeLiteralTags(escapeLiteralDollar(rawTextContent(t))), baseline > 0 ? "sup" : baseline < 0 ? "sub" : null);
17938
17960
  } else if (name === "br") {
17939
17961
  text += " ";
17940
17962
  }
17941
17963
  }
17942
- return text.replace(/\s+/g, " ").trim();
17964
+ return tidyScriptTags(text.replace(/\s+/g, " ").trim());
17943
17965
  }
17944
17966
  function bodyParagraphs(txBody) {
17945
17967
  const out = [];
@@ -18013,7 +18035,7 @@ async function pictureBlock(pic, ctx) {
18013
18035
  if (!filename) {
18014
18036
  const file = ctx.zip.file(rel.target);
18015
18037
  if (!file) return null;
18016
- const ext = rel.target.split(".").pop()?.toLowerCase() ?? "png";
18038
+ const ext = partExtension(rel.target);
18017
18039
  filename = `image_${String(ctx.imageNames.size + 1).padStart(3, "0")}.${ext}`;
18018
18040
  try {
18019
18041
  if (ctx.options?.images !== false) {
@@ -18091,7 +18113,7 @@ async function notesText(zip, rels) {
18091
18113
  return texts.join(" ");
18092
18114
  }
18093
18115
  async function parsePptxDocument(buffer, options) {
18094
- precheckZipSize(buffer, MAX_DECOMPRESS_SIZE5, MAX_ZIP_ENTRIES2, { re: MEDIA_PART_RE2, skip: options?.images === false });
18116
+ precheckZipSize(buffer, MAX_DECOMPRESS_SIZE5, MAX_ZIP_ENTRIES2, { re: MEDIA_PART_RE2, skip: options?.images === false, never: NEVER_READ_RE2 });
18095
18117
  const zip = await JSZip5.loadAsync(buffer);
18096
18118
  if (!zip.file("ppt/presentation.xml")) {
18097
18119
  throw new KordocError("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 PPTX \uD30C\uC77C: ppt/presentation.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
@@ -18101,8 +18123,10 @@ async function parsePptxDocument(buffer, options) {
18101
18123
  const imageNames = /* @__PURE__ */ new Map();
18102
18124
  const images = [];
18103
18125
  const slides = await slideParts(zip);
18126
+ const pageFilter = options?.pages ? parsePageRange(options.pages, slides.length) : null;
18104
18127
  for (let i = 0; i < slides.length; i++) {
18105
18128
  const page = i + 1;
18129
+ if (pageFilter && !pageFilter.has(page)) continue;
18106
18130
  const root = parseXml3(await zip.file(slides[i]).async("text")).documentElement;
18107
18131
  if (getAttr2(root, "show") === "0") {
18108
18132
  warnings.push({ page, code: "HIDDEN_TEXT_FILTERED", message: `PPTX \uC228\uAE34 \uC2AC\uB77C\uC774\uB4DC ${page}\uCABD\uC744 \uAC74\uB108\uB701\uB2C8\uB2E4` });
@@ -22687,7 +22711,7 @@ function sanitizeText(text) {
22687
22711
  return result;
22688
22712
  }
22689
22713
  function normForMatch(text) {
22690
- return sanitizeText(text.replace(/\\\$/g, "$")).replace(/\s+/g, " ").trim();
22714
+ return sanitizeText(text.replace(/\\\$/g, "$").replace(/\\(?=<\/?(?:u|sup|sub)>)/g, "")).replace(/\s+/g, " ").trim();
22691
22715
  }
22692
22716
  function unescapeGfm(text) {
22693
22717
  return text.replace(/\\([~*_`|#<$\\])/g, "$1");
@@ -23319,6 +23343,7 @@ var ImageRegistry = class {
23319
23343
  supplied;
23320
23344
  byUrl = /* @__PURE__ */ new Map();
23321
23345
  ids = /* @__PURE__ */ new Set();
23346
+ names = /* @__PURE__ */ new Set();
23322
23347
  parts = [];
23323
23348
  picSeq = 0;
23324
23349
  binSeq = 0;
@@ -23339,8 +23364,12 @@ var ImageRegistry = class {
23339
23364
  let n = 1;
23340
23365
  while (this.ids.has(itemId)) itemId = `${m[1].replace(/[^A-Za-z0-9_]/g, "_")}_${n++}`;
23341
23366
  this.ids.add(itemId);
23367
+ let name = `BinData/${url}`;
23368
+ let suffix = 1;
23369
+ while (this.names.has(name)) name = `BinData/${m[1]}_${suffix++}.${m[2]}`;
23370
+ this.names.add(name);
23342
23371
  part = {
23343
- name: `BinData/${url}`,
23372
+ name,
23344
23373
  itemId,
23345
23374
  mime,
23346
23375
  data: m[2].toLowerCase() === "bmp" ? PLACEHOLDER_BMP : PLACEHOLDER_PNG
@@ -23369,8 +23398,9 @@ var ImageRegistry = class {
23369
23398
  const base = safe && !url.includes("..") ? safe[1] : `image${++this.binSeq}`;
23370
23399
  let itemId = base.replace(/[^A-Za-z0-9_]/g, "_");
23371
23400
  let n = 1;
23372
- while (this.ids.has(itemId)) itemId = `${base.replace(/[^A-Za-z0-9_]/g, "_")}_${n++}`;
23401
+ while (this.ids.has(itemId) || this.names.has(`BinData/${itemId}.${sniffed.ext}`)) itemId = `${base.replace(/[^A-Za-z0-9_]/g, "_")}_${n++}`;
23373
23402
  this.ids.add(itemId);
23403
+ this.names.add(`BinData/${itemId}.${sniffed.ext}`);
23374
23404
  const dim = probeImageSize(bytes);
23375
23405
  let wHU, hHU;
23376
23406
  if (dim && dim.w > 0 && dim.h > 0) {
@@ -27836,30 +27866,11 @@ async function resolveSectionEntryNames(zip) {
27836
27866
  const f = zip.file(mp);
27837
27867
  if (!f) continue;
27838
27868
  const xml = await f.async("text");
27839
- const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
27869
+ const paths = parseSectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
27840
27870
  if (paths.length > 0) return paths;
27841
27871
  }
27842
27872
  return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(compareSectionPaths);
27843
27873
  }
27844
- function sectionPathsFromManifest(xml) {
27845
- const attr = (tag, name) => {
27846
- const m = tag.match(new RegExp(`(?:^|\\s)${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`));
27847
- return m ? m[1] ?? m[2] : "";
27848
- };
27849
- const idToHref = /* @__PURE__ */ new Map();
27850
- for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
27851
- const id = attr(m[1], "id");
27852
- const href = normalizeSectionHref(attr(m[1], "href"));
27853
- if (id && href) idToHref.set(id, href);
27854
- }
27855
- const ordered = [];
27856
- for (const m of xml.matchAll(/<opf:itemref(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
27857
- const href = idToHref.get(attr(m[1], "idref"));
27858
- if (href) ordered.push(href);
27859
- }
27860
- if (ordered.length > 0) return ordered;
27861
- return Array.from(idToHref.values()).sort(compareSectionPaths);
27862
- }
27863
27874
 
27864
27875
  // src/roundtrip/hwp5-patch.ts
27865
27876
  import { deflateRawSync } from "zlib";
@@ -29090,6 +29101,10 @@ async function patchHwpx(original, editedMarkdown, options) {
29090
29101
  const parsed = await parseHwpxDocument(u8ToArrayBuffer(original), { layoutTables: "keep" });
29091
29102
  origBlocks = parsed.blocks;
29092
29103
  const visual = await parseHwpxDocument(u8ToArrayBuffer(original));
29104
+ if (parsed.markdown !== visual.markdown && editedMarkdown === visual.markdown) {
29105
+ const verification2 = options?.verify === false ? void 0 : diffUnitLists(splitMarkdownUnits(visual.markdown), splitMarkdownUnits(editedMarkdown));
29106
+ return { success: true, data: new Uint8Array(original), applied: 0, skipped, verification: verification2 };
29107
+ }
29093
29108
  if (editedFromVisual(parsed.markdown, visual.markdown, editedMarkdown)) return { success: false, applied: 0, skipped, error: LAYOUT_MODE_MISMATCH };
29094
29109
  } catch (err) {
29095
29110
  return { success: false, applied: 0, skipped, error: `\uC6D0\uBCF8 HWPX \uD30C\uC2F1 \uC2E4\uD328: ${err instanceof Error ? err.message : String(err)}` };
@@ -29988,7 +30003,7 @@ async function parse(input, options) {
29988
30003
  buffer = toArrayBuffer(buf);
29989
30004
  } catch (err) {
29990
30005
  const msg2 = err instanceof Error && "code" in err && err.code === "ENOENT" ? `\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input}` : `\uD30C\uC77C \uC77D\uAE30 \uC2E4\uD328: ${input}`;
29991
- return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
30006
+ return { success: false, fileType: "unknown", error: msg2, code: classifyError(err) };
29992
30007
  }
29993
30008
  } else if (Buffer.isBuffer(input)) {
29994
30009
  buffer = toArrayBuffer(input);
@@ -30006,9 +30021,12 @@ async function parse(input, options) {
30006
30021
  }
30007
30022
  if (result.success && opts?.classifyTables) classifyTableTree(result.blocks);
30008
30023
  let out = result;
30009
- if (result.success && !result.pages) {
30010
- const pages = blocksToPages(result.blocks);
30011
- if (pages) out = { ...result, pages };
30024
+ if (result.success && opts?.pages && result.pageCount && parsePageRange(opts.pages, result.pageCount).size === 0) {
30025
+ out = { ...result, warnings: [...result.warnings ?? [], { code: "PARTIAL_PARSE", message: `\uC694\uCCAD\uD55C \uCABD \uBC94\uC704(${opts.pages})\uAC00 \uBB38\uC11C \uCABD(1~${result.pageCount})\uACFC \uACB9\uCE58\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4` }] };
30026
+ }
30027
+ if (out.success && !out.pages) {
30028
+ const pages = blocksToPages(out.blocks);
30029
+ if (pages) out = { ...out, pages };
30012
30030
  }
30013
30031
  if (out.success && opts?.plain) {
30014
30032
  out = { ...out, markdown: toPlainMarkdown(out.markdown), ...out.pages ? { pages: out.pages.map((p) => ({ ...p, markdown: toPlainMarkdown(p.markdown) })) } : {} };
@@ -30060,7 +30078,7 @@ function scriptsOff(r, off) {
30060
30078
  }
30061
30079
  async function parseImage(buffer, options) {
30062
30080
  try {
30063
- const { parseImageDocument } = await import("./image-ocr-LN3GSQPW.js");
30081
+ const { parseImageDocument } = await import("./image-ocr-RK3HJVCI.js");
30064
30082
  const { blocks, warnings } = await parseImageDocument(buffer, options);
30065
30083
  stripScriptTags({ blocks });
30066
30084
  return {
@@ -30120,7 +30138,7 @@ async function parseHwp(buffer, options) {
30120
30138
  async function parsePdf(buffer, options) {
30121
30139
  let parsePdfDocument;
30122
30140
  try {
30123
- const mod = await import("./parser-KB4BYQBZ.js");
30141
+ const mod = await import("./parser-SOWTUOMK.js");
30124
30142
  parsePdfDocument = mod.parsePdfDocument;
30125
30143
  } catch {
30126
30144
  return {
@@ -30165,7 +30183,7 @@ async function parseDocx(buffer, options) {
30165
30183
  async function parsePptx(buffer, options) {
30166
30184
  try {
30167
30185
  const { markdown, blocks, metadata, outline, warnings, images } = await parsePptxDocument(buffer, options);
30168
- return { success: true, fileType: "pptx", markdown, blocks, metadata, outline, warnings, images: images?.length ? images : void 0, pageCount: metadata?.pageCount };
30186
+ return scriptsOff({ success: true, fileType: "pptx", markdown, blocks, metadata, outline, warnings, images: images?.length ? images : void 0, pageCount: metadata?.pageCount }, options?.scriptTags === false);
30169
30187
  } catch (err) {
30170
30188
  return { success: false, fileType: "pptx", error: sanitizeError(err), code: classifyError(err) };
30171
30189
  }
@@ -30285,6 +30303,8 @@ async function extractTables(input, options = {}) {
30285
30303
  }
30286
30304
 
30287
30305
  export {
30306
+ toPlainMarkdown,
30307
+ toHtmlTables,
30288
30308
  extractHwpxMetadataOnly,
30289
30309
  formatFillValue,
30290
30310
  ValueCursor,
@@ -30341,4 +30361,4 @@ export {
30341
30361
  parseHwpml,
30342
30362
  fillForm
30343
30363
  };
30344
- //# sourceMappingURL=chunk-M4P7YS2N.js.map
30364
+ //# sourceMappingURL=chunk-F2GDLA45.js.map