kordoc 3.5.0 → 3.5.1

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 (83) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +590 -590
  3. package/dist/{-GKNSTVEZ.js → -BNJMPTQ2.js} +5 -5
  4. package/dist/{chunk-X34YWRL5.cjs → chunk-DCZVOIEO.cjs} +1 -1
  5. package/dist/chunk-DCZVOIEO.cjs.map +1 -0
  6. package/dist/{chunk-AIQ3ISQU.js → chunk-GE43BE46.js} +1 -1
  7. package/dist/chunk-GE43BE46.js.map +1 -0
  8. package/dist/{chunk-GTCJQANY.js → chunk-GMPDZD7Q.js} +44 -36
  9. package/dist/chunk-GMPDZD7Q.js.map +1 -0
  10. package/dist/chunk-GS7T56RP.cjs.map +1 -1
  11. package/dist/{chunk-A4LSWJEC.js → chunk-IKAXUVSU.js} +16 -2
  12. package/dist/chunk-IKAXUVSU.js.map +1 -0
  13. package/dist/{chunk-CFQLK3LM.js → chunk-MEPHGCPQ.js} +1 -1
  14. package/dist/chunk-MEPHGCPQ.js.map +1 -0
  15. package/dist/{chunk-3TBUDJDE.js → chunk-MOL7MDBG.js} +1 -1
  16. package/dist/chunk-MOL7MDBG.js.map +1 -0
  17. package/dist/{chunk-AHDNELBR.js → chunk-OXOPDVNV.js} +16 -2
  18. package/dist/chunk-OXOPDVNV.js.map +1 -0
  19. package/dist/{chunk-4JLD2IT7.cjs → chunk-RWSGBXSA.cjs} +25 -11
  20. package/dist/chunk-RWSGBXSA.cjs.map +1 -0
  21. package/dist/cli.js +8 -8
  22. package/dist/cli.js.map +1 -1
  23. package/dist/{detect-NTR2FUEG.js → detect-RI2MQ33K.js} +2 -2
  24. package/dist/{formula-ZYUDQHD3.cjs → formula-5NKVS2LR.cjs} +1 -1
  25. package/dist/formula-5NKVS2LR.cjs.map +1 -0
  26. package/dist/{formula-KOQV353G.js → formula-JCNF43NE.js} +1 -1
  27. package/dist/formula-JCNF43NE.js.map +1 -0
  28. package/dist/{formula-MEDGYQXS.js → formula-RXVSQPXI.js} +1 -1
  29. package/dist/formula-RXVSQPXI.js.map +1 -0
  30. package/dist/index.cjs +181 -173
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.js +42 -34
  33. package/dist/index.js.map +1 -1
  34. package/dist/mcp.js +6 -6
  35. package/dist/mcp.js.map +1 -1
  36. package/dist/page-range-737B4EZW.js +8 -0
  37. package/dist/page-range-LNMXJU6W.js +7 -0
  38. package/dist/page-range-P7SDW6LR.cjs +8 -0
  39. package/dist/page-range-P7SDW6LR.cjs.map +1 -0
  40. package/dist/{parser-LBLPN3KY.js → parser-GHZMDUGG.js} +5 -5
  41. package/dist/parser-GHZMDUGG.js.map +1 -0
  42. package/dist/{parser-LMBDB7RM.js → parser-XXQAMYGV.js} +5 -5
  43. package/dist/parser-XXQAMYGV.js.map +1 -0
  44. package/dist/{parser-25ISHR7Q.cjs → parser-ZLFOUVR4.cjs} +18 -18
  45. package/dist/parser-ZLFOUVR4.cjs.map +1 -0
  46. package/dist/{provider-H4WWSPOV.js → provider-4ZJKV3DC.js} +1 -1
  47. package/dist/provider-4ZJKV3DC.js.map +1 -0
  48. package/dist/{provider-7H4CPZYS.js → provider-AKROB7WQ.js} +1 -1
  49. package/dist/provider-AKROB7WQ.js.map +1 -0
  50. package/dist/{provider-5K7O3Z2O.cjs → provider-G4C2V2PD.cjs} +1 -1
  51. package/dist/provider-G4C2V2PD.cjs.map +1 -0
  52. package/dist/{setup-QSJ2INNS.js → setup-57FB3LSP.js} +1 -1
  53. package/dist/setup-57FB3LSP.js.map +1 -0
  54. package/dist/{watch-77CYT54V.js → watch-IN3YN72W.js} +5 -5
  55. package/dist/watch-IN3YN72W.js.map +1 -0
  56. package/package.json +98 -98
  57. package/dist/chunk-3TBUDJDE.js.map +0 -1
  58. package/dist/chunk-4JLD2IT7.cjs.map +0 -1
  59. package/dist/chunk-A4LSWJEC.js.map +0 -1
  60. package/dist/chunk-AHDNELBR.js.map +0 -1
  61. package/dist/chunk-AIQ3ISQU.js.map +0 -1
  62. package/dist/chunk-CFQLK3LM.js.map +0 -1
  63. package/dist/chunk-GTCJQANY.js.map +0 -1
  64. package/dist/chunk-X34YWRL5.cjs.map +0 -1
  65. package/dist/formula-KOQV353G.js.map +0 -1
  66. package/dist/formula-MEDGYQXS.js.map +0 -1
  67. package/dist/formula-ZYUDQHD3.cjs.map +0 -1
  68. package/dist/page-range-CIRRJPXJ.js +0 -7
  69. package/dist/page-range-OF5I4PQY.js +0 -8
  70. package/dist/page-range-TPIRSA3J.cjs +0 -8
  71. package/dist/page-range-TPIRSA3J.cjs.map +0 -1
  72. package/dist/parser-25ISHR7Q.cjs.map +0 -1
  73. package/dist/parser-LBLPN3KY.js.map +0 -1
  74. package/dist/parser-LMBDB7RM.js.map +0 -1
  75. package/dist/provider-5K7O3Z2O.cjs.map +0 -1
  76. package/dist/provider-7H4CPZYS.js.map +0 -1
  77. package/dist/provider-H4WWSPOV.js.map +0 -1
  78. package/dist/setup-QSJ2INNS.js.map +0 -1
  79. package/dist/watch-77CYT54V.js.map +0 -1
  80. /package/dist/{-GKNSTVEZ.js.map → -BNJMPTQ2.js.map} +0 -0
  81. /package/dist/{detect-NTR2FUEG.js.map → detect-RI2MQ33K.js.map} +0 -0
  82. /package/dist/{page-range-CIRRJPXJ.js.map → page-range-737B4EZW.js.map} +0 -0
  83. /package/dist/{page-range-OF5I4PQY.js.map → page-range-LNMXJU6W.js.map} +0 -0
@@ -33,7 +33,7 @@ import {
33
33
  patchHwpxBlocks,
34
34
  renderHtml,
35
35
  scanSectionXml
36
- } from "./chunk-GTCJQANY.js";
36
+ } from "./chunk-GMPDZD7Q.js";
37
37
  import {
38
38
  detectFormat,
39
39
  detectOle2Format,
@@ -42,12 +42,12 @@ import {
42
42
  isOldHwpFile,
43
43
  isPdfFile,
44
44
  isZipFile
45
- } from "./chunk-CFQLK3LM.js";
45
+ } from "./chunk-MEPHGCPQ.js";
46
46
  import {
47
47
  VERSION,
48
48
  blocksToMarkdown
49
- } from "./chunk-A4LSWJEC.js";
50
- import "./chunk-3TBUDJDE.js";
49
+ } from "./chunk-IKAXUVSU.js";
50
+ import "./chunk-MOL7MDBG.js";
51
51
  export {
52
52
  HwpxSession,
53
53
  PRESET_ALIAS,
@@ -92,4 +92,4 @@ export {
92
92
  renderHtml,
93
93
  scanSectionXml
94
94
  };
95
- //# sourceMappingURL=-GKNSTVEZ.js.map
95
+ //# sourceMappingURL=-BNJMPTQ2.js.map
@@ -30,4 +30,4 @@ function parsePageRange(spec, maxPages) {
30
30
 
31
31
 
32
32
  exports.parsePageRange = parsePageRange;
33
- //# sourceMappingURL=chunk-X34YWRL5.cjs.map
33
+ //# sourceMappingURL=chunk-DCZVOIEO.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/chris_gomdori/workspace/kordoc/dist/chunk-DCZVOIEO.cjs","../src/page-range.ts"],"names":[],"mappings":"AAAA;ACSO,SAAS,cAAA,CAAe,IAAA,EAAyB,QAAA,EAA+B;AACrF,EAAA,MAAM,OAAA,kBAAS,IAAI,GAAA,CAAY,CAAA;AAC/B,EAAA,GAAA,CAAI,SAAA,GAAY,CAAA,EAAG,OAAO,MAAA;AAE1B,EAAA,GAAA,CAAI,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,EAAG;AACvB,IAAA,IAAA,CAAA,MAAW,EAAA,GAAK,IAAA,EAAM;AACpB,MAAA,MAAM,KAAA,EAAO,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA;AACzB,MAAA,GAAA,CAAI,KAAA,GAAQ,EAAA,GAAK,KAAA,GAAQ,QAAA,EAAU,MAAA,CAAO,GAAA,CAAI,IAAI,CAAA;AAAA,IACpD;AACA,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,GAAA,CAAI,OAAO,KAAA,IAAS,SAAA,GAAY,IAAA,CAAK,IAAA,CAAK,EAAA,IAAM,EAAA,EAAI,OAAO,MAAA;AAE3D,EAAA,MAAM,MAAA,EAAQ,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA;AAC5B,EAAA,IAAA,CAAA,MAAW,KAAA,GAAQ,KAAA,EAAO;AACxB,IAAA,MAAM,QAAA,EAAU,IAAA,CAAK,IAAA,CAAK,CAAA;AAC1B,IAAA,GAAA,CAAI,CAAC,OAAA,EAAS,QAAA;AAEd,IAAA,MAAM,WAAA,EAAa,OAAA,CAAQ,KAAA,CAAM,qBAAqB,CAAA;AACtD,IAAA,GAAA,CAAI,UAAA,EAAY;AACd,MAAA,MAAM,MAAA,EAAQ,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,QAAA,CAAS,UAAA,CAAW,CAAC,CAAA,EAAG,EAAE,CAAC,CAAA;AACrD,MAAA,MAAM,IAAA,EAAM,IAAA,CAAK,GAAA,CAAI,QAAA,EAAU,QAAA,CAAS,UAAA,CAAW,CAAC,CAAA,EAAG,EAAE,CAAC,CAAA;AAC1D,MAAA,IAAA,CAAA,IAAS,EAAA,EAAI,KAAA,EAAO,EAAA,GAAK,GAAA,EAAK,CAAA,EAAA,EAAK,MAAA,CAAO,GAAA,CAAI,CAAC,CAAA;AAAA,IACjD,EAAA,KAAO;AACL,MAAA,MAAM,KAAA,EAAO,QAAA,CAAS,OAAA,EAAS,EAAE,CAAA;AACjC,MAAA,GAAA,CAAI,CAAC,KAAA,CAAM,IAAI,EAAA,GAAK,KAAA,GAAQ,EAAA,GAAK,KAAA,GAAQ,QAAA,EAAU,MAAA,CAAO,GAAA,CAAI,IAAI,CAAA;AAAA,IACpE;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT;ADZA;AACA;AACE;AACF,wCAAC","file":"/Users/chris_gomdori/workspace/kordoc/dist/chunk-DCZVOIEO.cjs","sourcesContent":[null,"/** 페이지/섹션 범위 파싱 유틸리티 */\n\n/**\n * 페이지 범위 지정을 1-based Set<number>로 변환.\n *\n * @param spec - [1,2,3] 또는 \"1-3\" 또는 \"1,3,5-7\"\n * @param maxPages - 최대 페이지 수 (클램핑 상한)\n * @returns 1-based 페이지 번호 Set\n */\nexport function parsePageRange(spec: number[] | string, maxPages: number): Set<number> {\n const result = new Set<number>()\n if (maxPages <= 0) return result\n\n if (Array.isArray(spec)) {\n for (const n of spec) {\n const page = Math.round(n)\n if (page >= 1 && page <= maxPages) result.add(page)\n }\n return result\n }\n\n if (typeof spec !== \"string\" || spec.trim() === \"\") return result\n\n const parts = spec.split(\",\")\n for (const part of parts) {\n const trimmed = part.trim()\n if (!trimmed) continue\n\n const rangeMatch = trimmed.match(/^(\\d+)\\s*-\\s*(\\d+)$/)\n if (rangeMatch) {\n const start = Math.max(1, parseInt(rangeMatch[1], 10))\n const end = Math.min(maxPages, parseInt(rangeMatch[2], 10))\n for (let i = start; i <= end; i++) result.add(i)\n } else {\n const page = parseInt(trimmed, 10)\n if (!isNaN(page) && page >= 1 && page <= maxPages) result.add(page)\n }\n }\n\n return result\n}\n"]}
@@ -30,4 +30,4 @@ function parsePageRange(spec, maxPages) {
30
30
  export {
31
31
  parsePageRange
32
32
  };
33
- //# sourceMappingURL=chunk-AIQ3ISQU.js.map
33
+ //# sourceMappingURL=chunk-GE43BE46.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/page-range.ts"],"sourcesContent":["/** 페이지/섹션 범위 파싱 유틸리티 */\n\n/**\n * 페이지 범위 지정을 1-based Set<number>로 변환.\n *\n * @param spec - [1,2,3] 또는 \"1-3\" 또는 \"1,3,5-7\"\n * @param maxPages - 최대 페이지 수 (클램핑 상한)\n * @returns 1-based 페이지 번호 Set\n */\nexport function parsePageRange(spec: number[] | string, maxPages: number): Set<number> {\n const result = new Set<number>()\n if (maxPages <= 0) return result\n\n if (Array.isArray(spec)) {\n for (const n of spec) {\n const page = Math.round(n)\n if (page >= 1 && page <= maxPages) result.add(page)\n }\n return result\n }\n\n if (typeof spec !== \"string\" || spec.trim() === \"\") return result\n\n const parts = spec.split(\",\")\n for (const part of parts) {\n const trimmed = part.trim()\n if (!trimmed) continue\n\n const rangeMatch = trimmed.match(/^(\\d+)\\s*-\\s*(\\d+)$/)\n if (rangeMatch) {\n const start = Math.max(1, parseInt(rangeMatch[1], 10))\n const end = Math.min(maxPages, parseInt(rangeMatch[2], 10))\n for (let i = start; i <= end; i++) result.add(i)\n } else {\n const page = parseInt(trimmed, 10)\n if (!isNaN(page) && page >= 1 && page <= maxPages) result.add(page)\n }\n }\n\n return result\n}\n"],"mappings":";AASO,SAAS,eAAe,MAAyB,UAA+B;AACrF,QAAM,SAAS,oBAAI,IAAY;AAC/B,MAAI,YAAY,EAAG,QAAO;AAE1B,MAAI,MAAM,QAAQ,IAAI,GAAG;AACvB,eAAW,KAAK,MAAM;AACpB,YAAM,OAAO,KAAK,MAAM,CAAC;AACzB,UAAI,QAAQ,KAAK,QAAQ,SAAU,QAAO,IAAI,IAAI;AAAA,IACpD;AACA,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,SAAS,YAAY,KAAK,KAAK,MAAM,GAAI,QAAO;AAE3D,QAAM,QAAQ,KAAK,MAAM,GAAG;AAC5B,aAAW,QAAQ,OAAO;AACxB,UAAM,UAAU,KAAK,KAAK;AAC1B,QAAI,CAAC,QAAS;AAEd,UAAM,aAAa,QAAQ,MAAM,qBAAqB;AACtD,QAAI,YAAY;AACd,YAAM,QAAQ,KAAK,IAAI,GAAG,SAAS,WAAW,CAAC,GAAG,EAAE,CAAC;AACrD,YAAM,MAAM,KAAK,IAAI,UAAU,SAAS,WAAW,CAAC,GAAG,EAAE,CAAC;AAC1D,eAAS,IAAI,OAAO,KAAK,KAAK,IAAK,QAAO,IAAI,CAAC;AAAA,IACjD,OAAO;AACL,YAAM,OAAO,SAAS,SAAS,EAAE;AACjC,UAAI,CAAC,MAAM,IAAI,KAAK,QAAQ,KAAK,QAAQ,SAAU,QAAO,IAAI,IAAI;AAAA,IACpE;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -4,7 +4,7 @@ import {
4
4
  detectOle2Format,
5
5
  detectZipFormat,
6
6
  parseLenientCfb
7
- } from "./chunk-CFQLK3LM.js";
7
+ } from "./chunk-MEPHGCPQ.js";
8
8
  import {
9
9
  HEADING_RATIO_H1,
10
10
  HEADING_RATIO_H2,
@@ -15,18 +15,20 @@ import {
15
15
  blocksToMarkdown,
16
16
  buildTable,
17
17
  classifyError,
18
+ compareSectionPaths,
18
19
  convertTableToText,
19
20
  flattenLayoutTables,
20
21
  isPathTraversal,
21
22
  mapPuaText,
23
+ normalizeSectionHref,
22
24
  precheckZipSize,
23
25
  sanitizeHref,
24
26
  stripDtd,
25
27
  toArrayBuffer
26
- } from "./chunk-A4LSWJEC.js";
28
+ } from "./chunk-IKAXUVSU.js";
27
29
  import {
28
30
  parsePageRange
29
- } from "./chunk-3TBUDJDE.js";
31
+ } from "./chunk-MOL7MDBG.js";
30
32
 
31
33
  // src/index.ts
32
34
  import { readFile } from "fs/promises";
@@ -412,14 +414,27 @@ function findBrackets(eqString, startIdx, direction) {
412
414
  const [s, e] = findBrackets(flipped, newStartIdx, 1);
413
415
  return [flipped.length - e, flipped.length - s];
414
416
  }
415
- function findOutterBrackets(eqString, startIdx) {
416
- let idx = startIdx;
417
- while (true) {
418
- idx -= 1;
419
- if (idx < 0) throw new Error("cannot find bracket");
420
- if (eqString[idx] === "{") break;
417
+ function findEnclosingBrackets(eqString, startIdx) {
418
+ let depth = 0;
419
+ for (let idx = startIdx - 1; idx >= 0; idx--) {
420
+ const ch = eqString[idx];
421
+ if (ch === "}") {
422
+ depth += 1;
423
+ } else if (ch === "{") {
424
+ if (depth > 0) {
425
+ depth -= 1;
426
+ continue;
427
+ }
428
+ try {
429
+ const [start, end] = findBrackets(eqString, idx, 1);
430
+ if (start === idx && end > startIdx) return [start, end];
431
+ } catch {
432
+ return null;
433
+ }
434
+ return null;
435
+ }
421
436
  }
422
- return findBrackets(eqString, idx, 1);
437
+ return null;
423
438
  }
424
439
  function replaceFrac(eqString) {
425
440
  const hmlFrac = "over";
@@ -472,8 +487,9 @@ function replaceAllMatrix(eqString) {
472
487
  const elem = replaceElements(input.slice(eStart, eEnd));
473
488
  let beforeMat;
474
489
  let afterMat;
475
- if (matElem.removeOutterBrackets) {
476
- const [bStart, bEnd] = findOutterBrackets(input, cursor);
490
+ const outer = matElem.removeOutterBrackets ? findEnclosingBrackets(input, cursor) : null;
491
+ if (outer && outer[1] >= eEnd) {
492
+ const [bStart, bEnd] = outer;
477
493
  beforeMat = input.slice(0, bStart);
478
494
  afterMat = input.slice(bEnd);
479
495
  } else {
@@ -499,10 +515,11 @@ function replaceAllBar(eqString) {
499
515
  if (cursor === -1) break;
500
516
  try {
501
517
  const [eStart, eEnd] = findBrackets(input, cursor, 1);
502
- const [bStart, bEnd] = findOutterBrackets(input, cursor);
503
518
  const elem = input.slice(eStart, eEnd);
504
- const beforeBar = input.slice(0, bStart);
505
- const afterBar = input.slice(bEnd);
519
+ const outer = findEnclosingBrackets(input, cursor);
520
+ const [replaceStart, replaceEnd] = outer && outer[1] >= eEnd ? outer : [cursor, eEnd];
521
+ const beforeBar = input.slice(0, replaceStart);
522
+ const afterBar = input.slice(replaceEnd);
506
523
  input = beforeBar + barElem + elem + afterBar;
507
524
  } catch {
508
525
  return input;
@@ -1137,24 +1154,19 @@ async function resolveSectionPaths(zip) {
1137
1154
  if (paths.length > 0) return paths;
1138
1155
  }
1139
1156
  const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
1140
- return sectionFiles.map((f) => f.name).sort();
1157
+ return sectionFiles.map((f) => f.name).sort(compareSectionPaths);
1141
1158
  }
1142
1159
  function parseSectionPathsFromManifest(xml) {
1143
1160
  const parser = createXmlParser();
1144
1161
  const doc = parser.parseFromString(stripDtd(xml), "text/xml");
1145
1162
  const items = doc.getElementsByTagName("opf:item");
1146
1163
  const spine = doc.getElementsByTagName("opf:itemref");
1147
- const isSectionId = (id) => /^s/i.test(id) || id.toLowerCase().includes("section");
1148
1164
  const idToHref = /* @__PURE__ */ new Map();
1149
1165
  for (let i = 0; i < items.length; i++) {
1150
1166
  const item = items[i];
1151
1167
  const id = item.getAttribute("id") || "";
1152
- let href = item.getAttribute("href") || "";
1153
- const mediaType = item.getAttribute("media-type") || "";
1154
- if (!isSectionId(id) && !mediaType.includes("xml")) continue;
1155
- if (!href.startsWith("/") && !href.startsWith("Contents/") && isSectionId(id))
1156
- href = "Contents/" + href;
1157
- idToHref.set(id, href);
1168
+ const href = normalizeSectionHref(item.getAttribute("href") || "");
1169
+ if (id && href) idToHref.set(id, href);
1158
1170
  }
1159
1171
  if (spine.length > 0) {
1160
1172
  const ordered = [];
@@ -1164,7 +1176,7 @@ function parseSectionPathsFromManifest(xml) {
1164
1176
  }
1165
1177
  if (ordered.length > 0) return ordered;
1166
1178
  }
1167
- return Array.from(idToHref.entries()).filter(([id]) => isSectionId(id)).sort((a, b) => a[0].localeCompare(b[0])).map(([, href]) => href);
1179
+ return Array.from(idToHref.values()).sort(compareSectionPaths);
1168
1180
  }
1169
1181
  function detectHwpxHeadings(blocks, styleMap) {
1170
1182
  if (blocks.some((b) => b.type === "heading")) return;
@@ -16689,7 +16701,7 @@ async function parseXlsxDocument(buffer, options) {
16689
16701
  }
16690
16702
  let pageFilter = null;
16691
16703
  if (options?.pages) {
16692
- const { parsePageRange: parsePageRange2 } = await import("./page-range-OF5I4PQY.js");
16704
+ const { parsePageRange: parsePageRange2 } = await import("./page-range-737B4EZW.js");
16693
16705
  pageFilter = parsePageRange2(options.pages, sheets.length);
16694
16706
  }
16695
16707
  const blocks = [];
@@ -17327,7 +17339,7 @@ async function parseXlsDocument(buffer, options) {
17327
17339
  const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
17328
17340
  let pageFilter = null;
17329
17341
  if (options?.pages) {
17330
- const { parsePageRange: parsePageRange2 } = await import("./page-range-OF5I4PQY.js");
17342
+ const { parsePageRange: parsePageRange2 } = await import("./page-range-737B4EZW.js");
17331
17343
  pageFilter = parsePageRange2(options.pages, totalSheets);
17332
17344
  }
17333
17345
  const allBlocks = [];
@@ -21255,10 +21267,9 @@ async function resolveSectionEntryNames(zip) {
21255
21267
  const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
21256
21268
  if (paths.length > 0) return paths;
21257
21269
  }
21258
- return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort();
21270
+ return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(compareSectionPaths);
21259
21271
  }
21260
21272
  function sectionPathsFromManifest(xml) {
21261
- const isSectionId = (id) => /^s/i.test(id) || id.toLowerCase().includes("section");
21262
21273
  const attr = (tag, name) => {
21263
21274
  const m = tag.match(new RegExp(`(?:^|\\s)${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`));
21264
21275
  return m ? m[1] ?? m[2] : "";
@@ -21266,11 +21277,8 @@ function sectionPathsFromManifest(xml) {
21266
21277
  const idToHref = /* @__PURE__ */ new Map();
21267
21278
  for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
21268
21279
  const id = attr(m[1], "id");
21269
- let href = attr(m[1], "href");
21270
- const mediaType = attr(m[1], "media-type");
21271
- if (!isSectionId(id) && !mediaType.includes("xml")) continue;
21272
- if (!href.startsWith("/") && !href.startsWith("Contents/") && isSectionId(id)) href = "Contents/" + href;
21273
- if (id) idToHref.set(id, href);
21280
+ const href = normalizeSectionHref(attr(m[1], "href"));
21281
+ if (id && href) idToHref.set(id, href);
21274
21282
  }
21275
21283
  const ordered = [];
21276
21284
  for (const m of xml.matchAll(/<opf:itemref(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
@@ -21278,7 +21286,7 @@ function sectionPathsFromManifest(xml) {
21278
21286
  if (href) ordered.push(href);
21279
21287
  }
21280
21288
  if (ordered.length > 0) return ordered;
21281
- return Array.from(idToHref.entries()).filter(([id]) => isSectionId(id)).sort((a, b) => a[0].localeCompare(b[0])).map(([, href]) => href);
21289
+ return Array.from(idToHref.values()).sort(compareSectionPaths);
21282
21290
  }
21283
21291
 
21284
21292
  // src/roundtrip/patcher.ts
@@ -23287,7 +23295,7 @@ async function parseHwp(buffer, options) {
23287
23295
  async function parsePdf(buffer, options) {
23288
23296
  let parsePdfDocument;
23289
23297
  try {
23290
- const mod = await import("./parser-LMBDB7RM.js");
23298
+ const mod = await import("./parser-XXQAMYGV.js");
23291
23299
  parsePdfDocument = mod.parsePdfDocument;
23292
23300
  } catch {
23293
23301
  return {
@@ -23414,4 +23422,4 @@ export {
23414
23422
  parseHwpml,
23415
23423
  fillForm
23416
23424
  };
23417
- //# sourceMappingURL=chunk-GTCJQANY.js.map
23425
+ //# sourceMappingURL=chunk-GMPDZD7Q.js.map