kordoc 4.22.3 → 4.22.5

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 (128) hide show
  1. package/README.md +9 -7
  2. package/dist/{-AOWV7MNY.js → -WFRWBH7T.js} +11 -11
  3. package/dist/{chunk-3ANXRVI2.js → chunk-2L3Q7REU.js} +3 -3
  4. package/dist/{chunk-FDFXL7VJ.js → chunk-35ZHXEJA.js} +3 -3
  5. package/dist/{chunk-BS2XWGT5.js → chunk-3BR7VKWL.js} +2 -2
  6. package/dist/{chunk-KBGNPGVY.js → chunk-3G3TLZDK.js} +2 -2
  7. package/dist/{chunk-M2X766AY.js → chunk-3YEL7P4L.js} +2 -2
  8. package/dist/{chunk-NJEMRAIF.cjs → chunk-4SUB43EJ.cjs} +24 -24
  9. package/dist/{chunk-NJEMRAIF.cjs.map → chunk-4SUB43EJ.cjs.map} +1 -1
  10. package/dist/{chunk-DKJ2RNDG.js → chunk-4TWN7PWJ.js} +2 -2
  11. package/dist/{chunk-UCLDUUBX.js → chunk-52HIK4C2.js} +4 -3
  12. package/dist/chunk-52HIK4C2.js.map +1 -0
  13. package/dist/{chunk-3H2IEU4V.js → chunk-63N6CEJE.js} +2 -2
  14. package/dist/{chunk-MEIQ476H.js → chunk-6MCC2XNB.js} +2 -2
  15. package/dist/{chunk-SKRWKVVW.js → chunk-6MQKNB6K.js} +15 -8
  16. package/dist/chunk-6MQKNB6K.js.map +1 -0
  17. package/dist/{chunk-MI655NV5.cjs → chunk-AS25R4EU.cjs} +2 -2
  18. package/dist/{chunk-MI655NV5.cjs.map → chunk-AS25R4EU.cjs.map} +1 -1
  19. package/dist/{chunk-4NQ4EZEE.js → chunk-C3REGEQO.js} +2 -2
  20. package/dist/{chunk-NLGOMLGU.cjs → chunk-C6B5GWN7.cjs} +35 -28
  21. package/dist/chunk-C6B5GWN7.cjs.map +1 -0
  22. package/dist/{chunk-6LIBF2ZB.js → chunk-CO7O3ZT6.js} +2 -2
  23. package/dist/{chunk-IRNWAHHZ.js → chunk-CRSTBATY.js} +2 -2
  24. package/dist/{chunk-VJCQOSMT.js → chunk-CW67DAAH.js} +2 -2
  25. package/dist/{chunk-6QBBGZST.js → chunk-DN55FTJP.js} +2 -2
  26. package/dist/{chunk-OIF5HRVP.js → chunk-HLPMC7L4.js} +16 -9
  27. package/dist/chunk-HLPMC7L4.js.map +1 -0
  28. package/dist/{chunk-24YLYR6Q.js → chunk-LE4VHWIT.js} +4 -4
  29. package/dist/{chunk-2BCQVQO2.cjs → chunk-N6KXGIIN.cjs} +3 -3
  30. package/dist/{chunk-2BCQVQO2.cjs.map → chunk-N6KXGIIN.cjs.map} +1 -1
  31. package/dist/{chunk-7XITVUAK.js → chunk-PSORL4PA.js} +11 -11
  32. package/dist/{chunk-AXX5AQT4.js → chunk-RYKDIUHT.js} +4 -4
  33. package/dist/{chunk-O5E25RHU.js → chunk-SETAYS6P.js} +2 -2
  34. package/dist/{chunk-X45Q7EAC.js → chunk-T7OZ7X6A.js} +2 -2
  35. package/dist/{chunk-J5PYESLX.js → chunk-TOUJCO2P.js} +2 -2
  36. package/dist/{chunk-YOGMCRM7.js → chunk-U3GUZQ54.js} +1353 -1335
  37. package/dist/chunk-U3GUZQ54.js.map +1 -0
  38. package/dist/{chunk-O3OS6FAW.cjs → chunk-UCK6WGHY.cjs} +3 -3
  39. package/dist/{chunk-O3OS6FAW.cjs.map → chunk-UCK6WGHY.cjs.map} +1 -1
  40. package/dist/{chunk-SJ5OZXEL.cjs → chunk-YG4GFQB7.cjs} +6 -6
  41. package/dist/{chunk-SJ5OZXEL.cjs.map → chunk-YG4GFQB7.cjs.map} +1 -1
  42. package/dist/chunks-NXABWR6G.js +10 -0
  43. package/dist/cli.js +30 -30
  44. package/dist/{formula-W4OL33YQ.js → formula-FSVHUQ6Y.js} +4 -4
  45. package/dist/{formula-C26FMMGO.js → formula-L625ULJP.js} +3 -3
  46. package/dist/{formula-5V2WG4BH.cjs → formula-QZGTF3DZ.cjs} +9 -9
  47. package/dist/{formula-5V2WG4BH.cjs.map → formula-QZGTF3DZ.cjs.map} +1 -1
  48. package/dist/{image-ocr-BELHEWPX.cjs → image-ocr-AELVAU75.cjs} +17 -17
  49. package/dist/{image-ocr-BELHEWPX.cjs.map → image-ocr-AELVAU75.cjs.map} +1 -1
  50. package/dist/{image-ocr-T72HMX2W.js → image-ocr-KE3RUS3R.js} +6 -6
  51. package/dist/{image-ocr-NSQ34Y6T.js → image-ocr-QTZNBP5V.js} +9 -9
  52. package/dist/index.cjs +859 -840
  53. package/dist/index.cjs.map +1 -1
  54. package/dist/index.js +322 -303
  55. package/dist/index.js.map +1 -1
  56. package/dist/mcp.js +22 -22
  57. package/dist/{model-bundle-34T2LJB4.js → model-bundle-F6TU6ZAV.js} +5 -5
  58. package/dist/{models-TQH5EM6V.js → models-ZHNNVH2W.js} +5 -5
  59. package/dist/{parse-worker-v2-YEYLILGJ.js → parse-worker-v2-KQRG3NQO.js} +12 -12
  60. package/dist/{parser-SJHCBL7T.js → parser-RVMH4PUB.js} +183 -21
  61. package/dist/parser-RVMH4PUB.js.map +1 -0
  62. package/dist/{parser-E6BG3ECD.js → parser-WBKVRDPV.js} +179 -17
  63. package/dist/parser-WBKVRDPV.js.map +1 -0
  64. package/dist/{parser-OAXCXVQ4.cjs → parser-WNDH2X6N.cjs} +442 -280
  65. package/dist/parser-WNDH2X6N.cjs.map +1 -0
  66. package/dist/pdf-ocr-IOUZTPPH.cjs +31 -0
  67. package/dist/{pdf-ocr-RKXDY3ZA.cjs.map → pdf-ocr-IOUZTPPH.cjs.map} +1 -1
  68. package/dist/{pdf-ocr-LGPSJM22.js → pdf-ocr-X5XLGL5J.js} +6 -6
  69. package/dist/{pdf-ocr-T5ASSUKK.js → pdf-ocr-ZP2CUWSO.js} +9 -9
  70. package/dist/{profile-io-KMCAFTMG.js → profile-io-B4VSI4LW.js} +3 -3
  71. package/dist/{rasterize-M52AKY7R.js → rasterize-Y7NVUVXU.js} +3 -3
  72. package/dist/{redact-doc-SWJC27LL.js → redact-doc-GIBTFWCO.js} +11 -11
  73. package/dist/{render-45AB5YZR.js → render-JVCGYRRO.js} +7 -7
  74. package/dist/seal-WNX2ZJTK.js +10 -0
  75. package/dist/{setup-5PBMUI6M.js → setup-7L7EQPMG.js} +3 -3
  76. package/dist/visual-VPWPXIHN.js +21 -0
  77. package/dist/{watch-QOGKV52T.js → watch-VYMFGX72.js} +12 -12
  78. package/package.json +1 -1
  79. package/dist/chunk-NLGOMLGU.cjs.map +0 -1
  80. package/dist/chunk-OIF5HRVP.js.map +0 -1
  81. package/dist/chunk-SKRWKVVW.js.map +0 -1
  82. package/dist/chunk-UCLDUUBX.js.map +0 -1
  83. package/dist/chunk-YOGMCRM7.js.map +0 -1
  84. package/dist/chunks-7KXTS7IV.js +0 -10
  85. package/dist/parser-E6BG3ECD.js.map +0 -1
  86. package/dist/parser-OAXCXVQ4.cjs.map +0 -1
  87. package/dist/parser-SJHCBL7T.js.map +0 -1
  88. package/dist/pdf-ocr-RKXDY3ZA.cjs +0 -31
  89. package/dist/seal-7KWG6VHS.js +0 -10
  90. package/dist/visual-OMJNXLNZ.js +0 -21
  91. /package/dist/{-AOWV7MNY.js.map → -WFRWBH7T.js.map} +0 -0
  92. /package/dist/{chunk-3ANXRVI2.js.map → chunk-2L3Q7REU.js.map} +0 -0
  93. /package/dist/{chunk-FDFXL7VJ.js.map → chunk-35ZHXEJA.js.map} +0 -0
  94. /package/dist/{chunk-BS2XWGT5.js.map → chunk-3BR7VKWL.js.map} +0 -0
  95. /package/dist/{chunk-KBGNPGVY.js.map → chunk-3G3TLZDK.js.map} +0 -0
  96. /package/dist/{chunk-M2X766AY.js.map → chunk-3YEL7P4L.js.map} +0 -0
  97. /package/dist/{chunk-DKJ2RNDG.js.map → chunk-4TWN7PWJ.js.map} +0 -0
  98. /package/dist/{chunk-3H2IEU4V.js.map → chunk-63N6CEJE.js.map} +0 -0
  99. /package/dist/{chunk-MEIQ476H.js.map → chunk-6MCC2XNB.js.map} +0 -0
  100. /package/dist/{chunk-4NQ4EZEE.js.map → chunk-C3REGEQO.js.map} +0 -0
  101. /package/dist/{chunk-6LIBF2ZB.js.map → chunk-CO7O3ZT6.js.map} +0 -0
  102. /package/dist/{chunk-IRNWAHHZ.js.map → chunk-CRSTBATY.js.map} +0 -0
  103. /package/dist/{chunk-VJCQOSMT.js.map → chunk-CW67DAAH.js.map} +0 -0
  104. /package/dist/{chunk-6QBBGZST.js.map → chunk-DN55FTJP.js.map} +0 -0
  105. /package/dist/{chunk-24YLYR6Q.js.map → chunk-LE4VHWIT.js.map} +0 -0
  106. /package/dist/{chunk-7XITVUAK.js.map → chunk-PSORL4PA.js.map} +0 -0
  107. /package/dist/{chunk-AXX5AQT4.js.map → chunk-RYKDIUHT.js.map} +0 -0
  108. /package/dist/{chunk-O5E25RHU.js.map → chunk-SETAYS6P.js.map} +0 -0
  109. /package/dist/{chunk-X45Q7EAC.js.map → chunk-T7OZ7X6A.js.map} +0 -0
  110. /package/dist/{chunk-J5PYESLX.js.map → chunk-TOUJCO2P.js.map} +0 -0
  111. /package/dist/{chunks-7KXTS7IV.js.map → chunks-NXABWR6G.js.map} +0 -0
  112. /package/dist/{formula-W4OL33YQ.js.map → formula-FSVHUQ6Y.js.map} +0 -0
  113. /package/dist/{formula-C26FMMGO.js.map → formula-L625ULJP.js.map} +0 -0
  114. /package/dist/{image-ocr-T72HMX2W.js.map → image-ocr-KE3RUS3R.js.map} +0 -0
  115. /package/dist/{image-ocr-NSQ34Y6T.js.map → image-ocr-QTZNBP5V.js.map} +0 -0
  116. /package/dist/{model-bundle-34T2LJB4.js.map → model-bundle-F6TU6ZAV.js.map} +0 -0
  117. /package/dist/{models-TQH5EM6V.js.map → models-ZHNNVH2W.js.map} +0 -0
  118. /package/dist/{parse-worker-v2-YEYLILGJ.js.map → parse-worker-v2-KQRG3NQO.js.map} +0 -0
  119. /package/dist/{pdf-ocr-LGPSJM22.js.map → pdf-ocr-X5XLGL5J.js.map} +0 -0
  120. /package/dist/{pdf-ocr-T5ASSUKK.js.map → pdf-ocr-ZP2CUWSO.js.map} +0 -0
  121. /package/dist/{profile-io-KMCAFTMG.js.map → profile-io-B4VSI4LW.js.map} +0 -0
  122. /package/dist/{rasterize-M52AKY7R.js.map → rasterize-Y7NVUVXU.js.map} +0 -0
  123. /package/dist/{redact-doc-SWJC27LL.js.map → redact-doc-GIBTFWCO.js.map} +0 -0
  124. /package/dist/{render-45AB5YZR.js.map → render-JVCGYRRO.js.map} +0 -0
  125. /package/dist/{seal-7KWG6VHS.js.map → seal-WNX2ZJTK.js.map} +0 -0
  126. /package/dist/{setup-5PBMUI6M.js.map → setup-7L7EQPMG.js.map} +0 -0
  127. /package/dist/{visual-OMJNXLNZ.js.map → visual-VPWPXIHN.js.map} +0 -0
  128. /package/dist/{watch-QOGKV52T.js.map → watch-VYMFGX72.js.map} +0 -0
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  blocksToPages,
3
3
  bmpToPng,
4
4
  inlineImagesIntoMarkdown
5
- } from "./chunk-IRNWAHHZ.js";
5
+ } from "./chunk-CRSTBATY.js";
6
6
  import {
7
7
  parsePageRange
8
8
  } from "./chunk-V4BH5SRQ.js";
@@ -37,7 +37,7 @@ import {
37
37
  validateOcrOptions,
38
38
  visibleText,
39
39
  wrapScript
40
- } from "./chunk-J5PYESLX.js";
40
+ } from "./chunk-TOUJCO2P.js";
41
41
  import {
42
42
  KordocError,
43
43
  OPTIONAL_DEP_INSTALL_HINT,
@@ -55,7 +55,7 @@ import {
55
55
  toArrayBuffer,
56
56
  unescapeHtml,
57
57
  unzipLimitBytes
58
- } from "./chunk-X45Q7EAC.js";
58
+ } from "./chunk-T7OZ7X6A.js";
59
59
 
60
60
  // src/plain-markdown.ts
61
61
  function toPlainMarkdown(md2) {
@@ -24642,7 +24642,7 @@ var MIN_SIDE = 24;
24642
24642
  async function ocrEmbeddedImages(blocks, options, warnings) {
24643
24643
  const ocr = options?.ocr;
24644
24644
  if (ocr !== true && ocr !== "force" && typeof ocr !== "function") return false;
24645
- const { parseImageDocument } = await import("./image-ocr-T72HMX2W.js");
24645
+ const { parseImageDocument } = await import("./image-ocr-KE3RUS3R.js");
24646
24646
  let inserted = false, unreadable = 0;
24647
24647
  let failed = null;
24648
24648
  const walk = async (list, depth) => {
@@ -27965,6 +27965,8 @@ var FACE_SPACE = {
27965
27965
  "KoPubWorld\uB3CB\uC6C0\uCCB4 Light": 290
27966
27966
  };
27967
27967
  var BEFORE_2024_WIDTH = {
27968
+ // TTF 신명조의 대체 큰따옴표 — 원본 PDF의 Haansoft Batang /W 370. 한양신명조 HFT와 별개다.
27969
+ "\uC2E0\uBA85\uC870": { 8220: 370, 8221: 370 },
27968
27970
  "\uD734\uBA3C\uBA85\uC870": {
27969
27971
  183: 1e3,
27970
27972
  8211: 430,
@@ -35141,14 +35143,14 @@ function fontHasGlyph(face, cp) {
35141
35143
  if (!hasFontMetrics(face)) return false;
35142
35144
  return cp >= 32 && cp <= 126 || FONTS[face.trim()].ex[cp] !== void 0;
35143
35145
  }
35144
- var HANCOM_FALLBACK_W = { 8228: 173, 8231: 173, 8211: 430, 8680: 1e3, 8728: 500, 8227: 465, 12295: 1e3 };
35146
+ var HANCOM_FALLBACK_W = { 8228: 173, 8231: 173, 8211: 430, 8680: 1e3, 8728: 500, 8227: 465, 12295: 1e3, 61607: 937 / 2048 * 1e3, 61599: 937 / 2048 * 1e3, 61550: 1529 / 2048 * 1e3 };
35145
35147
  function isHanja(cp) {
35146
35148
  return cp >= 19968 && cp <= 40959 || cp >= 13312 && cp <= 19903 || cp >= 63744 && cp <= 64255;
35147
35149
  }
35148
- function fontWidthFn(face) {
35150
+ function fontWidthFn(face, fallback = true) {
35149
35151
  if (!hasFontMetrics(face)) return null;
35150
35152
  const m = FONTS[face.trim()];
35151
- return (cp) => cp >= 32 && cp <= 126 ? m.ascii[cp - 32] : m.ex[cp] ?? (HANCOM_FALLBACK_W[cp] ?? (isHalfwidthForm(cp) ? 500 : m.han !== void 0 && isHanja(cp) ? m.han : m.cjk));
35153
+ return (cp) => cp >= 32 && cp <= 126 ? m.ascii[cp - 32] : m.ex[cp] ?? ((fallback ? HANCOM_FALLBACK_W[cp] : void 0) ?? (isHalfwidthForm(cp) ? 500 : m.han !== void 0 && isHanja(cp) ? m.han : m.cjk));
35152
35154
  }
35153
35155
  function isHalfwidthForm(cp) {
35154
35156
  return cp >= 65377 && cp <= 65500 || cp >= 65512 && cp <= 65518;
@@ -35372,20 +35374,20 @@ function fixedPitchWidthEm1000(cp) {
35372
35374
  return cp < 128 || isHalfwidthForm(cp) ? 500 : 1e3;
35373
35375
  }
35374
35376
  var PUA_FULL = /* @__PURE__ */ new Set([983729, 983730, 983731, 983732, 983733, 983734, 983803]);
35375
- function widthFnOf(faceClass) {
35376
- const base = baseWidthFnOf(faceClass);
35377
+ function widthFnOf(faceClass, fallback = true) {
35378
+ const base = baseWidthFnOf(faceClass, fallback);
35377
35379
  const hcr = faceClass === "hcr" || faceClass === "font:\uD568\uCD08\uB86C\uB3CB\uC6C0" || faceClass === "font:\uD568\uCD08\uB86C\uBC14\uD0D5";
35378
35380
  const f = (cp) => cp >= 983040 ? PUA_FULL.has(cp) ? 1e3 : 500 : cp === 61600 ? base(32) : !hcr && cp >= 10102 && cp <= 10131 ? 1e3 : base(cp);
35379
- if (faceClass === "fixedPitch" || faceClass === "cjk") return (cp) => isZeroWidthCp(cp) ? 0 : HANCOM_FALLBACK_W[cp] ?? f(cp);
35381
+ if (fallback && (faceClass === "fixedPitch" || faceClass === "cjk")) return (cp) => isZeroWidthCp(cp) ? 0 : HANCOM_FALLBACK_W[cp] ?? f(cp);
35380
35382
  return (cp) => isZeroWidthCp(cp) ? 0 : f(cp);
35381
35383
  }
35382
- function baseWidthFnOf(faceClass) {
35384
+ function baseWidthFnOf(faceClass, fallback = true) {
35383
35385
  if (faceClass === "fixedPitch") return fixedPitchWidthEm1000;
35384
35386
  if (faceClass === "gothic") return (cp) => isHalfwidthForm(cp) ? 500 : gothicWidthEm1000(cp);
35385
35387
  if (faceClass === "cjk") return cjkWidthEm1000;
35386
35388
  if (faceClass?.startsWith("font:")) {
35387
35389
  const face = faceClass.slice(5);
35388
- return fontWidthFn(face) ?? gothicWidthEm1000;
35390
+ return fontWidthFn(face, fallback) ?? gothicWidthEm1000;
35389
35391
  }
35390
35392
  return charWidthEm1000;
35391
35393
  }
@@ -35408,7 +35410,7 @@ function mulDiv(a, b, c) {
35408
35410
  const e = a * b;
35409
35411
  return Math.trunc(e < 0 ? (e - c / 2) / c : (e + c / 2) / c);
35410
35412
  }
35411
- function hancomCharWidth(ch, height, ratioPct, spacingPct, faceClass, emAdd = 0) {
35413
+ function hancomCharWidth(ch, height, ratioPct, spacingPct, faceClass, emAdd = 0, fallback = true) {
35412
35414
  const cp = ch.codePointAt(0);
35413
35415
  let w;
35414
35416
  if (cp === 8197) {
@@ -35417,7 +35419,7 @@ function hancomCharWidth(ch, height, ratioPct, spacingPct, faceClass, emAdd = 0)
35417
35419
  } else if (isSpaceCp(cp)) {
35418
35420
  const s = Math.trunc(height / 8);
35419
35421
  w = 4 * (ratioPct === 100 ? s : mulDiv(s, ratioPct, 100));
35420
- } else return hancomEmWidth(widthFnOf(faceClass)(cp) + emAdd, height, ratioPct, spacingPct);
35422
+ } else return hancomEmWidth(widthFnOf(faceClass, fallback)(cp) + emAdd, height, ratioPct, spacingPct);
35421
35423
  if (spacingPct) w += 4 * mulDiv(Math.trunc(w / 4), spacingPct, 100);
35422
35424
  return w;
35423
35425
  }
@@ -42685,7 +42687,8 @@ function parseRenderStyles(headXml, opts) {
42685
42687
  ...cpr != null && cpr !== "4294967295" ? { charPrId: cpr } : {},
42686
42688
  offset: Number(head?.getAttribute("textOffset")) || 0,
42687
42689
  offsetPct: (head?.getAttribute("textOffsetType") ?? "PERCENT") === "PERCENT",
42688
- autoIndent: head?.getAttribute("autoIndent") !== "0"
42690
+ autoIndent: head?.getAttribute("autoIndent") !== "0",
42691
+ ...head?.hasAttribute("useInstWidth") ? { useInstWidth: head.getAttribute("useInstWidth") !== "0" } : {}
42689
42692
  });
42690
42693
  }
42691
42694
  } else if (tag === "numbering") {
@@ -50008,7 +50011,8 @@ function pushTextSlots(t, chars, prId, depth, del = { deleted: 0 }) {
50008
50011
  } else if (tag === "tab") {
50009
50012
  if (del.deleted) pushFillers(chars, 8, prId);
50010
50013
  else {
50011
- chars.push({ ch: "", prId, tab: true, tabW: num2(el, "width"), ...el.getAttribute("type") === "2" ? { tabRight: true } : {} });
50014
+ const width = num2(el, "width", -1);
50015
+ chars.push({ ch: "", prId, tab: true, ...width >= 0 ? { tabW: width } : {}, ...el.getAttribute("type") === "2" ? { tabRight: true } : {} });
50012
50016
  pushFillers(chars, 7, prId);
50013
50017
  }
50014
50018
  } else if (tag === "titleMark") {
@@ -50147,10 +50151,13 @@ function captionExtra(el) {
50147
50151
  return c && (c.side === "TOP" || c.side === "BOTTOM") ? c.h + c.gap : 0;
50148
50152
  }
50149
50153
  var DEFAULT_TAB_HU = 4e3;
50150
- function tabAdvance(x, firstLine, geom, saved = 0) {
50154
+ function paraHeadAdvance(head, offsetHeight, width) {
50155
+ return width + (head.offsetPct ? Math.trunc(offsetHeight * head.offset / 100) : head.offset);
50156
+ }
50157
+ function tabAdvance(x, firstLine, geom, saved) {
50151
50158
  const hang = geom && geom.marginIntent < 0 ? -geom.marginIntent : 0;
50152
50159
  if (firstLine && geom?.autoTabLeft && hang > 0 && x < hang - 0.5) return hang - x;
50153
- if (saved > 0) return saved;
50160
+ if (saved != null && saved >= 0) return saved;
50154
50161
  return (Math.floor(x / DEFAULT_TAB_HU) + 1) * DEFAULT_TAB_HU - x;
50155
50162
  }
50156
50163
  function cellColumns(sub) {
@@ -50456,10 +50463,8 @@ function cellRowRemainder(cells, row, avail, from, record, bases, carries, style
50456
50463
  const end = Math.max(...lines.map((l) => l[1]));
50457
50464
  const k = lines.findIndex((l) => c.marginT + l[1] > avail - c.marginB);
50458
50465
  if (k < 0) {
50459
- if (carry > 0) {
50460
- placed = true;
50461
- rem = Math.max(rem, c.marginT + carry + c.marginB);
50462
- }
50466
+ placed = true;
50467
+ if (carry > 0) rem = Math.max(rem, c.marginT + carry + c.marginB);
50463
50468
  cuts.push([c.el, base + end + 1, base]);
50464
50469
  continue;
50465
50470
  }
@@ -50773,18 +50778,36 @@ function appendNarrowLineFragments(parent, seg, free, box, flow) {
50773
50778
  return true;
50774
50779
  }
50775
50780
 
50781
+ // src/render/reflow-borders.ts
50782
+ function lineBorderBox(model, styles, start, end) {
50783
+ const empty = model.chars.length === 0 && model.objs.length === 0;
50784
+ let top = 0, all = 0;
50785
+ const include = (prId) => {
50786
+ const st = prId != null ? styles.charPr.get(prId) : void 0;
50787
+ const f = st?.borderFill != null ? styles.borderFill.get(st.borderFill) : void 0;
50788
+ if (!f || !f.top && !f.bottom) return;
50789
+ const width = (pt3) => empty ? 2 * Math.trunc(pt3 * 50) : Math.trunc(pt3 * 100);
50790
+ const t = f.top ? width(f.top.widthPt) : 0, b = f.bottom ? width(f.bottom.widthPt) : 0;
50791
+ top = Math.max(top, st.height + t);
50792
+ all = Math.max(all, st.height + t + b);
50793
+ };
50794
+ if (empty) for (const run of model.runs) include(run.prId);
50795
+ else for (let i = start; i < end; i++) if (model.chars[i].ch) include(model.chars[i].prId);
50796
+ return [top, all, empty && all > 0];
50797
+ }
50798
+
50776
50799
  // src/render/reflow.ts
50777
50800
  var geomMemo = (styles) => ({ cell: /* @__PURE__ */ new WeakMap(), table: /* @__PURE__ */ new WeakMap(), paraGeom: styles.paraGeom });
50778
50801
  var LINESEG_FLAGS = "393216";
50779
50802
  var BASELINE_RATIO = 0.85;
50780
50803
  var FONT_LINE_METRICS = [
50781
50804
  [/^맑은 고딕/, 2230 / 2048, 496 / 2048, true],
50782
- [/^(바탕|돋움|굴림|궁서)(체)?$|^HY/, 1758 / 2048, 290 / 2048],
50805
+ [/^(바탕|돋움|굴림|궁서)(체)?$|^한컴바탕$|^HY/, 1758 / 2048, 290 / 2048],
50783
50806
  [/^휴먼명조$/, 0.859, 0.195],
50784
50807
  [/^KoPub(World)?(돋움|바탕)체 Light$/, 0.85, 0.25]
50785
50808
  ];
50786
- function fontLineMetrics(face) {
50787
- if (!face) return void 0;
50809
+ function fontLineMetrics(face, hft) {
50810
+ if (!face || hft && face.trim() === "\uD55C\uCEF4\uBC14\uD0D5") return void 0;
50788
50811
  for (const [re, a, d, up] of FONT_LINE_METRICS) if (re.test(face.trim())) return [a, d, up];
50789
50812
  return void 0;
50790
50813
  }
@@ -50824,7 +50847,7 @@ function hancomLangOf(cp) {
50824
50847
  if (cp >= 57344 && cp < 63744 || cp >= 983040) return "hangul";
50825
50848
  return "symbol";
50826
50849
  }
50827
- function glyphWidth(ch, st) {
50850
+ function glyphWidth(ch, st, fallback = true) {
50828
50851
  const cp = ch.codePointAt(0);
50829
50852
  const space = cp === 32 || cp === 160;
50830
50853
  const lang = space ? "hangul" : hancomLangOf(cp);
@@ -50837,7 +50860,7 @@ function glyphWidth(ch, st) {
50837
50860
  const face1 = L?.face ?? st.face;
50838
50861
  const face0 = face1 === "Batang" ? st.before2024 ? "\uBC14\uD0D5" : "\uD55C\uCEF4\uBC14\uD0D5" : face1;
50839
50862
  const boldFace = !space && st.bold && (L ? L.hft : st.hft) && face0 && fontHasGlyph(`${face0} Bold`, cp) ? `${face0} Bold` : void 0;
50840
- const oldEm = st.halfQuote && face0 === "\uD734\uBA3C\uBA85\uC870" && (cp === 8220 || cp === 8221) ? 500 : st.halfQuote && !st.before2024 && face0 === "\uD734\uBA3C\uBA85\uC870" && (cp === 8216 || cp === 8217) ? 312 : st.before2024 && face0 ? BEFORE_2024_WIDTH[face0]?.[cp] : !st.halfQuote && face0 === "\uD734\uBA3C\uBA85\uC870" && cp === 8231 ? BEFORE_2024_WIDTH[face0]?.[cp] : void 0;
50863
+ const oldEm = st.halfQuote && face0 === "\uD734\uBA3C\uBA85\uC870" && (cp === 8220 || cp === 8221) ? 500 : st.halfQuote && !st.before2024 && face0 === "\uD734\uBA3C\uBA85\uC870" && (cp === 8216 || cp === 8217) ? 312 : st.before2024 && face0 && !(face0 === "\uC2E0\uBA85\uC870" && (st.halfQuote || (L?.face ? L.hft : st.hft))) ? BEFORE_2024_WIDTH[face0]?.[cp] : !st.halfQuote && face0 === "\uD734\uBA3C\uBA85\uC870" && cp === 8231 ? BEFORE_2024_WIDTH[face0]?.[cp] : void 0;
50841
50864
  const fc = faceClassForReflow(boldFace ?? face0);
50842
50865
  const fsEm = space && st.fontSpace ? fontSpaceEm(st.face) : void 0;
50843
50866
  if (fsEm !== void 0) {
@@ -50850,8 +50873,8 @@ function glyphWidth(ch, st) {
50850
50873
  const b0 = hancomEmWidth(oldEm + bAdd, h, ratio, 0), w0 = spacing ? hancomEmWidth(oldEm + bAdd, h, ratio, spacing) : b0;
50851
50874
  return { w: w0, sp: w0 - b0 };
50852
50875
  }
50853
- const base = hancomCharWidth(ch, h, ratio, 0, fc, bAdd);
50854
- const w = spacing ? hancomCharWidth(ch, h, ratio, spacing, fc, bAdd) : base;
50876
+ const base = hancomCharWidth(ch, h, ratio, 0, fc, bAdd, fallback);
50877
+ const w = spacing ? hancomCharWidth(ch, h, ratio, spacing, fc, bAdd, fallback) : base;
50855
50878
  return { w, sp: w - base };
50856
50879
  }
50857
50880
  function pitchFor(height, geom) {
@@ -50980,12 +51003,10 @@ function reflowPara(p, doc, styles, areaW, startV, mode, zones = [], nums = /* @
50980
51003
  const avail = Math.max(1440, Math.floor(areaW / 4) * 4 - marginL - geom.marginRight);
50981
51004
  const firstWidth = avail;
50982
51005
  const bu = geom.bullet ?? (numText && geom.number ? { ch: numText, ...geom.number } : void 0);
51006
+ const bst = (bu?.charPrId != null ? styles.charPr.get(bu.charPrId) : void 0) ?? domChar;
50983
51007
  let headW = 0;
50984
- if (bu) {
50985
- const bst = (bu.charPrId != null ? styles.charPr.get(bu.charPrId) : void 0) ?? domChar;
50986
- for (const ch of bu.ch) headW += glyphWidth(ch, bst).w;
50987
- }
50988
- const bulletW = bu ? headW + (bu.offsetPct ? Math.trunc(height * bu.offset / 100) : bu.offset) : 0;
51008
+ if (bu) for (const ch of bu.ch) headW += glyphWidth(ch, bst, bu.useInstWidth !== false).w;
51009
+ const bulletW = bu ? paraHeadAdvance(bu, height, headW) : 0;
50989
51010
  const contBullet = bu?.autoIndent ? bulletW : 0;
50990
51011
  const squeeze = p.parentNode?.getAttribute?.("lineWrap") === "SQUEEZE" || !!geom.squeeze;
50991
51012
  const NO_WRAP = 1e9;
@@ -51057,7 +51078,7 @@ function reflowPara(p, doc, styles, areaW, startV, mode, zones = [], nums = /* @
51057
51078
  const hRel = pos?.getAttribute("horzRelTo") ?? "COLUMN", hAlign = pos?.getAttribute("horzAlign") ?? "LEFT";
51058
51079
  const ho = num3(pos, "horzOffset"), base = hRel === "PARA" ? marginL : 0, span2 = hRel === "PARA" ? avail : areaW;
51059
51080
  const x0 = base + (hAlign === "RIGHT" ? span2 - ho - o.width : hAlign === "CENTER" ? (span2 - o.width) / 2 + ho : ho);
51060
- const top = startV + vo;
51081
+ const top = startV - (bodyFlow && vertRel === "PARA" && wrapAttr === "SQUARE" ? geom.spaceBefore : 0) + vo;
51061
51082
  const omLx = num3(om, "left"), omRx = num3(om, "right");
51062
51083
  const xs = hAlign === "RIGHT" ? x0 - omRx : hAlign === "CENTER" ? x0 : x0 + omLx;
51063
51084
  const nextPage = pageH > 0 && top + effH + outB > pageH;
@@ -51198,6 +51219,8 @@ function reflowPara(p, doc, styles, areaW, startV, mode, zones = [], nums = /* @
51198
51219
  lineObjAsc[li] = Math.max(lineObjAsc[li], Math.round(h * (Number.isFinite(bl) ? bl / 100 : BASELINE_RATIO)));
51199
51220
  }
51200
51221
  const lsa = doc.createElement("hp:linesegarray");
51222
+ const subList = p.parentNode;
51223
+ const verticalCenter = subList?.getAttribute?.("vertAlign") === "CENTER" && ["VERTICAL", "VERTICALALL"].includes(subList.getAttribute("textDirection") ?? "");
51201
51224
  let v = textStartV;
51202
51225
  let firstAcc = 0;
51203
51226
  const textposOf = wrap.starts.map((startReal, li) => li === 0 ? 0 : startReal < realIdx.length ? realIdx[startReal] : realIdx.length ? m.chars.length : 0);
@@ -51213,40 +51236,27 @@ function reflowPara(p, doc, styles, areaW, startV, mode, zones = [], nums = /* @
51213
51236
  const fontLineOf = (li) => {
51214
51237
  if (!geom.fontLineHeight) return void 0;
51215
51238
  const s = textposOf[li], e = li === wrap.starts.length - 1 ? m.chars.length : textposOf[li + 1];
51239
+ if (!m.chars.slice(s, e).some((c) => c.ch && c.ch !== " ")) return void 0;
51216
51240
  let h = 0, b = 0, any = false;
51217
51241
  for (let k = s; k < e; k++) {
51218
51242
  const c = m.chars[k];
51219
- if (!c.ch || c.ch === " ") continue;
51243
+ if (!c.ch) continue;
51220
51244
  const st = c.prId != null ? styles.charPr.get(c.prId) : void 0;
51221
51245
  if (!st) continue;
51222
51246
  const cp = c.ch.codePointAt(0);
51223
- const fm = fontLineMetrics(st.latin && isLatinCp(cp) ? st.latin.face : st.face);
51247
+ const font = c.ch !== " " && st.latin && isLatinCp(cp) ? st.latin : st;
51248
+ const fm = fontLineMetrics(font.face, font.hft);
51224
51249
  any = true;
51225
51250
  h = Math.max(h, fm ? Math.round(st.height * fm[0]) + (fm[2] ? Math.round : Math.trunc)(st.height * fm[1]) : st.height);
51226
51251
  b = Math.max(b, fm ? Math.round(st.height * fm[0]) : Math.round(st.height * BASELINE_RATIO));
51227
51252
  }
51228
51253
  return any ? [h, b] : void 0;
51229
51254
  };
51230
- const lineBorderBox = (li) => {
51231
- const s0 = textposOf[li], e = li === wrap.starts.length - 1 ? m.chars.length : textposOf[li + 1];
51232
- let top = 0, all = 0;
51233
- for (let k = s0; k < e; k++) {
51234
- const c = m.chars[k];
51235
- if (!c.ch) continue;
51236
- const st = c.prId != null ? styles.charPr.get(c.prId) : void 0;
51237
- const f = st?.borderFill != null ? styles.borderFill.get(st.borderFill) : void 0;
51238
- if (!f || !f.top && !f.bottom) continue;
51239
- const t = f.top ? Math.trunc(f.top.widthPt * 100) : 0, b = f.bottom ? Math.trunc(f.bottom.widthPt * 100) : 0;
51240
- top = Math.max(top, st.height + t);
51241
- all = Math.max(all, st.height + t + b);
51242
- }
51243
- return [top, all];
51244
- };
51245
51255
  const natW = widths.reduce((a, w) => a + w, 0) + spacings.reduce((a, w) => a + w, 0);
51246
51256
  for (let li = 0; li < wrap.starts.length; li++) {
51247
51257
  const textpos = textposOf[li];
51248
51258
  const fl = fontLineOf(li);
51249
- const [boxTop, boxAll] = lineBorderBox(li);
51259
+ const [boxTop, boxAll, emptyBorder] = lineBorderBox(m, styles, textposOf[li], textposOf[li + 1] ?? m.chars.length);
51250
51260
  const textH0 = fl ? Math.max(fl[0], lineTextH(li)) : lineTextH(li);
51251
51261
  const textH = Math.max(textH0, boxAll);
51252
51262
  const objOnly = lineObjH[li] > 0 && lineObjH[li] < textH && (() => {
@@ -51269,15 +51279,17 @@ function reflowPara(p, doc, styles, areaW, startV, mode, zones = [], nums = /* @
51269
51279
  }
51270
51280
  }
51271
51281
  const vertpos = v;
51272
- const occupiedH = Math.max(lineH, collisionHeights[li] ?? 0);
51282
+ const nextStart = textposOf[li + 1], nextChar = m.chars[nextStart];
51283
+ const boundaryH = !m.objs.length && !geom.fontLineHeight && nextChar?.ch.trim() && m.runs.some((r) => r.at === nextStart && r.prId === nextChar.prId) ? heightOf(nextChar.prId) : 0;
51284
+ const occupiedH = Math.max(lineH, collisionHeights[li] ?? 0, boundaryH);
51273
51285
  v += lineH + spacing;
51274
51286
  const isFirst = li === 0;
51275
51287
  const seg = doc.createElement("hp:lineseg");
51276
51288
  seg.setAttribute("textpos", String(textpos));
51277
51289
  seg.setAttribute("vertpos", String(vertpos));
51278
- seg.setAttribute("vertsize", String(occupiedH === textH && boxAll > textH0 ? Math.max(textH0, boxTop) : occupiedH));
51290
+ seg.setAttribute("vertsize", String(emptyBorder ? textH0 : occupiedH === textH && boxAll > textH0 ? Math.max(textH0, boxTop) : occupiedH));
51279
51291
  seg.setAttribute("textheight", String(lineH));
51280
- seg.setAttribute("baseline", String(geom.vertAlign === "TOP" ? 0 : geom.vertAlign === "CENTER" ? Math.floor(lineH / 2) : geom.vertAlign === "BOTTOM" ? lineH : Math.max(fl ? fl[1] : Math.round(textH0 * BASELINE_RATIO), lineObjAsc[li])));
51292
+ seg.setAttribute("baseline", String(geom.vertAlign === "TOP" ? 0 : geom.vertAlign === "CENTER" || verticalCenter && (!geom.vertAlign || geom.vertAlign === "BASELINE") ? Math.floor(lineH / 2) : geom.vertAlign === "BOTTOM" ? lineH : Math.max(fl ? fl[1] : Math.round(textH0 * BASELINE_RATIO), boxTop > textH0 ? Math.round(boxTop * BASELINE_RATIO) : 0, lineObjAsc[li])));
51281
51293
  seg.setAttribute("spacing", String(spacing));
51282
51294
  let box = boxAt(li);
51283
51295
  const fit = wrap.starts.length === 1 && lineObjH[li] === 0 ? lineParts[li]?.filter(([a, b]) => b - a >= 1440) : void 0;
@@ -51755,205 +51767,6 @@ function flowEndNotes(root, bodyH) {
51755
51767
  });
51756
51768
  }
51757
51769
 
51758
- // src/render/equation-text.ts
51759
- var SYMBOLS = {
51760
- alpha: "\u03B1",
51761
- beta: "\u03B2",
51762
- gamma: "\u03B3",
51763
- delta: "\u03B4",
51764
- epsilon: "\u03B5",
51765
- varepsilon: "\u03B5",
51766
- zeta: "\u03B6",
51767
- eta: "\u03B7",
51768
- theta: "\u03B8",
51769
- vartheta: "\u03D1",
51770
- iota: "\u03B9",
51771
- kappa: "\u03BA",
51772
- lambda: "\u03BB",
51773
- mu: "\u03BC",
51774
- nu: "\u03BD",
51775
- xi: "\u03BE",
51776
- pi: "\u03C0",
51777
- rho: "\u03C1",
51778
- sigma: "\u03C3",
51779
- tau: "\u03C4",
51780
- upsilon: "\u03C5",
51781
- phi: "\u03C6",
51782
- varphi: "\u03C6",
51783
- chi: "\u03C7",
51784
- psi: "\u03C8",
51785
- omega: "\u03C9",
51786
- Gamma: "\u0393",
51787
- Delta: "\u0394",
51788
- Theta: "\u0398",
51789
- Lambda: "\u039B",
51790
- Xi: "\u039E",
51791
- Pi: "\u03A0",
51792
- Sigma: "\u03A3",
51793
- Phi: "\u03A6",
51794
- Psi: "\u03A8",
51795
- Omega: "\u03A9",
51796
- times: "\xD7",
51797
- cdot: "\xB7",
51798
- div: "\xF7",
51799
- pm: "\xB1",
51800
- mp: "\u2213",
51801
- le: "\u2264",
51802
- leq: "\u2264",
51803
- ge: "\u2265",
51804
- geq: "\u2265",
51805
- ne: "\u2260",
51806
- neq: "\u2260",
51807
- approx: "\u2248",
51808
- equiv: "\u2261",
51809
- sim: "\u223C",
51810
- infty: "\u221E",
51811
- rightarrow: "\u2192",
51812
- leftarrow: "\u2190",
51813
- Rightarrow: "\u21D2",
51814
- Leftarrow: "\u21D0",
51815
- leftrightarrow: "\u2194",
51816
- Leftrightarrow: "\u21D4",
51817
- to: "\u2192",
51818
- angle: "\u2220",
51819
- triangle: "\u25B3",
51820
- perp: "\u22A5",
51821
- parallel: "\u2225",
51822
- circ: "\u2218",
51823
- degree: "\xB0",
51824
- sum: "\u03A3",
51825
- prod: "\u03A0",
51826
- int: "\u222B",
51827
- oint: "\u222E",
51828
- partial: "\u2202",
51829
- nabla: "\u2207",
51830
- in: "\u2208",
51831
- notin: "\u2209",
51832
- subset: "\u2282",
51833
- supset: "\u2283",
51834
- subseteq: "\u2286",
51835
- supseteq: "\u2287",
51836
- cup: "\u222A",
51837
- cap: "\u2229",
51838
- emptyset: "\u2205",
51839
- forall: "\u2200",
51840
- exists: "\u2203",
51841
- therefore: "\u2234",
51842
- because: "\u2235",
51843
- prime: "\u2032",
51844
- cdots: "\u22EF",
51845
- ldots: "\u2026",
51846
- dots: "\u2026",
51847
- vdots: "\u22EE",
51848
- lim: "lim",
51849
- log: "log",
51850
- ln: "ln",
51851
- sin: "sin",
51852
- cos: "cos",
51853
- tan: "tan",
51854
- sec: "sec",
51855
- csc: "csc",
51856
- cot: "cot",
51857
- exp: "exp",
51858
- max: "max",
51859
- min: "min",
51860
- quad: " ",
51861
- qquad: " ",
51862
- ",": " ",
51863
- ";": " ",
51864
- "!": "",
51865
- "{": "{",
51866
- "}": "}",
51867
- "|": "\u2016",
51868
- backslash: "\\",
51869
- lbrace: "{",
51870
- rbrace: "}",
51871
- langle: "\u27E8",
51872
- rangle: "\u27E9"
51873
- };
51874
- var SUP = { "0": "\u2070", "1": "\xB9", "2": "\xB2", "3": "\xB3", "4": "\u2074", "5": "\u2075", "6": "\u2076", "7": "\u2077", "8": "\u2078", "9": "\u2079", "+": "\u207A", "-": "\u207B", "=": "\u207C", "(": "\u207D", ")": "\u207E", n: "\u207F", i: "\u2071", x: "\u02E3", "\u2032": "\u2032" };
51875
- var SUB = { "0": "\u2080", "1": "\u2081", "2": "\u2082", "3": "\u2083", "4": "\u2084", "5": "\u2085", "6": "\u2086", "7": "\u2087", "8": "\u2088", "9": "\u2089", "+": "\u208A", "-": "\u208B", "=": "\u208C", "(": "\u208D", ")": "\u208E" };
51876
- function latexToPlain(latex) {
51877
- let i = 0;
51878
- const s = latex;
51879
- const skipWs = () => {
51880
- while (i < s.length && s[i] === " ") i++;
51881
- };
51882
- const arg = () => {
51883
- skipWs();
51884
- if (s[i] === "{") {
51885
- i++;
51886
- const v = seq("}");
51887
- i++;
51888
- return v;
51889
- }
51890
- return atom();
51891
- };
51892
- const wrap = (v) => v.length > 1 && !/^[\w.′]+$|^\(.*\)$/u.test(v) ? `(${v})` : v;
51893
- const script = (v, map, mark) => {
51894
- const t = v.trim();
51895
- return [...t].every((c) => map[c]) ? [...t].map((c) => map[c]).join("") : `${mark}${wrap(t)}`;
51896
- };
51897
- const atom = () => {
51898
- const c = s[i];
51899
- if (c === void 0) return "";
51900
- if (c === "\\") {
51901
- i++;
51902
- let name = "";
51903
- if (/[A-Za-z]/.test(s[i] ?? "")) while (/[A-Za-z]/.test(s[i] ?? "")) name += s[i++];
51904
- else name = s[i++] ?? "";
51905
- if (name === "frac") {
51906
- const a = arg(), b = arg();
51907
- return `${wrap(a.trim())}/${wrap(b.trim())}`;
51908
- }
51909
- if (name === "sqrt") {
51910
- skipWs();
51911
- let root = "";
51912
- if (s[i] === "[") {
51913
- i++;
51914
- root = seq("]");
51915
- i++;
51916
- }
51917
- const a = arg();
51918
- return `${root ? script(root, SUP, "") : ""}\u221A${wrap(a.trim())}`;
51919
- }
51920
- if (name === "left" || name === "right" || name === "big" || name === "Big" || name === "bigg" || name === "Bigg") {
51921
- skipWs();
51922
- const d = s[i] === "\\" ? atom() : s[i++] ?? "";
51923
- return d === "." ? "" : d;
51924
- }
51925
- if (name === "overline" || name === "bar" || name === "hat" || name === "vec" || name === "dot" || name === "tilde") {
51926
- const a = arg().trim(), mark = { overline: "\u0305", bar: "\u0304", hat: "\u0302", vec: "\u20D7", dot: "\u0307", tilde: "\u0303" }[name];
51927
- return [...a].map((ch) => ch + mark).join("");
51928
- }
51929
- if (name === "mathrm" || name === "text" || name === "rm" || name === "mathbf" || name === "it" || name === "mathit" || name === "operatorname") return name === "rm" || name === "it" ? "" : arg();
51930
- return SYMBOLS[name] ?? name;
51931
- }
51932
- i++;
51933
- if (c === "{") {
51934
- const v = seq("}");
51935
- i++;
51936
- return v;
51937
- }
51938
- if (c === "^") return script(arg(), SUP, "^");
51939
- if (c === "_") return script(arg(), SUB, "_");
51940
- if (c === "~" || c === "`") return " ";
51941
- return c;
51942
- };
51943
- const seq = (end) => {
51944
- let out = "";
51945
- while (i < s.length && s[i] !== end) {
51946
- if (s[i] === " ") {
51947
- i++;
51948
- continue;
51949
- }
51950
- out += atom();
51951
- }
51952
- return out;
51953
- };
51954
- return seq("\0").replace(/\s+/g, " ").trim();
51955
- }
51956
-
51957
51770
  // src/render/scene.ts
51958
51771
  function regionId(type, seq) {
51959
51772
  return `${type}-${String(seq).padStart(6, "0")}`;
@@ -52528,7 +52341,249 @@ function shapeGeometry(o, boxX, boxY, defs, images, warn, local = false) {
52528
52341
  return { ...geometry, svg };
52529
52342
  }
52530
52343
 
52531
- // src/render/svg-render.ts
52344
+ // src/render/equation-text.ts
52345
+ var SYMBOLS = {
52346
+ alpha: "\u03B1",
52347
+ beta: "\u03B2",
52348
+ gamma: "\u03B3",
52349
+ delta: "\u03B4",
52350
+ epsilon: "\u03B5",
52351
+ varepsilon: "\u03B5",
52352
+ zeta: "\u03B6",
52353
+ eta: "\u03B7",
52354
+ theta: "\u03B8",
52355
+ vartheta: "\u03D1",
52356
+ iota: "\u03B9",
52357
+ kappa: "\u03BA",
52358
+ lambda: "\u03BB",
52359
+ mu: "\u03BC",
52360
+ nu: "\u03BD",
52361
+ xi: "\u03BE",
52362
+ pi: "\u03C0",
52363
+ rho: "\u03C1",
52364
+ sigma: "\u03C3",
52365
+ tau: "\u03C4",
52366
+ upsilon: "\u03C5",
52367
+ phi: "\u03C6",
52368
+ varphi: "\u03C6",
52369
+ chi: "\u03C7",
52370
+ psi: "\u03C8",
52371
+ omega: "\u03C9",
52372
+ Gamma: "\u0393",
52373
+ Delta: "\u0394",
52374
+ Theta: "\u0398",
52375
+ Lambda: "\u039B",
52376
+ Xi: "\u039E",
52377
+ Pi: "\u03A0",
52378
+ Sigma: "\u03A3",
52379
+ Phi: "\u03A6",
52380
+ Psi: "\u03A8",
52381
+ Omega: "\u03A9",
52382
+ times: "\xD7",
52383
+ cdot: "\xB7",
52384
+ div: "\xF7",
52385
+ pm: "\xB1",
52386
+ mp: "\u2213",
52387
+ le: "\u2264",
52388
+ leq: "\u2264",
52389
+ ge: "\u2265",
52390
+ geq: "\u2265",
52391
+ ne: "\u2260",
52392
+ neq: "\u2260",
52393
+ approx: "\u2248",
52394
+ equiv: "\u2261",
52395
+ sim: "\u223C",
52396
+ infty: "\u221E",
52397
+ rightarrow: "\u2192",
52398
+ leftarrow: "\u2190",
52399
+ Rightarrow: "\u21D2",
52400
+ Leftarrow: "\u21D0",
52401
+ leftrightarrow: "\u2194",
52402
+ Leftrightarrow: "\u21D4",
52403
+ to: "\u2192",
52404
+ angle: "\u2220",
52405
+ triangle: "\u25B3",
52406
+ perp: "\u22A5",
52407
+ parallel: "\u2225",
52408
+ circ: "\u2218",
52409
+ degree: "\xB0",
52410
+ sum: "\u03A3",
52411
+ prod: "\u03A0",
52412
+ int: "\u222B",
52413
+ oint: "\u222E",
52414
+ partial: "\u2202",
52415
+ nabla: "\u2207",
52416
+ in: "\u2208",
52417
+ notin: "\u2209",
52418
+ subset: "\u2282",
52419
+ supset: "\u2283",
52420
+ subseteq: "\u2286",
52421
+ supseteq: "\u2287",
52422
+ cup: "\u222A",
52423
+ cap: "\u2229",
52424
+ emptyset: "\u2205",
52425
+ forall: "\u2200",
52426
+ exists: "\u2203",
52427
+ therefore: "\u2234",
52428
+ because: "\u2235",
52429
+ prime: "\u2032",
52430
+ cdots: "\u22EF",
52431
+ ldots: "\u2026",
52432
+ dots: "\u2026",
52433
+ vdots: "\u22EE",
52434
+ lim: "lim",
52435
+ log: "log",
52436
+ ln: "ln",
52437
+ sin: "sin",
52438
+ cos: "cos",
52439
+ tan: "tan",
52440
+ sec: "sec",
52441
+ csc: "csc",
52442
+ cot: "cot",
52443
+ exp: "exp",
52444
+ max: "max",
52445
+ min: "min",
52446
+ quad: " ",
52447
+ qquad: " ",
52448
+ ",": " ",
52449
+ ";": " ",
52450
+ "!": "",
52451
+ "{": "{",
52452
+ "}": "}",
52453
+ "|": "\u2016",
52454
+ backslash: "\\",
52455
+ lbrace: "{",
52456
+ rbrace: "}",
52457
+ langle: "\u27E8",
52458
+ rangle: "\u27E9"
52459
+ };
52460
+ var SUP = { "0": "\u2070", "1": "\xB9", "2": "\xB2", "3": "\xB3", "4": "\u2074", "5": "\u2075", "6": "\u2076", "7": "\u2077", "8": "\u2078", "9": "\u2079", "+": "\u207A", "-": "\u207B", "=": "\u207C", "(": "\u207D", ")": "\u207E", n: "\u207F", i: "\u2071", x: "\u02E3", "\u2032": "\u2032" };
52461
+ var SUB = { "0": "\u2080", "1": "\u2081", "2": "\u2082", "3": "\u2083", "4": "\u2084", "5": "\u2085", "6": "\u2086", "7": "\u2087", "8": "\u2088", "9": "\u2089", "+": "\u208A", "-": "\u208B", "=": "\u208C", "(": "\u208D", ")": "\u208E" };
52462
+ function latexToPlain(latex) {
52463
+ let i = 0;
52464
+ const s = latex;
52465
+ const skipWs = () => {
52466
+ while (i < s.length && s[i] === " ") i++;
52467
+ };
52468
+ const arg = () => {
52469
+ skipWs();
52470
+ if (s[i] === "{") {
52471
+ i++;
52472
+ const v = seq("}");
52473
+ i++;
52474
+ return v;
52475
+ }
52476
+ return atom();
52477
+ };
52478
+ const wrap = (v) => v.length > 1 && !/^[\w.′]+$|^\(.*\)$/u.test(v) ? `(${v})` : v;
52479
+ const script = (v, map, mark) => {
52480
+ const t = v.trim();
52481
+ return [...t].every((c) => map[c]) ? [...t].map((c) => map[c]).join("") : `${mark}${wrap(t)}`;
52482
+ };
52483
+ const atom = () => {
52484
+ const c = s[i];
52485
+ if (c === void 0) return "";
52486
+ if (c === "\\") {
52487
+ i++;
52488
+ let name = "";
52489
+ if (/[A-Za-z]/.test(s[i] ?? "")) while (/[A-Za-z]/.test(s[i] ?? "")) name += s[i++];
52490
+ else name = s[i++] ?? "";
52491
+ if (name === "frac") {
52492
+ const a = arg(), b = arg();
52493
+ return `${wrap(a.trim())}/${wrap(b.trim())}`;
52494
+ }
52495
+ if (name === "sqrt") {
52496
+ skipWs();
52497
+ let root = "";
52498
+ if (s[i] === "[") {
52499
+ i++;
52500
+ root = seq("]");
52501
+ i++;
52502
+ }
52503
+ const a = arg();
52504
+ return `${root ? script(root, SUP, "") : ""}\u221A${wrap(a.trim())}`;
52505
+ }
52506
+ if (name === "left" || name === "right" || name === "big" || name === "Big" || name === "bigg" || name === "Bigg") {
52507
+ skipWs();
52508
+ const d = s[i] === "\\" ? atom() : s[i++] ?? "";
52509
+ return d === "." ? "" : d;
52510
+ }
52511
+ if (name === "overline" || name === "bar" || name === "hat" || name === "vec" || name === "dot" || name === "tilde") {
52512
+ const a = arg().trim(), mark = { overline: "\u0305", bar: "\u0304", hat: "\u0302", vec: "\u20D7", dot: "\u0307", tilde: "\u0303" }[name];
52513
+ return [...a].map((ch) => ch + mark).join("");
52514
+ }
52515
+ if (name === "mathrm" || name === "text" || name === "rm" || name === "mathbf" || name === "it" || name === "mathit" || name === "operatorname") return name === "rm" || name === "it" ? "" : arg();
52516
+ return SYMBOLS[name] ?? name;
52517
+ }
52518
+ i++;
52519
+ if (c === "{") {
52520
+ const v = seq("}");
52521
+ i++;
52522
+ return v;
52523
+ }
52524
+ if (c === "^") return script(arg(), SUP, "^");
52525
+ if (c === "_") return script(arg(), SUB, "_");
52526
+ if (c === "~" || c === "`") return " ";
52527
+ return c;
52528
+ };
52529
+ const seq = (end) => {
52530
+ let out = "";
52531
+ while (i < s.length && s[i] !== end) {
52532
+ if (s[i] === " ") {
52533
+ i++;
52534
+ continue;
52535
+ }
52536
+ out += atom();
52537
+ }
52538
+ return out;
52539
+ };
52540
+ return seq("\0").replace(/\s+/g, " ").trim();
52541
+ }
52542
+
52543
+ // src/render/object-anchor.ts
52544
+ function anchorObject(o, ox, oy, baseV, areaW, ctx, anchorLineV, stayLine = false, paraStartV, laterLineH) {
52545
+ const { PW, PH, ML, MT, BODY_W, BODY_H } = ctx.geom;
52546
+ const pos = findChildByLocalName(o.el, "pos");
52547
+ const om = findChildByLocalName(o.el, "outMargin");
52548
+ const omT = num2(om, "top"), omB = num2(om, "bottom");
52549
+ const w = o.width, h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el, ctx.extentMemo)) : o.height;
52550
+ if (!pos) return { x: ox, y: oy + baseV };
52551
+ const voRaw = num2(pos, "vertOffset"), voS = voRaw >= 2 ** 31 ? voRaw - 2 ** 32 : voRaw;
52552
+ const vo = (pos.getAttribute("vertRelTo") ?? "PARA") === "PARA" ? Math.max(0, voS) : voS;
52553
+ const ho = num2(pos, "horzOffset");
52554
+ const vrel = pos.getAttribute("vertRelTo") ?? "PARA";
52555
+ const hrel = pos.getAttribute("horzRelTo") ?? "PARA";
52556
+ const va = pos.getAttribute("vertAlign") ?? "TOP";
52557
+ const ha = pos.getAttribute("horzAlign") ?? "LEFT";
52558
+ const wrap = o.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM";
52559
+ let y;
52560
+ if (vrel === "PAPER") {
52561
+ y = va === "BOTTOM" ? PH - h - vo - omB : va === "CENTER" ? (PH - h) / 2 + vo : vo + omT;
52562
+ } else if (vrel === "PAGE") {
52563
+ y = va === "BOTTOM" ? MT + BODY_H - h - vo : va === "CENTER" ? MT + (BODY_H - h) / 2 + vo : MT + vo;
52564
+ } else if (wrap === "TOP_AND_BOTTOM") {
52565
+ const lineV = anchorLineV ?? baseV;
52566
+ const pushed = lineV - (omT + h + omB);
52567
+ const below = laterLineH !== void 0 && vo + omT >= laterLineH;
52568
+ const anchor = below ? lineV : stayLine !== false ? lineV - stayLine : pushed >= -100 ? pushed : paraStartV !== void 0 ? paraStartV : lineV;
52569
+ y = oy + anchor + omT + vo;
52570
+ } else {
52571
+ const origin = vrel === "PARA" && wrap === "SQUARE" ? paraStartV ?? baseV : baseV;
52572
+ y = oy + Math.max(origin + vo, wrap === "SQUARE" && anchorLineV !== void 0 ? anchorLineV : -Infinity) + omT;
52573
+ }
52574
+ let x;
52575
+ const omL = num2(om, "left"), omR = num2(om, "right");
52576
+ if (hrel === "PAGE") {
52577
+ x = ha === "RIGHT" ? ML + BODY_W - w - ho - omR : ha === "CENTER" ? ML + (BODY_W - w) / 2 + ho : ML + ho + omL;
52578
+ } else if (hrel === "PAPER") {
52579
+ x = (ha === "RIGHT" ? PW - w - ho - omR : ha === "CENTER" ? (PW - w) / 2 + ho : ho + omL) - (ctx.bodyDx?.(ctx.page) ?? 0);
52580
+ } else {
52581
+ x = ha === "RIGHT" ? ox + areaW - w - ho - omR : ha === "CENTER" ? ox + (areaW - w) / 2 + ho : ox + ho + omL;
52582
+ }
52583
+ return { x, y };
52584
+ }
52585
+
52586
+ // src/render/svg-content.ts
52532
52587
  function escapeXml7(s) {
52533
52588
  return s.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
52534
52589
  }
@@ -52578,7 +52633,8 @@ function planLines(m, styles, numText = "") {
52578
52633
  const bu = geom?.bullet ?? (numText && geom?.number ? { ch: numText, ...geom.number } : void 0);
52579
52634
  const firstPr = m.chars.find((c) => c.ch !== "")?.prId ?? null;
52580
52635
  const bst = (bu?.charPrId != null ? styles.charPr.get(bu.charPrId) : firstPr != null ? styles.charPr.get(firstPr) : void 0) ?? DEFAULT_CHAR;
52581
- const bulletW = bu ? measureTextWidth(bu.ch, bst.height, bst.ratio, { spacingPct: bst.spacing, faceClass: faceClassOf(bst.face) }) + (bu.offsetPct ? Math.trunc(bst.height * bu.offset / 100) : bu.offset) : 0;
52636
+ const headW = bu?.useInstWidth === false ? [...bu.ch].reduce((w, ch) => w + glyphWidth(ch, bst, false).w, 0) : bu ? measureTextWidth(bu.ch, bst.height, bst.ratio, { spacingPct: bst.spacing, faceClass: faceClassOf(bst.face) }) : 0;
52637
+ const bulletW = bu ? paraHeadAdvance(bu, bst.height, headW) : 0;
52582
52638
  const plans = [];
52583
52639
  for (let i = 0; i < m.segs.length; i++) {
52584
52640
  const seg = m.segs[i];
@@ -52850,7 +52906,7 @@ function drawPara(p, ox, oy, areaW, ctx, depth, segPages) {
52850
52906
  const stay = tbFloats < 2 && !m.objs.some((q) => q.inline) && !m.chars.some((c) => c.ch !== "" && !c.nb && c.ch.trim() !== "");
52851
52907
  const sbA = m.paraPrId != null ? ctx.styles.paraGeom.get(m.paraPrId)?.spaceBefore ?? 0 : 0;
52852
52908
  const firstLine = anchorLineV === void 0 || anchorLineV === baseV;
52853
- let { x, y } = anchorObject(o, ax, oy, objBaseV, aw, ctx, anchorLineV, stay ? sbA : false, firstLine && pTop !== void 0 && pTop < baseV ? pTop : void 0, firstLine ? void 0 : anchorLineH);
52909
+ 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);
52854
52910
  if (depth === 0 && tbFloats >= 2 && wrapA === "TOP_AND_BOTTOM") {
52855
52911
  if (!tbStack) {
52856
52912
  tbStack = /* @__PURE__ */ new Map();
@@ -52887,46 +52943,6 @@ function cellParaTop(p, geom) {
52887
52943
  const last = segs[segs.length - 1];
52888
52944
  return num2(last, "vertpos") + num2(last, "vertsize") + num2(last, "spacing") + (geom.get(prev.getAttribute("paraPrIDRef") ?? "")?.spaceAfter ?? 0);
52889
52945
  }
52890
- function anchorObject(o, ox, oy, baseV, areaW, ctx, anchorLineV, stayLine = false, paraStartV, laterLineH) {
52891
- const { PW, PH, ML, MT, BODY_W, BODY_H } = ctx.geom;
52892
- const pos = findChildByLocalName(o.el, "pos");
52893
- const om = findChildByLocalName(o.el, "outMargin");
52894
- const omT = num2(om, "top"), omB = num2(om, "bottom");
52895
- const w = o.width, h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el, ctx.extentMemo)) : o.height;
52896
- if (!pos) return { x: ox, y: oy + baseV };
52897
- const voRaw = num2(pos, "vertOffset"), voS = voRaw >= 2 ** 31 ? voRaw - 2 ** 32 : voRaw;
52898
- const vo = (pos.getAttribute("vertRelTo") ?? "PARA") === "PARA" ? Math.max(0, voS) : voS;
52899
- const ho = num2(pos, "horzOffset");
52900
- const vrel = pos.getAttribute("vertRelTo") ?? "PARA";
52901
- const hrel = pos.getAttribute("horzRelTo") ?? "PARA";
52902
- const va = pos.getAttribute("vertAlign") ?? "TOP";
52903
- const ha = pos.getAttribute("horzAlign") ?? "LEFT";
52904
- const wrap = o.el.getAttribute("textWrap") ?? "TOP_AND_BOTTOM";
52905
- let y;
52906
- if (vrel === "PAPER") {
52907
- y = va === "BOTTOM" ? PH - h - vo - omB : va === "CENTER" ? (PH - h) / 2 + vo : vo + omT;
52908
- } else if (vrel === "PAGE") {
52909
- y = va === "BOTTOM" ? MT + BODY_H - h - vo : va === "CENTER" ? MT + (BODY_H - h) / 2 + vo : MT + vo;
52910
- } else if (wrap === "TOP_AND_BOTTOM") {
52911
- const lineV = anchorLineV ?? baseV;
52912
- const pushed = lineV - (omT + h + omB);
52913
- const below = laterLineH !== void 0 && vo + omT >= laterLineH;
52914
- const anchor = below ? lineV : stayLine !== false ? lineV - stayLine : pushed >= -100 ? pushed : paraStartV !== void 0 ? paraStartV : lineV;
52915
- y = oy + anchor + omT + vo;
52916
- } else {
52917
- y = oy + Math.max(baseV + vo, wrap === "SQUARE" && anchorLineV !== void 0 ? anchorLineV : -Infinity) + omT;
52918
- }
52919
- let x;
52920
- const omL = num2(om, "left"), omR = num2(om, "right");
52921
- if (hrel === "PAGE") {
52922
- x = ha === "RIGHT" ? ML + BODY_W - w - ho - omR : ha === "CENTER" ? ML + (BODY_W - w) / 2 + ho : ML + ho + omL;
52923
- } else if (hrel === "PAPER") {
52924
- x = (ha === "RIGHT" ? PW - w - ho - omR : ha === "CENTER" ? (PW - w) / 2 + ho : ho + omL) - (ctx.bodyDx?.(ctx.page) ?? 0);
52925
- } else {
52926
- x = ha === "RIGHT" ? ox + areaW - w - ho - omR : ha === "CENTER" ? ox + (areaW - w) / 2 + ho : ox + ho + omL;
52927
- }
52928
- return { x, y };
52929
- }
52930
52946
  function drawObject(o, x, y, baseV, areaW, ctx, depth) {
52931
52947
  if (!o.inline && depth === 0 && ctx.paintJobs) {
52932
52948
  const wrap = o.el.getAttribute("textWrap");
@@ -52953,8 +52969,8 @@ function drawObject(o, x, y, baseV, areaW, ctx, depth) {
52953
52969
  x = ox;
52954
52970
  y = oy;
52955
52971
  }
52956
- if (o.tag === "tbl") drawTable(o.el, x, y, ctx, depth + 1);
52957
- else if (o.tag === "pic") drawPic(o.el, x, y, ctx);
52972
+ if (o.tag === "tbl") ctx.draw.table(o.el, x, y, ctx, depth + 1);
52973
+ else if (o.tag === "pic") ctx.draw.pic(o.el, x, y, ctx);
52958
52974
  else if (o.tag === "container") {
52959
52975
  if (drawGroupByMatrix(o, x, y, baseV, areaW, ctx, depth)) return;
52960
52976
  for (const ch of elements(o.el)) {
@@ -53010,7 +53026,7 @@ function drawGroupByMatrix(o, x, y, baseV, areaW, ctx, depth) {
53010
53026
  ctx.regionRotations.push(m);
53011
53027
  emit(ctx, `<g transform="matrix(${m.slice(0, 4).map((v) => Math.round(v * 1e6) / 1e6).join(" ")} ${pt2(m[4])} ${pt2(m[5])})">`);
53012
53028
  const sub = { el: leaf, tag, index: 0, inline: true, width: w, height: h, omL: 0, omR: 0 };
53013
- if (tag === "pic") drawPicFrame(leaf, 0, 0, w, h, "", ctx);
53029
+ if (tag === "pic") ctx.draw.picFrame(leaf, 0, 0, w, h, "", ctx);
53014
53030
  else if (SHAPE_TAGS.has(tag)) drawShape(sub, 0, 0, ctx, depth + 1, [Math.hypot(m[0], m[1]) || 1, Math.hypot(m[2], m[3]) || 1]);
53015
53031
  else drawObject(sub, 0, 0, baseV, areaW, ctx, depth + 1);
53016
53032
  emit(ctx, "</g>");
@@ -53058,6 +53074,8 @@ function drawShape(o, x, y, ctx, depth, groupScale) {
53058
53074
  ctx.parentStack.pop();
53059
53075
  emit(ctx, "</g>");
53060
53076
  }
53077
+
53078
+ // src/render/svg-render.ts
53061
53079
  function edgeLine(x1, y1, x2, y2, e) {
53062
53080
  const dash = /DASH|DOT/.test(e.type) ? ` stroke-dasharray="${e.type.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
53063
53081
  return `<line x1="${pt2(x1)}" y1="${pt2(y1)}" x2="${pt2(x2)}" y2="${pt2(y2)}" stroke="${escapeXml7(e.color)}" stroke-width="${e.widthPt.toFixed(2)}"${dash}/>`;
@@ -53672,6 +53690,7 @@ function drawPageNumbers(root, paraPages, ctx) {
53672
53690
  }
53673
53691
  function renderSectionRoots(sections, input) {
53674
53692
  const ctxBase = {
53693
+ draw: { table: drawTable, pic: drawPic, picFrame: drawPicFrame },
53675
53694
  styles: input.styles,
53676
53695
  images: input.images,
53677
53696
  defs: [],
@@ -54830,7 +54849,7 @@ function scriptsOff(r, off) {
54830
54849
  }
54831
54850
  async function parseImage(buffer, options) {
54832
54851
  try {
54833
- const { parseImageDocument } = await import("./image-ocr-T72HMX2W.js");
54852
+ const { parseImageDocument } = await import("./image-ocr-KE3RUS3R.js");
54834
54853
  const { blocks, warnings, lines } = await parseImageDocument(buffer, options);
54835
54854
  stripScriptTags({ blocks });
54836
54855
  return {
@@ -54894,7 +54913,7 @@ async function parseHwp(buffer, options) {
54894
54913
  async function parsePdf(buffer, options) {
54895
54914
  let parsePdfDocument;
54896
54915
  try {
54897
- const mod = await import("./parser-E6BG3ECD.js");
54916
+ const mod = await import("./parser-WBKVRDPV.js");
54898
54917
  parsePdfDocument = mod.parsePdfDocument;
54899
54918
  } catch {
54900
54919
  return {