kordoc 4.22.9 → 4.22.11

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 (122) hide show
  1. package/README.md +6 -4
  2. package/dist/{-KJW567ZH.js → -HVSX4WBM.js} +11 -11
  3. package/dist/{chunk-VH2QBIUA.js → chunk-4YZMZMSL.js} +2 -2
  4. package/dist/{chunk-55XTFFLH.js → chunk-4ZUR6QAO.js} +4 -4
  5. package/dist/{chunk-6LM4CAOF.js → chunk-7HTGSGIV.js} +2 -2
  6. package/dist/{chunk-SU6ABNIX.cjs → chunk-A4UUVU43.cjs} +3 -3
  7. package/dist/{chunk-SU6ABNIX.cjs.map → chunk-A4UUVU43.cjs.map} +1 -1
  8. package/dist/{chunk-BTLQOIES.cjs → chunk-DRBOO4F2.cjs} +23 -23
  9. package/dist/{chunk-BTLQOIES.cjs.map → chunk-DRBOO4F2.cjs.map} +1 -1
  10. package/dist/{chunk-7PBVL7NL.js → chunk-GMBWB4OU.js} +2 -2
  11. package/dist/{chunk-MLTGRR6C.js → chunk-JBPCRB4H.js} +2 -2
  12. package/dist/{chunk-7RVYIPLH.js → chunk-JX3QPTMU.js} +2 -2
  13. package/dist/{chunk-NT54LN6C.js → chunk-K6EG6ACM.js} +136 -75
  14. package/dist/chunk-K6EG6ACM.js.map +1 -0
  15. package/dist/{chunk-F6C4UO55.js → chunk-KINTYLL4.js} +2 -2
  16. package/dist/{chunk-ZBUOPXGD.js → chunk-LP6D54PI.js} +2 -2
  17. package/dist/{chunk-Z4SUS7JW.js → chunk-MDMCZUDP.js} +2 -2
  18. package/dist/{chunk-VQ5DOQZO.js → chunk-NCP7M4N2.js} +3 -3
  19. package/dist/{chunk-UNFXTOU3.js → chunk-NK3WCKJA.js} +3 -3
  20. package/dist/{chunk-CKWCSQGW.js → chunk-PFDAVLZT.js} +11 -11
  21. package/dist/{chunk-XSRXVLOL.js → chunk-PGIFLIT5.js} +2 -2
  22. package/dist/{chunk-EREKI4DD.cjs → chunk-PJHRL7UZ.cjs} +2 -2
  23. package/dist/{chunk-EREKI4DD.cjs.map → chunk-PJHRL7UZ.cjs.map} +1 -1
  24. package/dist/{chunk-SO4ZYWYE.cjs → chunk-QJRRJB6Z.cjs} +6 -6
  25. package/dist/{chunk-SO4ZYWYE.cjs.map → chunk-QJRRJB6Z.cjs.map} +1 -1
  26. package/dist/{chunk-OREE2GWG.js → chunk-QLDKBCAG.js} +2 -2
  27. package/dist/{chunk-AZUWSGMI.js → chunk-RLMAOBWN.js} +2 -2
  28. package/dist/{chunk-AZUWSGMI.js.map → chunk-RLMAOBWN.js.map} +1 -1
  29. package/dist/{chunk-Q3GZMZTK.cjs → chunk-RWWUQMLO.cjs} +24 -24
  30. package/dist/{chunk-Q3GZMZTK.cjs.map → chunk-RWWUQMLO.cjs.map} +1 -1
  31. package/dist/{chunk-VSH7EV3W.cjs → chunk-SOHPBZHR.cjs} +3 -3
  32. package/dist/{chunk-VSH7EV3W.cjs.map → chunk-SOHPBZHR.cjs.map} +1 -1
  33. package/dist/{chunk-UPZISYRP.js → chunk-SWY3AIPF.js} +2 -2
  34. package/dist/{chunk-AX3XT5Y7.js → chunk-WTJ7NVIJ.js} +3 -3
  35. package/dist/{chunk-DF6NB52F.js → chunk-XWTXCBXT.js} +4 -4
  36. package/dist/{chunk-R5TMMRVG.js → chunk-YP5T2EZ7.js} +2 -2
  37. package/dist/{chunk-D44JWJPI.js → chunk-Z6EA67XV.js} +2 -2
  38. package/dist/{chunk-D44JWJPI.js.map → chunk-Z6EA67XV.js.map} +1 -1
  39. package/dist/{chunk-3MTKUEA7.js → chunk-ZXNKMDBN.js} +4 -4
  40. package/dist/{chunk-ZP6SRHAD.js → chunk-ZYKZS3F6.js} +2 -2
  41. package/dist/chunks-OZGUNAAZ.js +10 -0
  42. package/dist/cli.js +30 -30
  43. package/dist/{formula-47QIFQ7V.js → formula-67MKCQ44.js} +4 -4
  44. package/dist/{formula-JCG77RAE.cjs → formula-MO5QV2WU.cjs} +9 -9
  45. package/dist/{formula-JCG77RAE.cjs.map → formula-MO5QV2WU.cjs.map} +1 -1
  46. package/dist/{formula-GZEMCXLD.js → formula-N3GX3SO2.js} +3 -3
  47. package/dist/{image-ocr-FAHJNFDG.js → image-ocr-65B7BSUH.js} +9 -9
  48. package/dist/{image-ocr-RTS5BZRM.cjs → image-ocr-7GIT7REG.cjs} +17 -17
  49. package/dist/{image-ocr-RTS5BZRM.cjs.map → image-ocr-7GIT7REG.cjs.map} +1 -1
  50. package/dist/{image-ocr-HEKAORHV.js → image-ocr-PQ2Q55I2.js} +6 -6
  51. package/dist/index.cjs +524 -463
  52. package/dist/index.cjs.map +1 -1
  53. package/dist/index.js +136 -75
  54. package/dist/index.js.map +1 -1
  55. package/dist/mcp.js +30 -23
  56. package/dist/mcp.js.map +1 -1
  57. package/dist/{model-bundle-IN3RQ52S.js → model-bundle-AH3WIGOE.js} +5 -5
  58. package/dist/{models-FHSKU7WB.js → models-YFEVC3DI.js} +5 -5
  59. package/dist/{parse-worker-v2-I3A77UZB.js → parse-worker-v2-7NT2ZMYZ.js} +12 -12
  60. package/dist/{parser-A4SIJK2I.cjs → parser-DIA2JXPE.cjs} +157 -157
  61. package/dist/{parser-A4SIJK2I.cjs.map → parser-DIA2JXPE.cjs.map} +1 -1
  62. package/dist/{parser-JDLV2EI4.js → parser-OZI6POE7.js} +12 -12
  63. package/dist/{parser-ZLZRQLZU.js → parser-REXFNEES.js} +9 -9
  64. package/dist/pdf-ocr-3K5LAKGL.cjs +31 -0
  65. package/dist/{pdf-ocr-MKSW5GJ7.cjs.map → pdf-ocr-3K5LAKGL.cjs.map} +1 -1
  66. package/dist/{pdf-ocr-SJKJ7JT7.js → pdf-ocr-EUJDEV4Z.js} +6 -6
  67. package/dist/{pdf-ocr-VIEII6TD.js → pdf-ocr-U2XEMTFR.js} +9 -9
  68. package/dist/{profile-io-ZPCTNRBM.js → profile-io-OIFR5XXG.js} +3 -3
  69. package/dist/{rasterize-QT7IPC27.js → rasterize-7QURJJZB.js} +3 -3
  70. package/dist/{redact-doc-64PLXN3U.js → redact-doc-OIHZYWVF.js} +11 -11
  71. package/dist/{render-43RSFAGY.js → render-ZAJ4L4QM.js} +7 -7
  72. package/dist/seal-XVZFHFMG.js +10 -0
  73. package/dist/{setup-46VYX5XM.js → setup-MWFDDT5X.js} +3 -3
  74. package/dist/visual-QZVCWEG2.js +21 -0
  75. package/dist/{watch-ZBBQKEKD.js → watch-7K2NBGMZ.js} +12 -12
  76. package/package.json +1 -1
  77. package/dist/chunk-NT54LN6C.js.map +0 -1
  78. package/dist/chunks-YCPWFWFT.js +0 -10
  79. package/dist/pdf-ocr-MKSW5GJ7.cjs +0 -31
  80. package/dist/seal-RQZTBH54.js +0 -10
  81. package/dist/visual-JFUP46UP.js +0 -21
  82. /package/dist/{-KJW567ZH.js.map → -HVSX4WBM.js.map} +0 -0
  83. /package/dist/{chunk-VH2QBIUA.js.map → chunk-4YZMZMSL.js.map} +0 -0
  84. /package/dist/{chunk-55XTFFLH.js.map → chunk-4ZUR6QAO.js.map} +0 -0
  85. /package/dist/{chunk-6LM4CAOF.js.map → chunk-7HTGSGIV.js.map} +0 -0
  86. /package/dist/{chunk-7PBVL7NL.js.map → chunk-GMBWB4OU.js.map} +0 -0
  87. /package/dist/{chunk-MLTGRR6C.js.map → chunk-JBPCRB4H.js.map} +0 -0
  88. /package/dist/{chunk-7RVYIPLH.js.map → chunk-JX3QPTMU.js.map} +0 -0
  89. /package/dist/{chunk-F6C4UO55.js.map → chunk-KINTYLL4.js.map} +0 -0
  90. /package/dist/{chunk-ZBUOPXGD.js.map → chunk-LP6D54PI.js.map} +0 -0
  91. /package/dist/{chunk-Z4SUS7JW.js.map → chunk-MDMCZUDP.js.map} +0 -0
  92. /package/dist/{chunk-VQ5DOQZO.js.map → chunk-NCP7M4N2.js.map} +0 -0
  93. /package/dist/{chunk-UNFXTOU3.js.map → chunk-NK3WCKJA.js.map} +0 -0
  94. /package/dist/{chunk-CKWCSQGW.js.map → chunk-PFDAVLZT.js.map} +0 -0
  95. /package/dist/{chunk-XSRXVLOL.js.map → chunk-PGIFLIT5.js.map} +0 -0
  96. /package/dist/{chunk-OREE2GWG.js.map → chunk-QLDKBCAG.js.map} +0 -0
  97. /package/dist/{chunk-UPZISYRP.js.map → chunk-SWY3AIPF.js.map} +0 -0
  98. /package/dist/{chunk-AX3XT5Y7.js.map → chunk-WTJ7NVIJ.js.map} +0 -0
  99. /package/dist/{chunk-DF6NB52F.js.map → chunk-XWTXCBXT.js.map} +0 -0
  100. /package/dist/{chunk-R5TMMRVG.js.map → chunk-YP5T2EZ7.js.map} +0 -0
  101. /package/dist/{chunk-3MTKUEA7.js.map → chunk-ZXNKMDBN.js.map} +0 -0
  102. /package/dist/{chunk-ZP6SRHAD.js.map → chunk-ZYKZS3F6.js.map} +0 -0
  103. /package/dist/{chunks-YCPWFWFT.js.map → chunks-OZGUNAAZ.js.map} +0 -0
  104. /package/dist/{formula-47QIFQ7V.js.map → formula-67MKCQ44.js.map} +0 -0
  105. /package/dist/{formula-GZEMCXLD.js.map → formula-N3GX3SO2.js.map} +0 -0
  106. /package/dist/{image-ocr-FAHJNFDG.js.map → image-ocr-65B7BSUH.js.map} +0 -0
  107. /package/dist/{image-ocr-HEKAORHV.js.map → image-ocr-PQ2Q55I2.js.map} +0 -0
  108. /package/dist/{model-bundle-IN3RQ52S.js.map → model-bundle-AH3WIGOE.js.map} +0 -0
  109. /package/dist/{models-FHSKU7WB.js.map → models-YFEVC3DI.js.map} +0 -0
  110. /package/dist/{parse-worker-v2-I3A77UZB.js.map → parse-worker-v2-7NT2ZMYZ.js.map} +0 -0
  111. /package/dist/{parser-JDLV2EI4.js.map → parser-OZI6POE7.js.map} +0 -0
  112. /package/dist/{parser-ZLZRQLZU.js.map → parser-REXFNEES.js.map} +0 -0
  113. /package/dist/{pdf-ocr-SJKJ7JT7.js.map → pdf-ocr-EUJDEV4Z.js.map} +0 -0
  114. /package/dist/{pdf-ocr-VIEII6TD.js.map → pdf-ocr-U2XEMTFR.js.map} +0 -0
  115. /package/dist/{profile-io-ZPCTNRBM.js.map → profile-io-OIFR5XXG.js.map} +0 -0
  116. /package/dist/{rasterize-QT7IPC27.js.map → rasterize-7QURJJZB.js.map} +0 -0
  117. /package/dist/{redact-doc-64PLXN3U.js.map → redact-doc-OIHZYWVF.js.map} +0 -0
  118. /package/dist/{render-43RSFAGY.js.map → render-ZAJ4L4QM.js.map} +0 -0
  119. /package/dist/{seal-RQZTBH54.js.map → seal-XVZFHFMG.js.map} +0 -0
  120. /package/dist/{setup-46VYX5XM.js.map → setup-MWFDDT5X.js.map} +0 -0
  121. /package/dist/{visual-JFUP46UP.js.map → visual-QZVCWEG2.js.map} +0 -0
  122. /package/dist/{watch-ZBBQKEKD.js.map → watch-7K2NBGMZ.js.map} +0 -0
@@ -3,7 +3,7 @@ import {
3
3
  ensureModelsIn,
4
4
  getModelStatusIn,
5
5
  getModelsDir
6
- } from "./chunk-ZBUOPXGD.js";
6
+ } from "./chunk-LP6D54PI.js";
7
7
 
8
8
  // src/ocr/models.ts
9
9
  import { join } from "path";
@@ -162,4 +162,4 @@ export {
162
162
  parseCharacterDict,
163
163
  ocrModelPath
164
164
  };
165
- //# sourceMappingURL=chunk-7PBVL7NL.js.map
165
+ //# sourceMappingURL=chunk-GMBWB4OU.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  escapeHtml,
3
3
  sanitizeHref
4
- } from "./chunk-D44JWJPI.js";
4
+ } from "./chunk-Z6EA67XV.js";
5
5
 
6
6
  // src/script-tags.ts
7
7
  var LITERAL_TAG = /<(?=\/?(?:u|sup|sub)>)/g;
@@ -1539,4 +1539,4 @@ export {
1539
1539
  HEADING_RATIO_H3,
1540
1540
  validateOcrOptions
1541
1541
  };
1542
- //# sourceMappingURL=chunk-MLTGRR6C.js.map
1542
+ //# sourceMappingURL=chunk-JBPCRB4H.js.map
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  KordocError,
4
4
  unzipLimitBytes
5
- } from "./chunk-AZUWSGMI.js";
5
+ } from "./chunk-RLMAOBWN.js";
6
6
 
7
7
  // src/hwpx/parser-shared.ts
8
8
  import { DOMParser } from "@xmldom/xmldom";
@@ -494,4 +494,4 @@ export {
494
494
  hwpFaceToCssStack,
495
495
  parseRenderStyles
496
496
  };
497
- //# sourceMappingURL=chunk-7RVYIPLH.js.map
497
+ //# sourceMappingURL=chunk-JX3QPTMU.js.map
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  loadSharp,
4
4
  rasterizePageSvg
5
- } from "./chunk-VH2QBIUA.js";
5
+ } from "./chunk-4YZMZMSL.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-6LM4CAOF.js";
19
+ } from "./chunk-7HTGSGIV.js";
20
20
  import {
21
21
  MAX_COLS,
22
22
  MAX_ROWS,
@@ -32,7 +32,7 @@ import {
32
32
  mapPuaText,
33
33
  markNonLayoutTable,
34
34
  romanNumeral
35
- } from "./chunk-F6C4UO55.js";
35
+ } from "./chunk-KINTYLL4.js";
36
36
  import {
37
37
  DEFAULT_CHAR,
38
38
  DEFAULT_PARA_GEOM,
@@ -46,7 +46,7 @@ import {
46
46
  hwpxAppMajor,
47
47
  parseRenderStyles,
48
48
  readZipEntry
49
- } from "./chunk-7RVYIPLH.js";
49
+ } from "./chunk-JX3QPTMU.js";
50
50
  import {
51
51
  KordocError,
52
52
  compareSectionPaths,
@@ -54,7 +54,7 @@ import {
54
54
  precheckZipSize,
55
55
  sanitizeHref,
56
56
  toArrayBuffer
57
- } from "./chunk-AZUWSGMI.js";
57
+ } from "./chunk-RLMAOBWN.js";
58
58
 
59
59
  // src/render/svg-render.ts
60
60
  import JSZip from "jszip";
@@ -107,7 +107,30 @@ function solveBoundaries(constraints, count, total) {
107
107
  for (let k = 1; k <= count; k++) if (out[k] < out[k - 1]) out[k] = out[k - 1];
108
108
  return out;
109
109
  }
110
- function solveRowHeights(cells, rowCount) {
110
+ function longestPathBoundaries(constraints, count) {
111
+ const inner = constraints.filter((c) => c.a >= 0 && c.b <= count && c.a < c.b && !(c.a === 0 && c.b === count));
112
+ const x = new Array(count + 1).fill(Number.NEGATIVE_INFINITY);
113
+ x[0] = 0;
114
+ for (let k = 1; k <= count; k++) {
115
+ for (const c of inner) if (c.b === k && x[c.a] > Number.NEGATIVE_INFINITY) x[k] = Math.max(x[k], x[c.a] + c.size);
116
+ if (x[k] === Number.NEGATIVE_INFINITY) return null;
117
+ x[k] = Math.max(x[k], x[k - 1]);
118
+ }
119
+ const y = new Array(count + 1).fill(Number.NEGATIVE_INFINITY);
120
+ y[count] = 0;
121
+ for (let k = count - 1; k >= 0; k--) {
122
+ y[k] = y[k + 1];
123
+ for (const c of inner) if (c.a === k && y[c.b] > Number.NEGATIVE_INFINITY) y[k] = Math.max(y[k], c.size + y[c.b]);
124
+ }
125
+ return { x, tight: x.map((v, k) => Math.abs(v + y[k] - x[count]) <= 2) };
126
+ }
127
+ function tableColumnBoundaries(constraints, count, total) {
128
+ const prop = solveBoundaries(constraints, count, total);
129
+ if (!total || total <= 0) return prop;
130
+ const lp = longestPathBoundaries(constraints, count);
131
+ return lp && Math.abs(lp.x[count] - total) <= 2 && lp.x.every((v, k) => Math.abs(v - prop[k]) <= 2 || lp.tight[k]) ? lp.x : prop;
132
+ }
133
+ function solveRowHeights(cells, rowCount, maxTotal = Number.POSITIVE_INFINITY) {
111
134
  const h = new Array(rowCount).fill(0);
112
135
  for (const c of cells) {
113
136
  if (c.rowSpan === 1 && c.rowAddr >= 0 && c.rowAddr < rowCount) {
@@ -145,6 +168,15 @@ function solveRowHeights(cells, rowCount) {
145
168
  for (let k = 0; k < spans.length; k++) if (!done.has(k) && solve(k, true)) again = true;
146
169
  }
147
170
  for (let k = 0; k < spans.length; k++) if (!done.has(k)) solve(k, false);
171
+ let total = h.reduce((s, x) => s + x, 0);
172
+ for (const { c, rows } of [...spans].sort((a, b) => a.rows[a.rows.length - 1] - b.rows[b.rows.length - 1] || b.rows[0] - a.rows[0])) {
173
+ const known = rows.reduce((s, r) => s + h[r], 0);
174
+ const add = Math.min(c.height - known, maxTotal - total);
175
+ if (rows.length && add > 0) {
176
+ h[rows[rows.length - 1]] += add;
177
+ total += add;
178
+ }
179
+ }
148
180
  return h;
149
181
  }
150
182
 
@@ -11373,17 +11405,18 @@ function cellContentExtent(cell, memo) {
11373
11405
  if (hit !== void 0) return hit;
11374
11406
  const cols = cellColumns(cell.sub);
11375
11407
  let ext = 0;
11376
- let shift = 0, prevV = Number.NEGATIVE_INFINITY, prevEnd = 0;
11408
+ let shift = 0, prevV = Number.NEGATIVE_INFINITY, prevH = 0, prevEnd = 0;
11377
11409
  for (const p of elements(cell.sub)) {
11378
11410
  if (ln(p) !== "p") continue;
11379
11411
  const m = buildPara(p);
11380
11412
  let firstShift = shift;
11381
11413
  const lineTops = [];
11382
11414
  m.segs.forEach((s, k) => {
11383
- if (s.vertpos < prevV && !cols) shift = prevEnd - s.vertpos;
11415
+ if ((s.vertpos < prevV || s.vertpos === prevV && s.horzpos <= prevH && prevEnd - shift > s.vertpos) && !cols) shift = prevEnd - s.vertpos;
11384
11416
  if (k === 0) firstShift = shift;
11385
11417
  lineTops.push(s.vertpos + shift);
11386
11418
  prevV = s.vertpos;
11419
+ prevH = s.horzpos;
11387
11420
  prevEnd = s.vertpos + shift + s.textheight + (s.spacing ?? 0);
11388
11421
  ext = Math.max(ext, s.vertpos + s.textheight + shift);
11389
11422
  });
@@ -11452,8 +11485,11 @@ function measureTableRowHeights(tbl, memo) {
11452
11485
  const nRows = Math.max(...cells.map((c) => c.ra + c.rs));
11453
11486
  const sp = num(tbl, "cellSpacing");
11454
11487
  const rows = solveRowHeights(
11455
- cells.map((c) => ({ rowAddr: c.ra, rowSpan: c.rs, height: c.h - sp * (c.rs - 1), contentH: c.rs === 1 ? cellContentExtent(c, memo) + c.marginT + c.marginB : void 0 })),
11456
- nRows
11488
+ // 여러 행 칸은 내용(+ 칸 여백)이 저장 높이보다 크면 내용 높이로 — 솔버가 모자란 만큼 그 칸 마지막 행을 키운다
11489
+ // (같은 판 PDF: 두 줄 든 2행 병합 칸 내용 2882 > 저장 2564 → 둘째 행이 318 자라고 첫 행은 그대로)
11490
+ cells.map((c) => ({ rowAddr: c.ra, rowSpan: c.rs, height: (c.rs > 1 ? Math.max(c.h, cellContentExtent(c, memo) + c.marginT + c.marginB) : c.h) - sp * (c.rs - 1), contentH: c.rs === 1 ? cellContentExtent(c, memo) + c.marginT + c.marginB : void 0 })),
11491
+ nRows,
11492
+ num(findChildByLocalName(tbl, "sz"), "height") - (sp > 0 ? sp * (nRows + 1) : 0) || Number.POSITIVE_INFINITY
11457
11493
  );
11458
11494
  if (sp > 0) {
11459
11495
  for (let r = 0; r < rows.length; r++) rows[r] += sp;
@@ -11738,10 +11774,10 @@ function subFloatBottoms(sub) {
11738
11774
  const rowInfo = split ? { rows: measureTableRowHeights(o), outT: num(om, "top"), outB: num(om, "bottom"), el: o } : {};
11739
11775
  if (spacesHost(p)) {
11740
11776
  const top0 = v0 - voS - carry;
11741
- out.push({ v0: top0, bottom: v0, carry, hostEnd: top0, lineBottom: top0 + num(seg, "vertsize"), ...rowInfo });
11777
+ out.push({ v0: top0, bottom: v0, carry, hostEnd: top0, lineBottom: top0 + num(seg, "vertsize"), ...rowInfo, seg });
11742
11778
  continue;
11743
11779
  }
11744
- out.push({ v0, bottom: v0 + voS + carry, carry, hostEnd, lineBottom: v0 + num(seg, "vertsize"), ...rowInfo });
11780
+ out.push({ v0, bottom: v0 + voS + carry, carry, hostEnd, lineBottom: v0 + num(seg, "vertsize"), ...rowInfo, seg });
11745
11781
  }
11746
11782
  }
11747
11783
  }
@@ -13189,17 +13225,19 @@ function stackedFloats(c) {
13189
13225
  }
13190
13226
  function cellLineBoxes(c) {
13191
13227
  const out = [];
13192
- let shift = 0, prevV = Number.NEGATIVE_INFINITY, prevEnd = 0, part = 0;
13228
+ let shift = 0, prevV = Number.NEGATIVE_INFINITY, prevH = 0, prevSavedEnd = 0, prevEnd = 0, part = 0;
13193
13229
  const cols = cellColumns(c.sub);
13194
13230
  for (const p of c.sub ? elements(c.sub) : []) if (ln(p) === "p") {
13195
13231
  const lsa = findChildByLocalName(p, "linesegarray");
13196
13232
  for (const sg of lsa ? elements(lsa) : []) if (ln(sg) === "lineseg") {
13197
- const v = num(sg, "vertpos");
13198
- if (v < prevV && !cols) {
13233
+ const v = num(sg, "vertpos"), hz = num(sg, "horzpos");
13234
+ if ((v < prevV || v === prevV && hz <= prevH && prevSavedEnd > v) && !cols) {
13199
13235
  shift = prevEnd - v;
13200
13236
  part++;
13201
13237
  }
13202
13238
  prevV = v;
13239
+ prevH = hz;
13240
+ prevSavedEnd = v + num(sg, "vertsize") + num(sg, "spacing");
13203
13241
  const top = v + shift, bottom = top + num(sg, "vertsize");
13204
13242
  prevEnd = bottom + num(sg, "spacing");
13205
13243
  out.push({ seg: sg, top, bottom, part, origin: shift });
@@ -13210,7 +13248,7 @@ function cellLineBoxes(c) {
13210
13248
  function cellLines(c) {
13211
13249
  return cellLineBoxes(c).map((b) => [b.top, b.bottom]);
13212
13250
  }
13213
- function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, nested = false) {
13251
+ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, nested = false, contMT = MT) {
13214
13252
  if (nested) slack = 0;
13215
13253
  const nRows = rowH.length;
13216
13254
  const rowY = [0];
@@ -13231,11 +13269,12 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
13231
13269
  }
13232
13270
  let hdrRows = 0;
13233
13271
  if (tbl.getAttribute("repeatHeader") === "1") while (hdrRows < nRows && cells.some((c) => c.ra === hdrRows) && cells.filter((c) => c.ra === hdrRows).every((c) => c.el.getAttribute("header") === "1")) hdrRows++;
13234
- const contTop = MT + num(findChildByLocalName(tbl, "outMargin"), "top") + rowY[hdrRows];
13272
+ const contTop = contMT + num(findChildByLocalName(tbl, "outMargin"), "top") + rowY[hdrRows];
13235
13273
  const outB = num(findChildByLocalName(tbl, "outMargin"), "bottom");
13236
13274
  const cellSplit = tbl.getAttribute("pageBreak") === "CELL";
13237
13275
  const out = [];
13238
- let page = 0, y = ty, first = true;
13276
+ const flows = (findChildByLocalName(tbl, "pos")?.getAttribute("vertRelTo") ?? "PARA") === "PARA";
13277
+ let page = 0, y = ty, first = !flows || ty - MT < 2e3;
13239
13278
  for (let r = 0; r < nRows; r++) {
13240
13279
  let h = rowH[r];
13241
13280
  const pieces = [];
@@ -13274,13 +13313,14 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
13274
13313
  if (boxes && hParts > 0) {
13275
13314
  const declared = num(findChildByLocalName(tbl, "sz"), "height");
13276
13315
  const led = /* @__PURE__ */ new Set();
13316
+ let firstPh = 0;
13277
13317
  for (let k = 0; k <= hParts; k++) {
13278
13318
  if (k > 0 && floatSpan) {
13279
13319
  let lead = 0, place;
13280
13320
  for (const c of rowCells) {
13281
13321
  const b = (boxes.get(c.el) ?? []).find((x) => x.part === k);
13282
13322
  if (!b) continue;
13283
- const f = floatSpan(b.seg, y + c.marginT);
13323
+ const f = floatSpan(b.seg, y + c.marginT, contTop + c.marginT);
13284
13324
  if (f?.el && f.pages > 0 && f.pages > lead && Math.abs(contTop + c.marginT + b.top - b.origin - f.endY) < 3e3) {
13285
13325
  lead = f.pages;
13286
13326
  place = /* @__PURE__ */ new Map([[f.el, y + c.marginT]]);
@@ -13301,11 +13341,18 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
13301
13341
  const from = inK[0]?.origin ?? next?.origin ?? Number.POSITIVE_INFINITY;
13302
13342
  range.set(c.el, [from, next?.top ?? Number.POSITIVE_INFINITY]);
13303
13343
  if (inK.length) ext = Math.max(ext, inK[inK.length - 1].bottom - from + c.marginT + c.marginB);
13344
+ if (k === hParts && inK.length && c.sub) for (const f of subFloatBottoms(c.sub)) {
13345
+ const b = bs.find((x) => x.seg === f.seg);
13346
+ if (b && b.part === k) ext = Math.max(ext, b.top + f.bottom - f.v0 - from + c.marginT + c.marginB);
13347
+ }
13304
13348
  if (inK.length && next) toNext = Math.max(toNext, next.top - from + c.marginT + c.marginB);
13305
13349
  }
13306
13350
  const last = k === hParts;
13307
- const firstH = declared > 0 && ty + declared - y >= ext ? Math.min(pageBottom - y, ty + declared - y) : pageBottom - y;
13308
- const ph = last ? ext : k === 0 ? firstH : toNext > 0 ? Math.min(pageBottom - contTop, toNext) : pageBottom - contTop;
13351
+ const cellH = Math.max(0, ...rowCells.map((c) => num(findChildByLocalName(c.el, "cellSz"), "height")));
13352
+ const firstH = Math.min(declared > 0 && ty + declared - y >= ext ? Math.min(pageBottom - y, ty + declared - y) : pageBottom - y, Math.max(ext, cellH));
13353
+ const share = last && k === 1 ? Math.max(0, ...rowCells.filter((c) => tbl.getAttribute("noAdjust") === "1" || /^(CENTER|BOTTOM)$/.test(c.sub?.getAttribute("vertAlign") ?? "")).map((c) => c.h - firstPh).filter((v) => v <= pageBottom - contTop)) : 0;
13354
+ const ph = last ? Math.max(ext, share) : k === 0 ? firstH : toNext > 0 ? Math.min(pageBottom - contTop, toNext) : pageBottom - contTop;
13355
+ if (k === 0) firstPh = ph;
13309
13356
  pieces.push({ page, y, h: ph, range });
13310
13357
  if (!last) {
13311
13358
  let span = 0, spanEnd = 0;
@@ -13313,7 +13360,7 @@ function planTableRows(tbl, cells, rowH, ty, MT, BODY_H, slack = 0, floatSpan, n
13313
13360
  const bs = (boxes.get(c.el) ?? []).filter((b) => b.part === k), from = bs[0]?.origin ?? 0;
13314
13361
  for (const b of bs) {
13315
13362
  if (led.has(b.seg)) continue;
13316
- const f = floatSpan(b.seg, y + c.marginT + b.top - from);
13363
+ const f = floatSpan(b.seg, y + c.marginT + b.top - from, contTop + c.marginT);
13317
13364
  if (f && f.pages > span) {
13318
13365
  span = f.pages;
13319
13366
  spanEnd = f.endY;
@@ -13559,6 +13606,54 @@ function shapeGeometry(o, boxX, boxY, defs, images, warn, local = false) {
13559
13606
  return { ...geometry, svg };
13560
13607
  }
13561
13608
 
13609
+ // src/render/object-anchor.ts
13610
+ function linePushedBy(o, lineV, paraTop) {
13611
+ if (paraTop === void 0) return false;
13612
+ const om = findChildByLocalName(o.el, "outMargin");
13613
+ return Math.abs(lineV - (num(om, "top") + o.height + num(om, "bottom")) - paraTop) <= 10;
13614
+ }
13615
+ function anchorObject(o, ox, oy, baseV, areaW, ctx, anchorLineV, stayLine = false, paraStartV, laterLineH) {
13616
+ const { PW, PH, ML, MT, BODY_W, BODY_H } = ctx.geom;
13617
+ const pos = findChildByLocalName(o.el, "pos");
13618
+ const om = findChildByLocalName(o.el, "outMargin");
13619
+ const omT = num(om, "top"), omB = num(om, "bottom");
13620
+ const w = o.width, h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el, ctx.extentMemo)) : o.height;
13621
+ if (!pos) return { x: ox, y: oy + baseV };
13622
+ const voRaw = num(pos, "vertOffset"), voS = voRaw >= 2 ** 31 ? voRaw - 2 ** 32 : voRaw;
13623
+ const vo = (pos.getAttribute("vertRelTo") ?? "PARA") === "PARA" ? Math.max(0, voS) : voS;
13624
+ const ho = num(pos, "horzOffset");
13625
+ const vrel = pos.getAttribute("vertRelTo") ?? "PARA";
13626
+ const hrel = pos.getAttribute("horzRelTo") ?? "PARA";
13627
+ const va = pos.getAttribute("vertAlign") ?? "TOP";
13628
+ const ha = pos.getAttribute("horzAlign") ?? "LEFT";
13629
+ const wrap = o.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM";
13630
+ let y;
13631
+ if (vrel === "PAPER") {
13632
+ y = va === "BOTTOM" ? PH - h - vo - omB : va === "CENTER" ? (PH - h) / 2 + vo : vo + omT;
13633
+ } else if (vrel === "PAGE") {
13634
+ y = va === "BOTTOM" ? MT + BODY_H - h - vo : va === "CENTER" ? MT + (BODY_H - h) / 2 + vo : MT + vo;
13635
+ } else if (wrap === "TOP_AND_BOTTOM") {
13636
+ const lineV = anchorLineV ?? baseV;
13637
+ const pushed = lineV - (omT + h + omB);
13638
+ const below = laterLineH !== void 0 && vo + omT >= laterLineH;
13639
+ const anchor = below ? lineV : stayLine !== false ? lineV - stayLine : pushed >= -100 ? pushed : paraStartV !== void 0 ? paraStartV : lineV;
13640
+ y = oy + anchor + omT + vo;
13641
+ } else {
13642
+ const origin = vrel === "PARA" && wrap === "SQUARE" ? paraStartV ?? baseV : baseV;
13643
+ y = oy + Math.max(origin + vo, wrap === "SQUARE" && anchorLineV !== void 0 ? anchorLineV : -Infinity) + omT;
13644
+ }
13645
+ let x;
13646
+ const omL = num(om, "left"), omR = num(om, "right");
13647
+ if (hrel === "PAGE") {
13648
+ x = ha === "RIGHT" ? ML + BODY_W - w - ho - omR : ha === "CENTER" ? ML + (BODY_W - w) / 2 + ho : ML + ho + omL;
13649
+ } else if (hrel === "PAPER") {
13650
+ x = (ha === "RIGHT" ? PW - w - ho - omR : ha === "CENTER" ? (PW - w) / 2 + ho : ho + omL) - (ctx.bodyDx?.(ctx.page) ?? 0);
13651
+ } else {
13652
+ x = ha === "RIGHT" ? ox + areaW - w - ho - omR : ha === "CENTER" ? ox + (areaW - w) / 2 + ho : ox + ho + omL;
13653
+ }
13654
+ return { x, y };
13655
+ }
13656
+
13562
13657
  // src/render/equation-text.ts
13563
13658
  var SYMBOLS = {
13564
13659
  alpha: "\u03B1",
@@ -14295,49 +14390,6 @@ function hwpEquationToLatex(equation) {
14295
14390
  return hmlToLatex(s).replace(/\s+/g, " ").trim();
14296
14391
  }
14297
14392
 
14298
- // src/render/object-anchor.ts
14299
- function anchorObject(o, ox, oy, baseV, areaW, ctx, anchorLineV, stayLine = false, paraStartV, laterLineH) {
14300
- const { PW, PH, ML, MT, BODY_W, BODY_H } = ctx.geom;
14301
- const pos = findChildByLocalName(o.el, "pos");
14302
- const om = findChildByLocalName(o.el, "outMargin");
14303
- const omT = num(om, "top"), omB = num(om, "bottom");
14304
- const w = o.width, h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el, ctx.extentMemo)) : o.height;
14305
- if (!pos) return { x: ox, y: oy + baseV };
14306
- const voRaw = num(pos, "vertOffset"), voS = voRaw >= 2 ** 31 ? voRaw - 2 ** 32 : voRaw;
14307
- const vo = (pos.getAttribute("vertRelTo") ?? "PARA") === "PARA" ? Math.max(0, voS) : voS;
14308
- const ho = num(pos, "horzOffset");
14309
- const vrel = pos.getAttribute("vertRelTo") ?? "PARA";
14310
- const hrel = pos.getAttribute("horzRelTo") ?? "PARA";
14311
- const va = pos.getAttribute("vertAlign") ?? "TOP";
14312
- const ha = pos.getAttribute("horzAlign") ?? "LEFT";
14313
- const wrap = o.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM";
14314
- let y;
14315
- if (vrel === "PAPER") {
14316
- y = va === "BOTTOM" ? PH - h - vo - omB : va === "CENTER" ? (PH - h) / 2 + vo : vo + omT;
14317
- } else if (vrel === "PAGE") {
14318
- y = va === "BOTTOM" ? MT + BODY_H - h - vo : va === "CENTER" ? MT + (BODY_H - h) / 2 + vo : MT + vo;
14319
- } else if (wrap === "TOP_AND_BOTTOM") {
14320
- const lineV = anchorLineV ?? baseV;
14321
- const pushed = lineV - (omT + h + omB);
14322
- const below = laterLineH !== void 0 && vo + omT >= laterLineH;
14323
- const anchor = below ? lineV : stayLine !== false ? lineV - stayLine : pushed >= -100 ? pushed : paraStartV !== void 0 ? paraStartV : lineV;
14324
- y = oy + anchor + omT + vo;
14325
- } else {
14326
- const origin = vrel === "PARA" && wrap === "SQUARE" ? paraStartV ?? baseV : baseV;
14327
- y = oy + Math.max(origin + vo, wrap === "SQUARE" && anchorLineV !== void 0 ? anchorLineV : -Infinity) + omT;
14328
- }
14329
- let x;
14330
- const omL = num(om, "left"), omR = num(om, "right");
14331
- if (hrel === "PAGE") {
14332
- x = ha === "RIGHT" ? ML + BODY_W - w - ho - omR : ha === "CENTER" ? ML + (BODY_W - w) / 2 + ho : ML + ho + omL;
14333
- } else if (hrel === "PAPER") {
14334
- x = (ha === "RIGHT" ? PW - w - ho - omR : ha === "CENTER" ? (PW - w) / 2 + ho : ho + omL) - (ctx.bodyDx?.(ctx.page) ?? 0);
14335
- } else {
14336
- x = ha === "RIGHT" ? ox + areaW - w - ho - omR : ha === "CENTER" ? ox + (areaW - w) / 2 + ho : ox + ho + omL;
14337
- }
14338
- return { x, y };
14339
- }
14340
-
14341
14393
  // src/render/svg-content.ts
14342
14394
  function escapeXml(s) {
14343
14395
  return s.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
@@ -14665,8 +14717,9 @@ function drawPara(p, ox, oy, areaW, ctx, depth, segPages) {
14665
14717
  }
14666
14718
  }
14667
14719
  const tbFloats = m.objs.filter((q) => !q.inline && (q.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM") === "TOP_AND_BOTTOM" && (findChildByLocalName(q.el, "pos")?.getAttribute("vertRelTo") ?? "PARA") === "PARA").length;
14668
- const stay = tbFloats < 2 && !m.objs.some((q) => q.inline) && !m.chars.some((c) => c.ch !== "" && !c.nb && c.ch.trim() !== "");
14720
+ let stay = tbFloats < 2 && !m.objs.some((q) => q.inline) && !m.chars.some((c) => c.ch !== "" && !c.nb && c.ch.trim() !== "");
14669
14721
  const sbA = m.paraPrId != null ? ctx.styles.paraGeom.get(m.paraPrId)?.spaceBefore ?? 0 : 0;
14722
+ if (stay && wrapA === "TOP_AND_BOTTOM" && linePushedBy(o, anchorLineV ?? baseV, pTop)) stay = false;
14670
14723
  const firstLine = anchorLineV === void 0 || anchorLineV === baseV;
14671
14724
  let { x, y } = anchorObject(o, ax, oy, objBaseV, aw, ctx, anchorLineV, stay ? sbA : false, (firstLine || wrapA === "SQUARE") && pTop !== void 0 && pTop < baseV ? pTop : void 0, firstLine ? void 0 : anchorLineH);
14672
14725
  if (depth === 0 && tbFloats >= 2 && wrapA === "TOP_AND_BOTTOM") {
@@ -14842,13 +14895,13 @@ function edgeLine(x1, y1, x2, y2, e) {
14842
14895
  const dash = /DASH|DOT/.test(e.type) ? ` stroke-dasharray="${e.type.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
14843
14896
  return `<line x1="${pt2(x1)}" y1="${pt2(y1)}" x2="${pt2(x2)}" y2="${pt2(y2)}" stroke="${escapeXml(e.color)}" stroke-width="${e.widthPt.toFixed(2)}"${dash}/>`;
14844
14897
  }
14845
- function tableContPages(tbl, ty, MT, BODY_H, memo, slack = 0, floatSpan, nested = false) {
14846
- const pcs = planTableRows(tbl, collectCells(tbl), measureTableRowHeights(tbl, memo), ty, MT, BODY_H, slack, floatSpan, nested).flat();
14898
+ function tableContPages(tbl, ty, MT, BODY_H, memo, slack = 0, floatSpan, nested = false, contMT = MT) {
14899
+ const pcs = planTableRows(tbl, collectCells(tbl), measureTableRowHeights(tbl, memo), ty, MT, BODY_H, slack, floatSpan, nested, contMT).flat();
14847
14900
  const last = pcs.reduce((a, b) => b.page > a.page || b.page === a.page && b.y + b.h > a.y + a.h ? b : a, pcs[0] ?? { page: 0, y: ty, h: 0 });
14848
14901
  return { pages: last.page, endY: last.y + last.h };
14849
14902
  }
14850
14903
  function cellFloatSpan(MT, BODY_H, memo, slack) {
14851
- return (seg, top) => {
14904
+ return (seg, top, contMT) => {
14852
14905
  const lsa = seg.parentNode, p = lsa?.parentNode;
14853
14906
  if (!p || ln(p) !== "p") return void 0;
14854
14907
  const segs = elements(lsa).filter((e) => ln(e) === "lineseg"), k = segs.indexOf(seg);
@@ -14861,7 +14914,7 @@ function cellFloatSpan(MT, BODY_H, memo, slack) {
14861
14914
  const segK = Math.max(0, m.segs.findIndex((sg, i) => sg.textpos <= o.index && (i === m.segs.length - 1 || m.segs[i + 1].textpos > o.index)));
14862
14915
  if (segK !== k) continue;
14863
14916
  const ty = top + num(findChildByLocalName(o.el, "outMargin"), "top") + Math.max(0, toInt32(pos?.getAttribute("vertOffset") ?? void 0, 0));
14864
- const span = tableContPages(o.el, ty, MT, BODY_H, memo, slack, cellFloatSpan(MT, BODY_H, memo, slack), true);
14917
+ const span = tableContPages(o.el, ty, MT, BODY_H, memo, slack, cellFloatSpan(MT, BODY_H, memo, slack), true, contMT);
14865
14918
  if (span.pages > 0 && (!best || span.pages > best.pages)) best = { ...span, el: o.el };
14866
14919
  }
14867
14920
  return best;
@@ -14879,7 +14932,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
14879
14932
  const nCols = Math.max(...cells.map((c) => c.ca + c.cs));
14880
14933
  const nRows = Math.max(...cells.map((c) => c.ra + c.rs));
14881
14934
  const colCons = cells.map((c) => ({ a: c.ca, b: c.ca + c.cs, size: c.w }));
14882
- const colX = solveBoundaries(colCons, nCols, num(tblSz, "width") || void 0);
14935
+ const colX = tableColumnBoundaries(colCons, nCols, num(tblSz, "width") || void 0);
14883
14936
  const rowH = measureTableRowHeights(tbl, ctx.extentMemo);
14884
14937
  const rowY = [0];
14885
14938
  for (let r = 0; r < nRows; r++) rowY.push(rowY[r] + rowH[r]);
@@ -14893,7 +14946,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
14893
14946
  if (tbl.getAttribute("repeatHeader") === "1") while (hdrRows < nRows && cells.some((c) => c.ra === hdrRows) && cells.filter((c) => c.ra === hdrRows).every((c) => c.el.getAttribute("header") === "1")) hdrRows++;
14894
14947
  const slack = ctx.geom.PH - ctx.geom.MT - ctx.geom.BODY_H;
14895
14948
  const splitHere = depth === 1 || !!ctx.splitCell && findChildByLocalName(tbl, "pos")?.getAttribute("treatAsChar") !== "1";
14896
- const plan = splitHere ? planTableRows(tbl, cells, rowH, ty, ctx.geom.MT, ctx.geom.BODY_H, slack, cellFloatSpan(ctx.geom.MT, ctx.geom.BODY_H, ctx.extentMemo, slack), depth !== 1) : rowH.map((h, r) => [{ page: 0, y: ty + rowY[r], h }]);
14949
+ const plan = splitHere ? planTableRows(tbl, cells, rowH, ty, ctx.geom.MT, ctx.geom.BODY_H, slack, cellFloatSpan(ctx.geom.MT, ctx.geom.BODY_H, ctx.extentMemo, slack), depth !== 1, depth !== 1 && ctx.splitContMT !== void 0 ? ctx.splitContMT : ctx.geom.MT) : rowH.map((h, r) => [{ page: 0, y: ty + rowY[r], h }]);
14897
14950
  const splitSaved = ctx.splitCell;
14898
14951
  ctx.splitCell = false;
14899
14952
  for (const pc of plan.flat()) for (const [el, py] of pc.place ?? []) (ctx.objPlace ??= /* @__PURE__ */ new Map()).set(el, { page: startPage + pc.page, y: py });
@@ -14929,10 +14982,15 @@ function drawTable(tbl, tx, ty, ctx, depth) {
14929
14982
  return !!r && v >= r[0] && v < r[1];
14930
14983
  }));
14931
14984
  const va2 = c.sub.getAttribute("vertAlign") ?? "TOP";
14985
+ const lastK = g.pieces.length - 1;
14932
14986
  const pieceOff = g.pieces.map((pc, k) => {
14933
- if (va2 === "TOP" || k > 0) return 0;
14987
+ if (va2 === "TOP" || k > 0 && k < lastK) return 0;
14934
14988
  const from = pc.range?.get(c.el)?.[0] ?? 0;
14935
14989
  const bottoms = boxes.filter((b) => pieceOf(b.top) === k).map((b) => b.bottom - from);
14990
+ if (k > 0) for (const f of subFloatBottoms(c.sub)) {
14991
+ const b = boxes.find((x) => x.seg === f.seg);
14992
+ if (b && pieceOf(b.top) === k) bottoms.push(b.top + f.bottom - f.v0 - from);
14993
+ }
14936
14994
  if (!bottoms.length) return 0;
14937
14995
  const free = pc.h - c.marginT - c.marginB - Math.max(...bottoms);
14938
14996
  return Math.max(0, va2 === "CENTER" ? free / 2 : free);
@@ -14949,7 +15007,10 @@ function drawTable(tbl, tx, ty, ctx, depth) {
14949
15007
  return startPage + pc.page;
14950
15008
  });
14951
15009
  ctx.splitCell = splitHere;
15010
+ const contMTSaved = ctx.splitContMT;
15011
+ ctx.splitContMT = ctx.geom.MT + num(findChildByLocalName(tbl, "outMargin"), "top") + rowY[hdrRows] + c.marginT;
14952
15012
  drawPara(p, g.x + c.marginL, base, g.w - c.marginL - c.marginR, ctx, depth + 1, pages);
15013
+ ctx.splitContMT = contMTSaved;
14953
15014
  ctx.splitCell = false;
14954
15015
  segs.forEach((sg, i) => sg.setAttribute("vertpos", saved[i] ?? "0"));
14955
15016
  }
@@ -15224,9 +15285,9 @@ function renderSectionToPages(root, geom, ctxBase, doReflow, reflowMode, masters
15224
15285
  const h = Math.max(o.height, measureTableHeight(o.el, ctxBase.extentMemo)), omT = num(om, "top"), omB = num(om, "bottom");
15225
15286
  const pushed = segV - (omT + h + omB);
15226
15287
  const nTb = m0.objs.filter((q) => !q.inline && (q.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM") === "TOP_AND_BOTTOM").length;
15227
- const stay = nTb < 2 && !m0.objs.some((q) => q.inline) && !m0.chars.some((c) => c.ch !== "" && !c.nb && c.ch.trim() !== "");
15228
15288
  const wrapP = o.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM";
15229
15289
  const pTop = paraTops.get(p), sbP = m0.paraPrId != null ? geom0.get(m0.paraPrId)?.spaceBefore ?? 0 : 0;
15290
+ const stay = nTb < 2 && !m0.objs.some((q) => q.inline) && !m0.chars.some((c) => c.ch !== "" && !c.nb && c.ch.trim() !== "") && !(!o.inline && wrapP === "TOP_AND_BOTTOM" && linePushedBy(o, segV, pTop));
15230
15291
  const nonPush = wrapP !== "TOP_AND_BOTTOM" && pTop !== void 0 && segV > pTop + sbP + 100 ? pTop + sbP : void 0;
15231
15292
  const voP = Math.max(0, toInt32(pos?.getAttribute("vertOffset") ?? void 0, 0));
15232
15293
  const paraStart = segK === 0 && pTop !== void 0 && pTop < segV ? pTop : segV;
@@ -19758,4 +19819,4 @@ export {
19758
19819
  cropRect,
19759
19820
  extractRenderedRegions
19760
19821
  };
19761
- //# sourceMappingURL=chunk-NT54LN6C.js.map
19822
+ //# sourceMappingURL=chunk-K6EG6ACM.js.map