kordoc 4.24.17 → 4.24.19

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 (121) hide show
  1. package/README.md +5 -5
  2. package/dist/{-EM3WKYYH.js → -IFNBZFGR.js} +11 -11
  3. package/dist/{chunk-KUTKDE4Z.js → chunk-2IFSM7ZE.js} +4 -4
  4. package/dist/{chunk-I4QRLAX7.cjs → chunk-4OWHKA6D.cjs} +3 -3
  5. package/dist/{chunk-I4QRLAX7.cjs.map → chunk-4OWHKA6D.cjs.map} +1 -1
  6. package/dist/{chunk-Y43Y4KJC.js → chunk-752MQ7LI.js} +3 -3
  7. package/dist/{chunk-PQR5Q2CN.cjs → chunk-7RVG2IVX.cjs} +3 -3
  8. package/dist/{chunk-PQR5Q2CN.cjs.map → chunk-7RVG2IVX.cjs.map} +1 -1
  9. package/dist/{chunk-X2AVHAPM.js → chunk-B4X2Q5MK.js} +2 -2
  10. package/dist/{chunk-MHZLOPOO.js → chunk-DCEXKPBH.js} +77 -16
  11. package/dist/chunk-DCEXKPBH.js.map +1 -0
  12. package/dist/{chunk-4LGYS5MV.js → chunk-DIDPIFGO.js} +2 -2
  13. package/dist/{chunk-JLA752YE.js → chunk-DTNNWOBN.js} +2 -2
  14. package/dist/{chunk-7X4BNPDR.js → chunk-EEJKU5SD.js} +2 -2
  15. package/dist/{chunk-QEOKQ5XD.js → chunk-IXCXFGYB.js} +2 -2
  16. package/dist/{chunk-FKAXXCRA.js → chunk-JQJYIYMJ.js} +2 -2
  17. package/dist/{chunk-ILPVBF4G.js → chunk-MHBJAY2T.js} +4 -4
  18. package/dist/{chunk-DQDDQ7IH.js → chunk-MP6CLG5T.js} +11 -11
  19. package/dist/{chunk-2YCBFGMT.js → chunk-MRFBERH2.js} +2 -2
  20. package/dist/{chunk-SWEGYVUL.js → chunk-OI4LVKFX.js} +2 -2
  21. package/dist/{chunk-6SITJI2W.cjs → chunk-OJL4V7WL.cjs} +25 -25
  22. package/dist/{chunk-6SITJI2W.cjs.map → chunk-OJL4V7WL.cjs.map} +1 -1
  23. package/dist/{chunk-XNEITV3L.js → chunk-Q6XWPGGB.js} +2 -2
  24. package/dist/{chunk-URA7A4PT.js → chunk-QQAANXHZ.js} +2 -2
  25. package/dist/{chunk-4JQO5D7Y.cjs → chunk-RPHURU2B.cjs} +79 -79
  26. package/dist/{chunk-4JQO5D7Y.cjs.map → chunk-RPHURU2B.cjs.map} +1 -1
  27. package/dist/{chunk-OOD7R4UR.js → chunk-RQCGVE3R.js} +2 -2
  28. package/dist/{chunk-HX556OPI.js → chunk-S4EPR2Q4.js} +2 -2
  29. package/dist/{chunk-3W4ZOEL3.js → chunk-TATLMLLJ.js} +3 -3
  30. package/dist/{chunk-AYYPVST4.cjs → chunk-U4QSRBEV.cjs} +2 -2
  31. package/dist/{chunk-AYYPVST4.cjs.map → chunk-U4QSRBEV.cjs.map} +1 -1
  32. package/dist/{chunk-O7YE4N45.js → chunk-UNTBPUY5.js} +2 -2
  33. package/dist/{chunk-BX7VJQ4K.js → chunk-UTDQAY35.js} +2 -2
  34. package/dist/{chunk-CQ2SQZU5.js → chunk-WUU63RFU.js} +3 -3
  35. package/dist/{chunk-NIKO5MNS.js → chunk-X6GHZRPS.js} +2 -2
  36. package/dist/{chunk-DG3BK3CA.js → chunk-XGUX3JDV.js} +4 -4
  37. package/dist/{chunk-ISHFQDFZ.cjs → chunk-XQJNL7TD.cjs} +6 -6
  38. package/dist/{chunk-ISHFQDFZ.cjs.map → chunk-XQJNL7TD.cjs.map} +1 -1
  39. package/dist/chunks-7ACTVPJJ.js +10 -0
  40. package/dist/cli.js +30 -30
  41. package/dist/{formula-XOF7RB5O.js → formula-IYTV7SBF.js} +3 -3
  42. package/dist/{formula-BHBMDZLT.js → formula-WSFS7D7Z.js} +4 -4
  43. package/dist/{formula-AAVTR32F.cjs → formula-WSK7DHQS.cjs} +9 -9
  44. package/dist/{formula-AAVTR32F.cjs.map → formula-WSK7DHQS.cjs.map} +1 -1
  45. package/dist/{image-ocr-FUDCRQ77.js → image-ocr-AVMUMNAV.js} +9 -9
  46. package/dist/{image-ocr-KRKCFP2H.cjs → image-ocr-LWWF4HEE.cjs} +17 -17
  47. package/dist/{image-ocr-KRKCFP2H.cjs.map → image-ocr-LWWF4HEE.cjs.map} +1 -1
  48. package/dist/{image-ocr-GQFTBSR5.js → image-ocr-Y75JNXPZ.js} +6 -6
  49. package/dist/index.cjs +512 -452
  50. package/dist/index.cjs.map +1 -1
  51. package/dist/index.js +76 -16
  52. package/dist/index.js.map +1 -1
  53. package/dist/mcp.js +23 -23
  54. package/dist/{model-bundle-636BXOZX.js → model-bundle-JOACGE6A.js} +5 -5
  55. package/dist/{models-X7KSG5YH.js → models-RTSOF7XB.js} +5 -5
  56. package/dist/{parse-worker-v2-K4DOWRRE.js → parse-worker-v2-GHCIS7RI.js} +12 -12
  57. package/dist/{parser-ZS6ZYKFT.js → parser-4NF5BGSC.js} +9 -9
  58. package/dist/{parser-TKVE62OM.js → parser-E7VENFW7.js} +12 -12
  59. package/dist/{parser-JG5TDHTN.cjs → parser-GJWAT5YG.cjs} +159 -159
  60. package/dist/{parser-JG5TDHTN.cjs.map → parser-GJWAT5YG.cjs.map} +1 -1
  61. package/dist/{pdf-ocr-R4BKOKOV.js → pdf-ocr-CJSC4DLZ.js} +6 -6
  62. package/dist/pdf-ocr-J74A2ZQW.cjs +35 -0
  63. package/dist/{pdf-ocr-JJTEVY6C.cjs.map → pdf-ocr-J74A2ZQW.cjs.map} +1 -1
  64. package/dist/{pdf-ocr-PJO3UIZQ.js → pdf-ocr-K4MHY4KP.js} +9 -9
  65. package/dist/{profile-io-6DC7KBGZ.js → profile-io-LA4LFEFV.js} +3 -3
  66. package/dist/{rasterize-CXMAQVBK.js → rasterize-PZ6VCPOZ.js} +3 -3
  67. package/dist/{redact-doc-3GGPUJT7.js → redact-doc-HHDDIIV7.js} +11 -11
  68. package/dist/{render-BARUM5VX.js → render-QIWXWLYC.js} +7 -7
  69. package/dist/seal-SBA3CFCC.js +10 -0
  70. package/dist/{setup-ZTF5QCXL.js → setup-Y6EZH34Z.js} +3 -3
  71. package/dist/visual-PN3PUVDG.js +21 -0
  72. package/dist/{watch-WJWZLQDF.js → watch-LBRW6NAG.js} +12 -12
  73. package/package.json +1 -1
  74. package/dist/chunk-MHZLOPOO.js.map +0 -1
  75. package/dist/chunks-KB7TWL43.js +0 -10
  76. package/dist/pdf-ocr-JJTEVY6C.cjs +0 -35
  77. package/dist/seal-NR6HNFHD.js +0 -10
  78. package/dist/visual-H5Z72EB2.js +0 -21
  79. /package/dist/{-EM3WKYYH.js.map → -IFNBZFGR.js.map} +0 -0
  80. /package/dist/{chunk-KUTKDE4Z.js.map → chunk-2IFSM7ZE.js.map} +0 -0
  81. /package/dist/{chunk-Y43Y4KJC.js.map → chunk-752MQ7LI.js.map} +0 -0
  82. /package/dist/{chunk-X2AVHAPM.js.map → chunk-B4X2Q5MK.js.map} +0 -0
  83. /package/dist/{chunk-4LGYS5MV.js.map → chunk-DIDPIFGO.js.map} +0 -0
  84. /package/dist/{chunk-JLA752YE.js.map → chunk-DTNNWOBN.js.map} +0 -0
  85. /package/dist/{chunk-7X4BNPDR.js.map → chunk-EEJKU5SD.js.map} +0 -0
  86. /package/dist/{chunk-QEOKQ5XD.js.map → chunk-IXCXFGYB.js.map} +0 -0
  87. /package/dist/{chunk-FKAXXCRA.js.map → chunk-JQJYIYMJ.js.map} +0 -0
  88. /package/dist/{chunk-ILPVBF4G.js.map → chunk-MHBJAY2T.js.map} +0 -0
  89. /package/dist/{chunk-DQDDQ7IH.js.map → chunk-MP6CLG5T.js.map} +0 -0
  90. /package/dist/{chunk-2YCBFGMT.js.map → chunk-MRFBERH2.js.map} +0 -0
  91. /package/dist/{chunk-SWEGYVUL.js.map → chunk-OI4LVKFX.js.map} +0 -0
  92. /package/dist/{chunk-XNEITV3L.js.map → chunk-Q6XWPGGB.js.map} +0 -0
  93. /package/dist/{chunk-URA7A4PT.js.map → chunk-QQAANXHZ.js.map} +0 -0
  94. /package/dist/{chunk-OOD7R4UR.js.map → chunk-RQCGVE3R.js.map} +0 -0
  95. /package/dist/{chunk-HX556OPI.js.map → chunk-S4EPR2Q4.js.map} +0 -0
  96. /package/dist/{chunk-3W4ZOEL3.js.map → chunk-TATLMLLJ.js.map} +0 -0
  97. /package/dist/{chunk-O7YE4N45.js.map → chunk-UNTBPUY5.js.map} +0 -0
  98. /package/dist/{chunk-BX7VJQ4K.js.map → chunk-UTDQAY35.js.map} +0 -0
  99. /package/dist/{chunk-CQ2SQZU5.js.map → chunk-WUU63RFU.js.map} +0 -0
  100. /package/dist/{chunk-NIKO5MNS.js.map → chunk-X6GHZRPS.js.map} +0 -0
  101. /package/dist/{chunk-DG3BK3CA.js.map → chunk-XGUX3JDV.js.map} +0 -0
  102. /package/dist/{chunks-KB7TWL43.js.map → chunks-7ACTVPJJ.js.map} +0 -0
  103. /package/dist/{formula-XOF7RB5O.js.map → formula-IYTV7SBF.js.map} +0 -0
  104. /package/dist/{formula-BHBMDZLT.js.map → formula-WSFS7D7Z.js.map} +0 -0
  105. /package/dist/{image-ocr-FUDCRQ77.js.map → image-ocr-AVMUMNAV.js.map} +0 -0
  106. /package/dist/{image-ocr-GQFTBSR5.js.map → image-ocr-Y75JNXPZ.js.map} +0 -0
  107. /package/dist/{model-bundle-636BXOZX.js.map → model-bundle-JOACGE6A.js.map} +0 -0
  108. /package/dist/{models-X7KSG5YH.js.map → models-RTSOF7XB.js.map} +0 -0
  109. /package/dist/{parse-worker-v2-K4DOWRRE.js.map → parse-worker-v2-GHCIS7RI.js.map} +0 -0
  110. /package/dist/{parser-ZS6ZYKFT.js.map → parser-4NF5BGSC.js.map} +0 -0
  111. /package/dist/{parser-TKVE62OM.js.map → parser-E7VENFW7.js.map} +0 -0
  112. /package/dist/{pdf-ocr-PJO3UIZQ.js.map → pdf-ocr-CJSC4DLZ.js.map} +0 -0
  113. /package/dist/{pdf-ocr-R4BKOKOV.js.map → pdf-ocr-K4MHY4KP.js.map} +0 -0
  114. /package/dist/{profile-io-6DC7KBGZ.js.map → profile-io-LA4LFEFV.js.map} +0 -0
  115. /package/dist/{rasterize-CXMAQVBK.js.map → rasterize-PZ6VCPOZ.js.map} +0 -0
  116. /package/dist/{redact-doc-3GGPUJT7.js.map → redact-doc-HHDDIIV7.js.map} +0 -0
  117. /package/dist/{render-BARUM5VX.js.map → render-QIWXWLYC.js.map} +0 -0
  118. /package/dist/{seal-NR6HNFHD.js.map → seal-SBA3CFCC.js.map} +0 -0
  119. /package/dist/{setup-ZTF5QCXL.js.map → setup-Y6EZH34Z.js.map} +0 -0
  120. /package/dist/{visual-H5Z72EB2.js.map → visual-PN3PUVDG.js.map} +0 -0
  121. /package/dist/{watch-WJWZLQDF.js.map → watch-LBRW6NAG.js.map} +0 -0
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  loadSharp,
4
4
  rasterizePageSvg
5
- } from "./chunk-SWEGYVUL.js";
5
+ } from "./chunk-OI4LVKFX.js";
6
6
  import {
7
7
  inlineImagesIntoMarkdown
8
8
  } from "./chunk-VKVDMH7X.js";
@@ -16,7 +16,7 @@ import {
16
16
  HEADING_RATIO_H3,
17
17
  tidyScriptTags,
18
18
  unframeLayoutTables
19
- } from "./chunk-7X4BNPDR.js";
19
+ } from "./chunk-EEJKU5SD.js";
20
20
  import {
21
21
  MAX_COLS,
22
22
  MAX_ROWS,
@@ -33,7 +33,7 @@ import {
33
33
  mapPuaText,
34
34
  markNonLayoutTable,
35
35
  romanNumeral
36
- } from "./chunk-QEOKQ5XD.js";
36
+ } from "./chunk-IXCXFGYB.js";
37
37
  import {
38
38
  DEFAULT_CHAR,
39
39
  DEFAULT_PARA_GEOM,
@@ -47,15 +47,16 @@ import {
47
47
  hwpxAppMajor,
48
48
  parseRenderStyles,
49
49
  readZipEntry
50
- } from "./chunk-URA7A4PT.js";
50
+ } from "./chunk-QQAANXHZ.js";
51
51
  import {
52
52
  KordocError,
53
53
  compareSectionPaths,
54
54
  escapeHtml,
55
55
  precheckZipSize,
56
56
  sanitizeHref,
57
+ stripDtd,
57
58
  toArrayBuffer
58
- } from "./chunk-NIKO5MNS.js";
59
+ } from "./chunk-X6GHZRPS.js";
59
60
 
60
61
  // src/render/svg-render.ts
61
62
  import JSZip from "jszip";
@@ -12119,6 +12120,18 @@ function elements2(el) {
12119
12120
  function num2(el, attr, fallback = 0) {
12120
12121
  return el ? toInt32(el.getAttribute(attr) ?? void 0, fallback) : fallback;
12121
12122
  }
12123
+ function staleTableSz(tbl) {
12124
+ const rows = /* @__PURE__ */ new Map();
12125
+ for (const tr of elements2(tbl)) if (ln2(tr) === "tr") {
12126
+ for (const tc of elements2(tr)) if (ln2(tc) === "tc") {
12127
+ const ra = num2(findChildByLocalName(tc, "cellAddr"), "rowAddr"), rs = num2(findChildByLocalName(tc, "cellSpan"), "rowSpan") || 1;
12128
+ if (rs === 1) rows.set(ra, Math.max(rows.get(ra) ?? 0, num2(findChildByLocalName(tc, "cellSz"), "height")));
12129
+ }
12130
+ }
12131
+ let sum = 0;
12132
+ for (const v of rows.values()) sum += v;
12133
+ return rows.size > 0 && sum + 1e3 < num2(findChildByLocalName(tbl, "sz"), "height");
12134
+ }
12122
12135
  function shiftParaVert(p, delta) {
12123
12136
  for (const lsa of elements2(p)) {
12124
12137
  if (ln2(lsa) !== "linesegarray") continue;
@@ -12323,7 +12336,7 @@ function reflowPara(p, doc, styles, areaW, startV, mode, zones = [], nums = /* @
12323
12336
  let firstFloatVo = 0;
12324
12337
  const lineFloats = [];
12325
12338
  let objBottom = startV;
12326
- const effHOf = (o) => (o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el, geomMemo(styles))) : o.inline ? Math.max(o.height, drawTextHeight(o.el)) : o.height) + captionExtra(o.el);
12339
+ const effHOf = (o) => (o.tag === "tbl" ? staleTableSz(o.el) ? measureTableHeight(o.el, geomMemo(styles)) : Math.max(o.height, measureTableHeight(o.el, geomMemo(styles))) : o.inline ? Math.max(o.height, drawTextHeight(o.el)) : o.height) + captionExtra(o.el);
12327
12340
  let cellFloatBottom = 0, cellTextBelow = 0;
12328
12341
  const spacesOnly = spacesHost(p);
12329
12342
  const zoneStart = zones.length;
@@ -12636,6 +12649,7 @@ function carryZones(zones, bodyH, oneColumn) {
12636
12649
  zones.push(...moved);
12637
12650
  }
12638
12651
  var STALE_SLACK = 500;
12652
+ var STALE_CACHE_SHIFT = 2e3;
12639
12653
  function regrownInlineTables(p) {
12640
12654
  const out = [];
12641
12655
  for (const run of elements2(p)) {
@@ -12744,6 +12758,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
12744
12758
  const cellW = areaW;
12745
12759
  let cellCols = 1, cellCol = 0;
12746
12760
  let staleRest = false;
12761
+ let prevReflowed = false, cacheShift = 0, lastStored = 0;
12747
12762
  for (const p of elements2(container)) {
12748
12763
  if (ln2(p) !== "p") continue;
12749
12764
  if (bodyFlow) {
@@ -12791,6 +12806,18 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
12791
12806
  }
12792
12807
  if (!res) {
12793
12808
  const lsa = findChildByLocalName(p, "linesegarray");
12809
+ if (lsa && bodyFlow) {
12810
+ const segs = elements2(lsa).filter((e) => ln2(e) === "lineseg");
12811
+ const vs = segs.map((e) => num2(e, "vertpos")), v0 = vs[0] ?? 0;
12812
+ const mono = vs.every((v, i) => i === 0 || v >= vs[i - 1]);
12813
+ if (prevReflowed) {
12814
+ const d = startV - v0;
12815
+ cacheShift = mono && v0 > 0 && d <= STALE_CACHE_SHIFT ? d : 0;
12816
+ } else if (cacheShift && (!mono || v0 < lastStored)) cacheShift = 0;
12817
+ if (segs.length) lastStored = vs[vs.length - 1] + num2(segs[segs.length - 1], "vertsize");
12818
+ if (cacheShift) shiftParaVert(p, cacheShift);
12819
+ }
12820
+ prevReflowed = false;
12794
12821
  if (lsa) {
12795
12822
  const bottom = cachedParagraphBottom(lsa, bodyFlow);
12796
12823
  if (Number.isFinite(bottom)) {
@@ -12801,6 +12828,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
12801
12828
  continue;
12802
12829
  }
12803
12830
  const paraH = res.paraBottom - startV;
12831
+ prevReflowed = true;
12804
12832
  const explicitBreak = bodyH > 0 && startV > 0 && (p.getAttribute("pageBreak") === "1" || p.getAttribute("columnBreak") === "1" || !!g?.pageBreakBefore);
12805
12833
  const lines = bodyH > 0 ? elements2(findChildByLocalName(p, "linesegarray") ?? p).filter((e) => ln2(e) === "lineseg") : [];
12806
12834
  const reserve = bodyH > 0 ? pageBottomReserve(p) : 0;
@@ -13386,6 +13414,21 @@ function spanPartRows(cells, rowY) {
13386
13414
  }
13387
13415
  return out;
13388
13416
  }
13417
+ function coAnchoredFollower(tbl) {
13418
+ const isTb = (o) => {
13419
+ const pos = findChildByLocalName(o, "pos");
13420
+ return !!pos && pos.getAttribute("treatAsChar") !== "1" && (pos.getAttribute("vertRelTo") ?? "PARA") === "PARA" && (o.getAttribute("textWrap") ?? "TOP_AND_BOTTOM") === "TOP_AND_BOTTOM";
13421
+ };
13422
+ const p = tbl.parentNode?.parentNode;
13423
+ if (!p || ln(p) !== "p" || !isTb(tbl)) return false;
13424
+ let seen = false;
13425
+ for (const run of elements(p)) if (ln(run) === "run") for (const o of elements(run)) {
13426
+ if (o === tbl) return seen;
13427
+ if ((ln(o) === "tbl" || ln(o) === "pic") && isTb(o)) seen = true;
13428
+ }
13429
+ return false;
13430
+ }
13431
+ var ROW_CARRY_MIN = 1e3;
13389
13432
  function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, nested = false, contMT = MT) {
13390
13433
  if (nested) slack = 0;
13391
13434
  const nRows = rowH.length;
@@ -13404,7 +13447,8 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
13404
13447
  const declared = num(findChildByLocalName(tbl, "sz"), "height");
13405
13448
  if (rowY.some((v, k) => k > 0 && k < nRows && Math.abs(v - declared) <= 2)) slack = 0;
13406
13449
  }
13407
- if (BODY_H <= 0 || ty + rowY[nRows] <= pageBottom + slack && !stackOver) return plain();
13450
+ const savedParts = tbl.getAttribute("pageBreak") === "CELL" && cells.some((c) => c.h > rowY[nRows] && cellLineBoxes(c).some((b) => b.part > 0));
13451
+ if (BODY_H <= 0 || ty + rowY[nRows] <= pageBottom + slack && !stackOver && !savedParts) return plain();
13408
13452
  if (findChildByLocalName(tbl, "pos")?.getAttribute("treatAsChar") === "1") {
13409
13453
  const declared = num(findChildByLocalName(tbl, "sz"), "height") || rowY[nRows];
13410
13454
  if (ty - MT < 2e3 || ty + declared <= pageBottom + slack) return plain();
@@ -13418,11 +13462,15 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
13418
13462
  const out = [];
13419
13463
  const flows = (findChildByLocalName(tbl, "pos")?.getAttribute("vertRelTo") ?? "PARA") === "PARA";
13420
13464
  let page = 0, y = ty, first = !flows || ty - MT < 2e3;
13465
+ if (!first && coAnchoredFollower(tbl)) {
13466
+ const outT = num(findChildByLocalName(tbl, "outMargin"), "top");
13467
+ if (outT + rowY[nRows] + outB <= BODY_H) return rowH.map((h, r) => [{ page: 1, y: contMT + outT + rowY[r], h }]);
13468
+ }
13421
13469
  const spanStarts = cellSplit ? spanPartRows(cells, rowY) : /* @__PURE__ */ new Set();
13422
13470
  for (let r = 0; r < nRows; r++) {
13423
13471
  let h = rowH[r];
13424
13472
  const pieces = [];
13425
- if (!first && r >= hdrRows && spanStarts.has(r)) {
13473
+ if (!first && r >= hdrRows && spanStarts.has(r) && !cells.some((c) => c.rs > 1 && c.ra < r && c.ra + c.rs > r && (out[c.ra]?.[0]?.page ?? page) < page)) {
13426
13474
  page++;
13427
13475
  y = contTop;
13428
13476
  first = true;
@@ -13568,6 +13616,10 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
13568
13616
  if (splittable && y + h + outB > pageBottom) {
13569
13617
  const from = /* @__PURE__ */ new Map();
13570
13618
  const lines = new Map(rowCells.map((c) => [c.el, cellLines(c)]));
13619
+ const sp0 = new Map(rowCells.map((c) => {
13620
+ const b = cellLineBoxes(c)[0];
13621
+ return [c.el, b ? num(b.seg, "spacing") : 0];
13622
+ }));
13571
13623
  while (y + h + outB > pageBottom && BODY_H > rowY[hdrRows]) {
13572
13624
  const avail = pageBottom - y - outB;
13573
13625
  let rem = 0, placed = false, allFit = true, blocked = false;
@@ -13580,7 +13632,7 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
13580
13632
  continue;
13581
13633
  }
13582
13634
  const end = Math.max(...ls.map((l) => l[1]));
13583
- const k = ls.findIndex((l) => c.marginT + (l[1] - off) > avail - c.marginB);
13635
+ const k = ls.findIndex((l, i) => c.marginT + (l[1] + (off === 0 && i === 0 && ls.length > 1 ? sp0.get(c.el) ?? 0 : 0) - off) > avail - c.marginB);
13584
13636
  if (k < 0) {
13585
13637
  cuts.push([c.el, off, end + 1]);
13586
13638
  continue;
@@ -13593,13 +13645,21 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
13593
13645
  }
13594
13646
  if (allFit) {
13595
13647
  const spanCells = cells.filter((c) => c.ra === r && c.rs > 1);
13596
- if (!first && h <= pageBottom - contTop && [...rowCells, ...spanCells].some((c) => cellContentExtent(c) + c.marginT + c.marginB > avail)) {
13648
+ const spanExt = (c) => {
13649
+ const bs = cellLineBoxes(c);
13650
+ return bs.some((b) => b.part > 0) ? Math.max(...bs.filter((b) => b.part === 0).map((b) => b.bottom)) : cellContentExtent(c);
13651
+ };
13652
+ if (!first && h <= pageBottom - contTop && [...rowCells.map((c) => cellContentExtent(c) + c.marginT + c.marginB), ...spanCells.map((c) => spanExt(c) + c.marginT + c.marginB)].some((e) => e > avail)) {
13597
13653
  page++;
13598
13654
  y = contTop;
13599
13655
  first = true;
13600
13656
  break;
13601
13657
  }
13602
- if (nested && avail > 0) {
13658
+ const carry = !nested && h - avail > ROW_CARRY_MIN && h <= pageBottom - contTop && rowCells.every((c) => {
13659
+ const e = cellContentExtent(c) + c.marginT + c.marginB, va = c.sub?.getAttribute("vertAlign") ?? "TOP";
13660
+ return (va === "CENTER" ? (h + e) / 2 : va === "BOTTOM" ? h : e) <= avail;
13661
+ });
13662
+ if ((nested || carry) && avail > 0) {
13603
13663
  pieces.push({ page, y, h: avail, range: new Map(rowCells.map((c) => [c.el, [from.get(c.el) ?? 0, Number.POSITIVE_INFINITY]])) });
13604
13664
  for (const c of rowCells) from.set(c.el, Number.POSITIVE_INFINITY);
13605
13665
  page++;
@@ -14948,7 +15008,8 @@ function drawPara(p, ox, oy, areaW, ctx, depth, segPages) {
14948
15008
  const shadowed = o.tag === "pic" && !!findChildByLocalName(findChildByLocalName(o.el, "effects") ?? o.el, "shadow") && plan.seg.textheight > o.height && Math.abs(plan.seg.baseline - Math.round(plan.seg.textheight * 0.85)) <= 2;
14949
15009
  const eqAsc = o.tag === "equation" && Number(o.el.getAttribute("baseLine")) > 0 ? Math.round(o.height * Number(o.el.getAttribute("baseLine")) / 100) : shadowed ? Math.round(plan.seg.textheight * 0.85) : o.tag === "pic" ? Math.round(o.height * 0.85) : o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el, ctx.extentMemo)) : o.height;
14950
15010
  const iom = findChildByLocalName(o.el, "outMargin"), iomT = num(iom, "top"), iomB = num(iom, "bottom");
14951
- const yTop = oy + plan.seg.vertpos + Math.max(iomT, plan.seg.baseline - eqAsc - iomB - captionExtra(o.el));
15011
+ const capX = captionExtra(o.el);
15012
+ const yTop = oy + plan.seg.vertpos + Math.max(iomT, o.tag === "tbl" && capX === 0 ? plan.seg.baseline - Math.round((eqAsc + iomT + iomB) * 0.85) + iomT : plan.seg.baseline - eqAsc - iomB - capX);
14952
15013
  drawObject(o, x, yTop, baseV, areaW, ctx, depth);
14953
15014
  } else {
14954
15015
  if (segPages && segPages[0] !== void 0) ctx.page = segPages[0];
@@ -15929,12 +15990,12 @@ async function renderHwpxInternal(input, options) {
15929
15990
  const verFile = zip.file("version.xml");
15930
15991
  const verXml = verFile ? await readZipEntry(verFile, "text") : void 0;
15931
15992
  const appMajor = hwpxAppMajor(verXml), appBuild = hwpxAppBuild(verXml);
15932
- const headXml = headFile ? await readZipEntry(headFile, "text") : void 0;
15993
+ const headXml = headFile ? stripDtd(await readZipEntry(headFile, "text")) : void 0;
15933
15994
  let styles = headXml ? parseRenderStyles(headXml, { appMajor, appBuild }) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
15934
15995
  if (!headFile) warnings.push("header.xml \uC5C6\uC74C \u2014 \uAE30\uBCF8 \uC2A4\uD0C0\uC77C\uB85C \uB80C\uB354");
15935
15996
  const secXmls = [];
15936
15997
  for (const f of secFiles) {
15937
- const xml = await readZipEntry(f, "text");
15998
+ const xml = stripDtd(await readZipEntry(f, "text"));
15938
15999
  if (xml.length > MAX_DECOMPRESS_SIZE) throw new KordocError("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
15939
16000
  secXmls.push(xml);
15940
16001
  }
@@ -15945,7 +16006,7 @@ async function renderHwpxInternal(input, options) {
15945
16006
  const masterPages = /* @__PURE__ */ new Map();
15946
16007
  const masterXmls = [];
15947
16008
  for (const file of zip.file(/Contents\/masterpage[^/]*\.xml$/i)) {
15948
- const xml = await readZipEntry(file, "text");
16009
+ const xml = stripDtd(await readZipEntry(file, "text"));
15949
16010
  if (xml.length > MAX_DECOMPRESS_SIZE) throw new KordocError("\uBC14\uD0D5\uCABD XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
15950
16011
  const root = createXmlParser().parseFromString(xml, "text/xml").documentElement;
15951
16012
  if (root && ln(root) === "masterPage") {
@@ -20205,4 +20266,4 @@ export {
20205
20266
  cropRect,
20206
20267
  extractRenderedRegions
20207
20268
  };
20208
- //# sourceMappingURL=chunk-MHZLOPOO.js.map
20269
+ //# sourceMappingURL=chunk-DCEXKPBH.js.map