kordoc 3.3.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  sanitizeHref,
18
18
  stripDtd,
19
19
  toArrayBuffer
20
- } from "./chunk-ESBGMBRF.js";
20
+ } from "./chunk-ZPLRG2SJ.js";
21
21
  import {
22
22
  parsePageRange
23
23
  } from "./chunk-GE43BE46.js";
@@ -22247,14 +22247,7 @@ async function patchHwp(original, editedMarkdown, options) {
22247
22247
  const editedUnits = splitMarkdownUnits(editedMarkdown);
22248
22248
  const pairs = alignUnits(origUnits.map((u) => u.raw), editedUnits.map((u) => u.raw));
22249
22249
  const paraMap = resolveParaMappings(origBlocks, scans);
22250
- const scanTables = scans.flatMap((s) => s.tables);
22251
- const obTableOrdinals = /* @__PURE__ */ new Map();
22252
- {
22253
- let ordinal = 0;
22254
- for (let i = 0; i < origBlocks.length; i++) {
22255
- if (origBlocks[i].type === "table" && origBlocks[i].table) obTableOrdinals.set(i, ordinal++);
22256
- }
22257
- }
22250
+ const tableMap = resolveTableMappings(origBlocks, scans.flatMap((s) => s.tables));
22258
22251
  for (const [oi, ei] of pairs) {
22259
22252
  if (oi !== null && ei !== null) {
22260
22253
  const orig = origUnits[oi];
@@ -22264,8 +22257,7 @@ async function patchHwp(original, editedMarkdown, options) {
22264
22257
  origBlocks,
22265
22258
  paraMap,
22266
22259
  scans,
22267
- scanTables,
22268
- obTableOrdinals,
22260
+ tableMap,
22269
22261
  skipped
22270
22262
  });
22271
22263
  } else if (oi !== null) {
@@ -22350,6 +22342,46 @@ function resolveParaMappings(blocks, scans) {
22350
22342
  }
22351
22343
  return result;
22352
22344
  }
22345
+ function resolveTableMappings(blocks, scanTables) {
22346
+ const result = /* @__PURE__ */ new Map();
22347
+ let si = 0;
22348
+ for (let i = 0; i < blocks.length; i++) {
22349
+ const table = blocks[i].table;
22350
+ if (blocks[i].type !== "table" || !table) continue;
22351
+ const cands = [];
22352
+ for (let k = si; k < scanTables.length; k++) {
22353
+ if (scanTables[k].rows === table.rows && scanTables[k].cols === table.cols) cands.push(k);
22354
+ }
22355
+ if (cands.length === 0) continue;
22356
+ let pick = cands[0];
22357
+ if (cands.length > 1) {
22358
+ let best = tableContentScore(table, scanTables[cands[0]]);
22359
+ for (let ci = 1; ci < cands.length; ci++) {
22360
+ const sc = tableContentScore(table, scanTables[cands[ci]]);
22361
+ if (sc > best) {
22362
+ best = sc;
22363
+ pick = cands[ci];
22364
+ }
22365
+ }
22366
+ }
22367
+ result.set(i, scanTables[pick]);
22368
+ si = pick + 1;
22369
+ }
22370
+ return result;
22371
+ }
22372
+ function tableContentScore(irTable, scanTable) {
22373
+ let matched = 0;
22374
+ for (const [key, scanCell] of scanTable.cells) {
22375
+ const comma = key.indexOf(",");
22376
+ const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
22377
+ const irCell = irTable.cells[r]?.[c];
22378
+ if (!irCell) continue;
22379
+ const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
22380
+ const b = normForMatch(stripCellTokens(irCell.text));
22381
+ if (a && a === b) matched++;
22382
+ }
22383
+ return matched;
22384
+ }
22353
22385
  function handleModified(orig, edited, ctx) {
22354
22386
  const block = ctx.origBlocks[orig.blockIdx];
22355
22387
  const skip = (reason) => {
@@ -22362,12 +22394,10 @@ function handleModified(orig, edited, ctx) {
22362
22394
  if (orig.fragment) return skip("\uBB38\uB2E8 \uBD84\uC808(\uAC15\uC81C \uC904\uBC14\uAFC8/\uBCD1\uD569 \uC720\uB2DB) \u2014 \uBD80\uBD84 \uC218\uC815\uC740 \uBBF8\uC9C0\uC6D0 (v1)");
22363
22395
  if (block.type === "table" && block.table) {
22364
22396
  if (orig.kind !== edited.kind) return skip("\uD45C \u2194 \uBE44\uD45C \uBCC0\uACBD\uC740 \uBBF8\uC9C0\uC6D0 (\uD45C \uAD6C\uC870 \uBCC0\uACBD)");
22365
- if (ctx.obTableOrdinals.size !== ctx.scanTables.length) return skip("\uD45C \uAC1C\uC218 \uBD88\uC77C\uCE58 \u2014 \uC18C\uC2A4\uB9F5 \uC2E0\uB8B0 \uBD88\uAC00");
22366
- const ordinal = ctx.obTableOrdinals.get(orig.blockIdx);
22367
- const scanTable = ordinal !== void 0 ? ctx.scanTables[ordinal] : void 0;
22368
- if (!scanTable) return skip("\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
22397
+ const scanTable = ctx.tableMap.get(orig.blockIdx);
22398
+ if (!scanTable) return skip("\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 \u2014 \uD45C \uAC1C\uC218/\uAD6C\uC870 \uBD88\uC77C\uCE58\uB85C \uC2E0\uB8B0 \uBD88\uAC00");
22369
22399
  if (orig.kind === "gfm-table") return patchGfmCells(scanTable, orig, edited, ctx, skip);
22370
- if (orig.kind === "html-table") return skip("HTML \uD45C(\uBCD1\uD569/\uC904\uBC14\uAFC8 \uC140) \uC218\uC815\uC740 HWP5 \uBBF8\uC9C0\uC6D0 (v1)");
22400
+ if (orig.kind === "html-table") return patchHtmlCells5(block.table, scanTable, orig, edited, ctx, skip);
22371
22401
  return patchTextChunk5(block.table, scanTable, orig, edited, ctx, skip);
22372
22402
  }
22373
22403
  if ((block.type === "paragraph" || block.type === "heading") && orig.kind === "text" && edited.kind === "text") {
@@ -22424,35 +22454,87 @@ function patchGfmCells(scanTable, orig, edited, ctx, skip) {
22424
22454
  ctx.skipped.push({ reason, before: summarize(origRows[r][c]), after: summarize(editedRows[r][c]) });
22425
22455
  return 0;
22426
22456
  };
22427
- const before = gfmCellToPlain(origRows[r][c]);
22428
- const after = gfmCellToPlain(editedRows[r][c]);
22429
- if (before === null || after === null) {
22430
- cellSkip("\uC11C\uC2DD/\uB9C1\uD06C/\uC774\uBBF8\uC9C0 \uD3EC\uD568 \uC140 \uC218\uC815\uC740 \uBBF8\uC9C0\uC6D0 (v1)");
22431
- continue;
22432
- }
22433
- if (after.includes("\n")) {
22434
- cellSkip("\uC140 \uB0B4 \uC904\uBC14\uAFC8 \uCD94\uAC00\uB294 \uBBF8\uC9C0\uC6D0 (v1)");
22435
- continue;
22436
- }
22437
22457
  const cell = scanTable.cells.get(`${r},${c}`);
22438
22458
  if (!cell) {
22439
22459
  cellSkip("\uBCD1\uD569 \uC601\uC5ED \uC140 \u2014 \uC575\uCEE4 \uC140\uC774 \uC544\uB2C8\uBBC0\uB85C \uBBF8\uC9C0\uC6D0");
22440
22460
  continue;
22441
22461
  }
22442
- if (cell.paras.length !== 1) {
22443
- cellSkip("\uBCF5\uC218 \uBB38\uB2E8 \uC140 \uC218\uC815\uC740 \uBBF8\uC9C0\uC6D0 (v1)");
22462
+ const beforeParts = origRows[r][c].split(/<br\s*\/?>/i);
22463
+ const afterParts = editedRows[r][c].split(/<br\s*\/?>/i);
22464
+ if (beforeParts.length !== cell.paras.length || afterParts.length !== cell.paras.length) {
22465
+ cellSkip("\uC140 \uBB38\uB2E8 \uC218 \uBCC0\uACBD \u2014 \uBBF8\uC9C0\uC6D0 (\uBB38\uB2E8 \uCD94\uAC00/\uC0AD\uC81C)");
22444
22466
  continue;
22445
22467
  }
22446
- const para = cell.paras[0];
22447
- if (normForMatch(para.rawText) !== normForMatch(before)) {
22448
- cellSkip("\uC140 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58 \u2014 \uC18C\uC2A4\uB9F5 \uC2E0\uB8B0 \uBD88\uAC00");
22449
- continue;
22468
+ for (let k = 0; k < cell.paras.length; k++) {
22469
+ const before = gfmCellToPlain(beforeParts[k]);
22470
+ const after = gfmCellToPlain(afterParts[k]);
22471
+ if (before === null || after === null) {
22472
+ cellSkip("\uC11C\uC2DD/\uB9C1\uD06C/\uC774\uBBF8\uC9C0 \uD3EC\uD568 \uC140 \uC218\uC815\uC740 \uBBF8\uC9C0\uC6D0 (v1)");
22473
+ break;
22474
+ }
22475
+ if (before === after) continue;
22476
+ if (after.includes("\n")) {
22477
+ cellSkip("\uC140 \uB0B4 \uC904\uBC14\uAFC8 \uCD94\uAC00\uB294 \uBBF8\uC9C0\uC6D0 (v1)");
22478
+ break;
22479
+ }
22480
+ const para = cell.paras[k];
22481
+ if (normForMatch(para.rawText) !== normForMatch(before)) {
22482
+ cellSkip("\uC140 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58 \u2014 \uC18C\uC2A4\uB9F5 \uC2E0\uB8B0 \uBD88\uAC00");
22483
+ break;
22484
+ }
22485
+ if (sanitizeText(after) !== after) {
22486
+ cellSkip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uBBF8\uC9C0\uC6D0");
22487
+ break;
22488
+ }
22489
+ applied += stageParaPatch(ctx.scans[para.sectionIndex], para, after, cellSkip);
22450
22490
  }
22451
- if (sanitizeText(after) !== after) {
22452
- cellSkip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uBBF8\uC9C0\uC6D0");
22491
+ }
22492
+ }
22493
+ return applied;
22494
+ }
22495
+ function extractImgTags5(inner) {
22496
+ return (inner.match(/<img\s(?:"[^"]*"|'[^']*'|[^>"'])*?>/gi) || []).join(" ");
22497
+ }
22498
+ function patchHtmlCells5(table, scanTable, orig, edited, ctx, skip) {
22499
+ if (replicateTableToHtml(table) !== orig.raw) return skip("\uD45C \uC88C\uD45C \uC7AC\uD604 \uBD88\uC77C\uCE58 \u2014 \uB9E4\uD551 \uC2E0\uB8B0 \uBD88\uAC00");
22500
+ const replica = replicateHtmlTable(table);
22501
+ const origRows = parseHtmlTable(orig.raw);
22502
+ if (!origRows || origRows.length !== replica.length || origRows.some((r, i) => r.cells.length !== replica[i].cells.length || r.cells.some((c, j) => c.inner !== replica[i].cells[j].inner))) {
22503
+ return skip("\uC140 \uACBD\uACC4 \uBAA8\uD638 (\uB9AC\uD130\uB7F4 \uD0DC\uADF8 \uC758\uC2EC) \u2014 \uB9E4\uD551 \uC2E0\uB8B0 \uBD88\uAC00");
22504
+ }
22505
+ const editedRows = parseHtmlTable(edited.raw);
22506
+ if (!editedRows) return skip("\uD3B8\uC9D1\uB41C HTML \uD45C \uD30C\uC2F1 \uC2E4\uD328");
22507
+ if (editedRows.length !== replica.length) return skip("\uD45C \uD589 \uCD94\uAC00/\uC0AD\uC81C\uB294 \uBBF8\uC9C0\uC6D0 (\uD45C \uAD6C\uC870 \uBCC0\uACBD)");
22508
+ let applied = 0;
22509
+ for (let r = 0; r < replica.length; r++) {
22510
+ if (editedRows[r].cells.length !== replica[r].cells.length) {
22511
+ skip(`\uD45C ${r + 1}\uD589 \uC140 \uC218 \uBCC0\uACBD\uC740 \uBBF8\uC9C0\uC6D0`);
22512
+ continue;
22513
+ }
22514
+ for (let c = 0; c < replica[r].cells.length; c++) {
22515
+ const oc = replica[r].cells[c];
22516
+ const ec = editedRows[r].cells[c];
22517
+ if (oc.colSpan !== ec.colSpan || oc.rowSpan !== ec.rowSpan) {
22518
+ skip("\uC140 \uBCD1\uD569(colspan/rowspan) \uBCC0\uACBD\uC740 \uBBF8\uC9C0\uC6D0");
22453
22519
  continue;
22454
22520
  }
22455
- applied += stageParaPatch(ctx.scans[para.sectionIndex], para, after, cellSkip);
22521
+ if (oc.inner === ec.inner) continue;
22522
+ const origContent = htmlCellInnerToLines(oc.inner);
22523
+ const editedContent = htmlCellInnerToLines(ec.inner);
22524
+ if (origContent.hadNonText || editedContent.hadNonText) {
22525
+ if (extractImgTags5(oc.inner) !== extractImgTags5(ec.inner)) {
22526
+ skip("\uC140 \uB0B4 \uC774\uBBF8\uC9C0 \uBCC0\uACBD\uC740 \uBBF8\uC9C0\uC6D0");
22527
+ continue;
22528
+ }
22529
+ if (extractTopLevelTables(oc.inner).join("\n") !== extractTopLevelTables(ec.inner).join("\n")) {
22530
+ skip("\uC140 \uB0B4 \uC911\uCCA9\uD45C \uC218\uC815\uC740 HWP5 \uBBF8\uC9C0\uC6D0 (v1)");
22531
+ continue;
22532
+ }
22533
+ }
22534
+ if (origContent.lines.join("\n") !== editedContent.lines.join("\n")) {
22535
+ const newLines = editedContent.lines.map((l) => unescapeGfm(l));
22536
+ applied += applyCellEdit5(table, scanTable, oc.gridR, oc.gridC, newLines, ctx, oc.inner, ec.inner, origContent.lines.length);
22537
+ }
22456
22538
  }
22457
22539
  }
22458
22540
  return applied;
@@ -22544,15 +22626,103 @@ function gfmCellToPlain(md2) {
22544
22626
  let t = md2.trim();
22545
22627
  const bold = t.match(/^\*\*([\s\S]+)\*\*$/);
22546
22628
  if (bold) t = bold[1];
22547
- if (/[*`]|!\[|\]\(|<(?!br\s*\/?>)/i.test(t)) return null;
22629
+ if (/[*`]|!\[|\]\(/.test(t)) return null;
22630
+ if (/<(?!br\s*\/?>)[a-zA-Z/]/i.test(t)) return null;
22548
22631
  return unescapeGfm(unescapeGfmCell(t));
22549
22632
  }
22550
- var PARA_BREAK = Buffer.from([13, 0]);
22633
+ function splitParaText(data) {
22634
+ const toks = [];
22635
+ let i = 0;
22636
+ while (i + 1 < data.length) {
22637
+ const ch = data.readUInt16LE(i);
22638
+ const start = i;
22639
+ i += 2;
22640
+ if (ch >= 32) {
22641
+ let units = 1;
22642
+ if (ch >= 55296 && ch <= 56319 && i + 1 < data.length) {
22643
+ const lo = data.readUInt16LE(i);
22644
+ if (lo >= 56320 && lo <= 57343) {
22645
+ i += 2;
22646
+ units = 2;
22647
+ }
22648
+ }
22649
+ toks.push({ start, end: i, units, plain: true, visible: true });
22650
+ continue;
22651
+ }
22652
+ switch (ch) {
22653
+ case 0:
22654
+ case 24:
22655
+ case 25:
22656
+ case 30:
22657
+ case 31:
22658
+ toks.push({ start, end: i, units: 1, plain: false, visible: true });
22659
+ break;
22660
+ case 9:
22661
+ if (i + 14 <= data.length) i += 14;
22662
+ toks.push({ start, end: i, units: 1, plain: false, visible: true });
22663
+ break;
22664
+ case 13:
22665
+ toks.push({ start, end: i, units: 1, plain: false, visible: false });
22666
+ break;
22667
+ case 10:
22668
+ if (i + 16 <= data.length && data.readUInt16LE(i) === 11) {
22669
+ i += 16;
22670
+ toks.push({ start, end: i, units: 1, plain: false, visible: false });
22671
+ } else {
22672
+ if (i + 14 <= data.length) i += 14;
22673
+ toks.push({ start, end: i, units: 1, plain: false, visible: true });
22674
+ }
22675
+ break;
22676
+ default: {
22677
+ const ext = isExtendedOnlyCtrlChar(ch);
22678
+ const inl = ch >= 4 && ch <= 9 || ch >= 19 && ch <= 20;
22679
+ if ((ext || inl) && i + 14 <= data.length) i += 14;
22680
+ toks.push({ start, end: i, units: 1, plain: false, visible: false });
22681
+ break;
22682
+ }
22683
+ }
22684
+ }
22685
+ if (i !== data.length) return null;
22686
+ let firstP = -1, lastP = -1;
22687
+ for (let k = 0; k < toks.length; k++) if (toks[k].plain) {
22688
+ if (firstP < 0) firstP = k;
22689
+ lastP = k;
22690
+ }
22691
+ if (firstP < 0) return null;
22692
+ for (let k = firstP; k <= lastP; k++) if (!toks[k].plain) return null;
22693
+ for (let k = 0; k < firstP; k++) if (toks[k].visible) return null;
22694
+ for (let k = lastP + 1; k < toks.length; k++) if (toks[k].visible) return null;
22695
+ const prefixEnd = toks[firstP].start;
22696
+ const coreEnd = toks[lastP].end;
22697
+ const prefixUnits = prefixEnd / 2;
22698
+ const suffixUnits = (data.length - coreEnd) / 2;
22699
+ return {
22700
+ prefix: data.subarray(0, prefixEnd),
22701
+ prefixUnits,
22702
+ core: data.subarray(prefixEnd, coreEnd).toString("utf16le"),
22703
+ suffix: data.subarray(coreEnd),
22704
+ suffixUnits
22705
+ };
22706
+ }
22707
+ function rebuildCharShape(csData, coreStartUnit) {
22708
+ const pairs = [];
22709
+ for (let o = 0; o + 8 <= csData.length; o += 8) pairs.push([csData.readUInt32LE(o), csData.readUInt32LE(o + 4)]);
22710
+ if (pairs.length === 0) return { buf: Buffer.from(csData.subarray(0, 8)), count: 1 };
22711
+ let coreId = pairs[0][1];
22712
+ for (const [p, id] of pairs) if (p <= coreStartUnit) coreId = id;
22713
+ const kept = pairs.filter(([p]) => p < coreStartUnit);
22714
+ if (kept.length === 0 || kept[kept.length - 1][1] !== coreId) kept.push([coreStartUnit, coreId]);
22715
+ const buf = Buffer.alloc(kept.length * 8);
22716
+ kept.forEach(([p, id], k) => {
22717
+ buf.writeUInt32LE(p >>> 0, k * 8);
22718
+ buf.writeUInt32LE(id >>> 0, k * 8 + 4);
22719
+ });
22720
+ return { buf, count: kept.length };
22721
+ }
22551
22722
  function stageParaPatch(scan, para, newPlain, skip) {
22552
22723
  if (!scan.safe) return skip("\uC139\uC158 \uB808\uCF54\uB4DC \uC7AC\uC9C1\uB82C\uD654 \uBD88\uC77C\uCE58 \u2014 \uC548\uC804\uC744 \uC704\uD574 \uC774 \uC139\uC158\uC740 \uBBF8\uC9C0\uC6D0");
22553
22724
  if (para.textIdx === -1) return skip("\uBE48 \uBB38\uB2E8 \uD14D\uC2A4\uD2B8 \uCD94\uAC00\uB294 \uBBF8\uC9C0\uC6D0 (v1)");
22554
22725
  if (para.textIdx === -2) return skip("\uBCF5\uC218 PARA_TEXT \uB808\uCF54\uB4DC \uBB38\uB2E8 \u2014 \uBBF8\uC9C0\uC6D0 (v1)");
22555
- if (para.ctrlMask !== 0) return skip("\uCEE8\uD2B8\uB864 \uBB38\uC790 \uD3EC\uD568 \uBB38\uB2E8(\uD0ED/\uAC1C\uCCB4/\uD544\uB4DC/\uD2B9\uC218\uACF5\uBC31) \u2014 \uBBF8\uC9C0\uC6D0 (v1)");
22556
22726
  if (para.rangeTagCount > 0) return skip("\uBC94\uC704 \uD0DC\uADF8(\uD615\uAD11\uD39C/\uAD50\uC815\uBD80\uD638) \uBB38\uB2E8 \u2014 \uBBF8\uC9C0\uC6D0 (v1)");
22557
22727
  if (para.charShapeIdx < 0 || para.lineSegIdx < 0) return skip("\uBB38\uB2E8 \uB808\uCF54\uB4DC \uAD6C\uC131 \uBE44\uC815\uD615 \u2014 \uBBF8\uC9C0\uC6D0");
22558
22728
  if (scan.repl.has(para.headerIdx)) return skip("\uB3D9\uC77C \uBB38\uB2E8 \uC911\uBCF5 \uC218\uC815 \u2014 \uCCAB \uC218\uC815\uB9CC \uC801\uC6A9");
@@ -22561,36 +22731,25 @@ function stageParaPatch(scan, para, newPlain, skip) {
22561
22731
  const headerRec = records[para.headerIdx];
22562
22732
  const textRec = records[para.textIdx];
22563
22733
  const charShapeRec = records[para.charShapeIdx];
22564
- const lineSegRec = records[para.lineSegIdx];
22565
- if (charShapeRec.data.length < 8 || lineSegRec.data.length < 36) {
22566
- return skip("CHAR_SHAPE/LINE_SEG \uB808\uCF54\uB4DC \uBE44\uC815\uD615 \u2014 \uBBF8\uC9C0\uC6D0");
22734
+ if (charShapeRec.data.length < 8) {
22735
+ return skip("CHAR_SHAPE \uB808\uCF54\uB4DC \uBE44\uC815\uD615 \u2014 \uBBF8\uC9C0\uC6D0");
22736
+ }
22737
+ const seg = splitParaText(textRec.data);
22738
+ if (!seg) {
22739
+ return skip(para.ctrlMask !== 0 ? "\uCEE8\uD2B8\uB864 \uBB38\uC790(\uD0ED/\uD544\uB4DC/\uD2B9\uC218\uACF5\uBC31 \uB4F1 \uD14D\uC2A4\uD2B8 \uC911\uAC04) \uD3EC\uD568 \uBB38\uB2E8 \u2014 \uBBF8\uC9C0\uC6D0 (v1)" : "PARA_TEXT \uC7AC\uAD6C\uC131 \uBD88\uC77C\uCE58 \u2014 \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
22567
22740
  }
22568
- const hadBreak = textRec.data.length >= 2 && textRec.data.readUInt16LE(textRec.data.length - 2) === 13;
22569
- const expect = hadBreak ? Buffer.concat([Buffer.from(para.rawText, "utf16le"), PARA_BREAK]) : Buffer.from(para.rawText, "utf16le");
22570
- if (!expect.equals(textRec.data)) return skip("PARA_TEXT \uC7AC\uAD6C\uC131 \uBD88\uC77C\uCE58 \u2014 \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
22741
+ if (seg.core !== para.rawText) return skip("PARA_TEXT \uC7AC\uAD6C\uC131 \uBD88\uC77C\uCE58 \u2014 \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
22571
22742
  const lead = para.rawText.match(/^\s*/)[0];
22572
22743
  const trail = para.rawText.match(/\s*$/)[0];
22573
22744
  const newRaw = para.rawText.trim() === para.rawText ? newPlain : lead + newPlain + trail;
22574
- const newText = hadBreak ? Buffer.concat([Buffer.from(newRaw, "utf16le"), PARA_BREAK]) : Buffer.from(newRaw, "utf16le");
22745
+ const newText = Buffer.concat([seg.prefix, Buffer.from(newRaw, "utf16le"), seg.suffix]);
22575
22746
  scan.repl.set(para.textIdx, newText);
22576
22747
  const newHeader = Buffer.from(headerRec.data);
22577
- const nChars = newRaw.length + (hadBreak ? 1 : 0);
22748
+ const nChars = seg.prefixUnits + newRaw.length + seg.suffixUnits;
22578
22749
  newHeader.writeUInt32LE((para.nCharsRaw & 2147483648 | nChars) >>> 0, 0);
22579
- if (charShapeRec.data.length > 8) {
22580
- newHeader.writeUInt16LE(1, 12);
22581
- scan.repl.set(para.charShapeIdx, Buffer.from(charShapeRec.data.subarray(0, 8)));
22582
- }
22583
- const csData = scan.repl.get(para.charShapeIdx) ?? Buffer.from(charShapeRec.data);
22584
- if (csData.readUInt32LE(0) !== 0) {
22585
- csData.writeUInt32LE(0, 0);
22586
- scan.repl.set(para.charShapeIdx, csData);
22587
- }
22588
- if (lineSegRec.data.length > 36 || lineSegRec.data.readUInt32LE(0) !== 0) {
22589
- const seg = Buffer.from(lineSegRec.data.subarray(0, 36));
22590
- seg.writeUInt32LE(0, 0);
22591
- newHeader.writeUInt16LE(1, 16);
22592
- scan.repl.set(para.lineSegIdx, seg);
22593
- }
22750
+ const cs = rebuildCharShape(charShapeRec.data, seg.prefixUnits);
22751
+ scan.repl.set(para.charShapeIdx, cs.buf);
22752
+ newHeader.writeUInt16LE(cs.count, 12);
22594
22753
  scan.repl.set(para.headerIdx, newHeader);
22595
22754
  return 1;
22596
22755
  }
@@ -23179,7 +23338,7 @@ async function parseHwp(buffer, options) {
23179
23338
  async function parsePdf(buffer, options) {
23180
23339
  let parsePdfDocument;
23181
23340
  try {
23182
- const mod = await import("./parser-FLE2ZPAW.js");
23341
+ const mod = await import("./parser-VZL3MK5X.js");
23183
23342
  parsePdfDocument = mod.parsePdfDocument;
23184
23343
  } catch {
23185
23344
  return {