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.
- package/LICENSE +21 -21
- package/README.md +590 -590
- package/dist/{-GKNSTVEZ.js → -BNJMPTQ2.js} +5 -5
- package/dist/{chunk-X34YWRL5.cjs → chunk-DCZVOIEO.cjs} +1 -1
- package/dist/chunk-DCZVOIEO.cjs.map +1 -0
- package/dist/{chunk-AIQ3ISQU.js → chunk-GE43BE46.js} +1 -1
- package/dist/chunk-GE43BE46.js.map +1 -0
- package/dist/{chunk-GTCJQANY.js → chunk-GMPDZD7Q.js} +44 -36
- package/dist/chunk-GMPDZD7Q.js.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-A4LSWJEC.js → chunk-IKAXUVSU.js} +16 -2
- package/dist/chunk-IKAXUVSU.js.map +1 -0
- package/dist/{chunk-CFQLK3LM.js → chunk-MEPHGCPQ.js} +1 -1
- package/dist/chunk-MEPHGCPQ.js.map +1 -0
- package/dist/{chunk-3TBUDJDE.js → chunk-MOL7MDBG.js} +1 -1
- package/dist/chunk-MOL7MDBG.js.map +1 -0
- package/dist/{chunk-AHDNELBR.js → chunk-OXOPDVNV.js} +16 -2
- package/dist/chunk-OXOPDVNV.js.map +1 -0
- package/dist/{chunk-4JLD2IT7.cjs → chunk-RWSGBXSA.cjs} +25 -11
- package/dist/chunk-RWSGBXSA.cjs.map +1 -0
- package/dist/cli.js +8 -8
- package/dist/cli.js.map +1 -1
- package/dist/{detect-NTR2FUEG.js → detect-RI2MQ33K.js} +2 -2
- package/dist/{formula-ZYUDQHD3.cjs → formula-5NKVS2LR.cjs} +1 -1
- package/dist/formula-5NKVS2LR.cjs.map +1 -0
- package/dist/{formula-KOQV353G.js → formula-JCNF43NE.js} +1 -1
- package/dist/formula-JCNF43NE.js.map +1 -0
- package/dist/{formula-MEDGYQXS.js → formula-RXVSQPXI.js} +1 -1
- package/dist/formula-RXVSQPXI.js.map +1 -0
- package/dist/index.cjs +181 -173
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +42 -34
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +6 -6
- package/dist/mcp.js.map +1 -1
- package/dist/page-range-737B4EZW.js +8 -0
- package/dist/page-range-LNMXJU6W.js +7 -0
- package/dist/page-range-P7SDW6LR.cjs +8 -0
- package/dist/page-range-P7SDW6LR.cjs.map +1 -0
- package/dist/{parser-LBLPN3KY.js → parser-GHZMDUGG.js} +5 -5
- package/dist/parser-GHZMDUGG.js.map +1 -0
- package/dist/{parser-LMBDB7RM.js → parser-XXQAMYGV.js} +5 -5
- package/dist/parser-XXQAMYGV.js.map +1 -0
- package/dist/{parser-25ISHR7Q.cjs → parser-ZLFOUVR4.cjs} +18 -18
- package/dist/parser-ZLFOUVR4.cjs.map +1 -0
- package/dist/{provider-H4WWSPOV.js → provider-4ZJKV3DC.js} +1 -1
- package/dist/provider-4ZJKV3DC.js.map +1 -0
- package/dist/{provider-7H4CPZYS.js → provider-AKROB7WQ.js} +1 -1
- package/dist/provider-AKROB7WQ.js.map +1 -0
- package/dist/{provider-5K7O3Z2O.cjs → provider-G4C2V2PD.cjs} +1 -1
- package/dist/provider-G4C2V2PD.cjs.map +1 -0
- package/dist/{setup-QSJ2INNS.js → setup-57FB3LSP.js} +1 -1
- package/dist/setup-57FB3LSP.js.map +1 -0
- package/dist/{watch-77CYT54V.js → watch-IN3YN72W.js} +5 -5
- package/dist/watch-IN3YN72W.js.map +1 -0
- package/package.json +98 -98
- package/dist/chunk-3TBUDJDE.js.map +0 -1
- package/dist/chunk-4JLD2IT7.cjs.map +0 -1
- package/dist/chunk-A4LSWJEC.js.map +0 -1
- package/dist/chunk-AHDNELBR.js.map +0 -1
- package/dist/chunk-AIQ3ISQU.js.map +0 -1
- package/dist/chunk-CFQLK3LM.js.map +0 -1
- package/dist/chunk-GTCJQANY.js.map +0 -1
- package/dist/chunk-X34YWRL5.cjs.map +0 -1
- package/dist/formula-KOQV353G.js.map +0 -1
- package/dist/formula-MEDGYQXS.js.map +0 -1
- package/dist/formula-ZYUDQHD3.cjs.map +0 -1
- package/dist/page-range-CIRRJPXJ.js +0 -7
- package/dist/page-range-OF5I4PQY.js +0 -8
- package/dist/page-range-TPIRSA3J.cjs +0 -8
- package/dist/page-range-TPIRSA3J.cjs.map +0 -1
- package/dist/parser-25ISHR7Q.cjs.map +0 -1
- package/dist/parser-LBLPN3KY.js.map +0 -1
- package/dist/parser-LMBDB7RM.js.map +0 -1
- package/dist/provider-5K7O3Z2O.cjs.map +0 -1
- package/dist/provider-7H4CPZYS.js.map +0 -1
- package/dist/provider-H4WWSPOV.js.map +0 -1
- package/dist/setup-QSJ2INNS.js.map +0 -1
- package/dist/watch-77CYT54V.js.map +0 -1
- /package/dist/{-GKNSTVEZ.js.map → -BNJMPTQ2.js.map} +0 -0
- /package/dist/{detect-NTR2FUEG.js.map → detect-RI2MQ33K.js.map} +0 -0
- /package/dist/{page-range-CIRRJPXJ.js.map → page-range-737B4EZW.js.map} +0 -0
- /package/dist/{page-range-OF5I4PQY.js.map → page-range-LNMXJU6W.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -9,18 +9,20 @@ import {
|
|
|
9
9
|
blocksToMarkdown,
|
|
10
10
|
buildTable,
|
|
11
11
|
classifyError,
|
|
12
|
+
compareSectionPaths,
|
|
12
13
|
convertTableToText,
|
|
13
14
|
flattenLayoutTables,
|
|
14
15
|
isPathTraversal,
|
|
15
16
|
mapPuaText,
|
|
17
|
+
normalizeSectionHref,
|
|
16
18
|
precheckZipSize,
|
|
17
19
|
sanitizeHref,
|
|
18
20
|
stripDtd,
|
|
19
21
|
toArrayBuffer
|
|
20
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-OXOPDVNV.js";
|
|
21
23
|
import {
|
|
22
24
|
parsePageRange
|
|
23
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-GE43BE46.js";
|
|
24
26
|
|
|
25
27
|
// src/index.ts
|
|
26
28
|
import { readFile } from "fs/promises";
|
|
@@ -657,14 +659,27 @@ function findBrackets(eqString, startIdx, direction) {
|
|
|
657
659
|
const [s, e] = findBrackets(flipped, newStartIdx, 1);
|
|
658
660
|
return [flipped.length - e, flipped.length - s];
|
|
659
661
|
}
|
|
660
|
-
function
|
|
661
|
-
let
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
if (
|
|
665
|
-
|
|
662
|
+
function findEnclosingBrackets(eqString, startIdx) {
|
|
663
|
+
let depth = 0;
|
|
664
|
+
for (let idx = startIdx - 1; idx >= 0; idx--) {
|
|
665
|
+
const ch = eqString[idx];
|
|
666
|
+
if (ch === "}") {
|
|
667
|
+
depth += 1;
|
|
668
|
+
} else if (ch === "{") {
|
|
669
|
+
if (depth > 0) {
|
|
670
|
+
depth -= 1;
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
try {
|
|
674
|
+
const [start, end] = findBrackets(eqString, idx, 1);
|
|
675
|
+
if (start === idx && end > startIdx) return [start, end];
|
|
676
|
+
} catch {
|
|
677
|
+
return null;
|
|
678
|
+
}
|
|
679
|
+
return null;
|
|
680
|
+
}
|
|
666
681
|
}
|
|
667
|
-
return
|
|
682
|
+
return null;
|
|
668
683
|
}
|
|
669
684
|
function replaceFrac(eqString) {
|
|
670
685
|
const hmlFrac = "over";
|
|
@@ -717,8 +732,9 @@ function replaceAllMatrix(eqString) {
|
|
|
717
732
|
const elem = replaceElements(input.slice(eStart, eEnd));
|
|
718
733
|
let beforeMat;
|
|
719
734
|
let afterMat;
|
|
720
|
-
|
|
721
|
-
|
|
735
|
+
const outer = matElem.removeOutterBrackets ? findEnclosingBrackets(input, cursor) : null;
|
|
736
|
+
if (outer && outer[1] >= eEnd) {
|
|
737
|
+
const [bStart, bEnd] = outer;
|
|
722
738
|
beforeMat = input.slice(0, bStart);
|
|
723
739
|
afterMat = input.slice(bEnd);
|
|
724
740
|
} else {
|
|
@@ -744,10 +760,11 @@ function replaceAllBar(eqString) {
|
|
|
744
760
|
if (cursor === -1) break;
|
|
745
761
|
try {
|
|
746
762
|
const [eStart, eEnd] = findBrackets(input, cursor, 1);
|
|
747
|
-
const [bStart, bEnd] = findOutterBrackets(input, cursor);
|
|
748
763
|
const elem = input.slice(eStart, eEnd);
|
|
749
|
-
const
|
|
750
|
-
const
|
|
764
|
+
const outer = findEnclosingBrackets(input, cursor);
|
|
765
|
+
const [replaceStart, replaceEnd] = outer && outer[1] >= eEnd ? outer : [cursor, eEnd];
|
|
766
|
+
const beforeBar = input.slice(0, replaceStart);
|
|
767
|
+
const afterBar = input.slice(replaceEnd);
|
|
751
768
|
input = beforeBar + barElem + elem + afterBar;
|
|
752
769
|
} catch {
|
|
753
770
|
return input;
|
|
@@ -1369,24 +1386,19 @@ async function resolveSectionPaths(zip) {
|
|
|
1369
1386
|
if (paths.length > 0) return paths;
|
|
1370
1387
|
}
|
|
1371
1388
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
1372
|
-
return sectionFiles.map((f) => f.name).sort();
|
|
1389
|
+
return sectionFiles.map((f) => f.name).sort(compareSectionPaths);
|
|
1373
1390
|
}
|
|
1374
1391
|
function parseSectionPathsFromManifest(xml) {
|
|
1375
1392
|
const parser = createXmlParser();
|
|
1376
1393
|
const doc = parser.parseFromString(stripDtd(xml), "text/xml");
|
|
1377
1394
|
const items = doc.getElementsByTagName("opf:item");
|
|
1378
1395
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
1379
|
-
const isSectionId = (id) => /^s/i.test(id) || id.toLowerCase().includes("section");
|
|
1380
1396
|
const idToHref = /* @__PURE__ */ new Map();
|
|
1381
1397
|
for (let i = 0; i < items.length; i++) {
|
|
1382
1398
|
const item = items[i];
|
|
1383
1399
|
const id = item.getAttribute("id") || "";
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
if (!isSectionId(id) && !mediaType.includes("xml")) continue;
|
|
1387
|
-
if (!href.startsWith("/") && !href.startsWith("Contents/") && isSectionId(id))
|
|
1388
|
-
href = "Contents/" + href;
|
|
1389
|
-
idToHref.set(id, href);
|
|
1400
|
+
const href = normalizeSectionHref(item.getAttribute("href") || "");
|
|
1401
|
+
if (id && href) idToHref.set(id, href);
|
|
1390
1402
|
}
|
|
1391
1403
|
if (spine.length > 0) {
|
|
1392
1404
|
const ordered = [];
|
|
@@ -1396,7 +1408,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
1396
1408
|
}
|
|
1397
1409
|
if (ordered.length > 0) return ordered;
|
|
1398
1410
|
}
|
|
1399
|
-
return Array.from(idToHref.
|
|
1411
|
+
return Array.from(idToHref.values()).sort(compareSectionPaths);
|
|
1400
1412
|
}
|
|
1401
1413
|
function detectHwpxHeadings(blocks, styleMap) {
|
|
1402
1414
|
if (blocks.some((b) => b.type === "heading")) return;
|
|
@@ -16907,7 +16919,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16907
16919
|
}
|
|
16908
16920
|
let pageFilter = null;
|
|
16909
16921
|
if (options?.pages) {
|
|
16910
|
-
const { parsePageRange: parsePageRange2 } = await import("./page-range-
|
|
16922
|
+
const { parsePageRange: parsePageRange2 } = await import("./page-range-LNMXJU6W.js");
|
|
16911
16923
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
16912
16924
|
}
|
|
16913
16925
|
const blocks = [];
|
|
@@ -17545,7 +17557,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17545
17557
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
17546
17558
|
let pageFilter = null;
|
|
17547
17559
|
if (options?.pages) {
|
|
17548
|
-
const { parsePageRange: parsePageRange2 } = await import("./page-range-
|
|
17560
|
+
const { parsePageRange: parsePageRange2 } = await import("./page-range-LNMXJU6W.js");
|
|
17549
17561
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
17550
17562
|
}
|
|
17551
17563
|
const allBlocks = [];
|
|
@@ -21473,10 +21485,9 @@ async function resolveSectionEntryNames(zip) {
|
|
|
21473
21485
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
21474
21486
|
if (paths.length > 0) return paths;
|
|
21475
21487
|
}
|
|
21476
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort();
|
|
21488
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(compareSectionPaths);
|
|
21477
21489
|
}
|
|
21478
21490
|
function sectionPathsFromManifest(xml) {
|
|
21479
|
-
const isSectionId = (id) => /^s/i.test(id) || id.toLowerCase().includes("section");
|
|
21480
21491
|
const attr = (tag, name) => {
|
|
21481
21492
|
const m = tag.match(new RegExp(`(?:^|\\s)${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`));
|
|
21482
21493
|
return m ? m[1] ?? m[2] : "";
|
|
@@ -21484,11 +21495,8 @@ function sectionPathsFromManifest(xml) {
|
|
|
21484
21495
|
const idToHref = /* @__PURE__ */ new Map();
|
|
21485
21496
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
21486
21497
|
const id = attr(m[1], "id");
|
|
21487
|
-
|
|
21488
|
-
|
|
21489
|
-
if (!isSectionId(id) && !mediaType.includes("xml")) continue;
|
|
21490
|
-
if (!href.startsWith("/") && !href.startsWith("Contents/") && isSectionId(id)) href = "Contents/" + href;
|
|
21491
|
-
if (id) idToHref.set(id, href);
|
|
21498
|
+
const href = normalizeSectionHref(attr(m[1], "href"));
|
|
21499
|
+
if (id && href) idToHref.set(id, href);
|
|
21492
21500
|
}
|
|
21493
21501
|
const ordered = [];
|
|
21494
21502
|
for (const m of xml.matchAll(/<opf:itemref(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
@@ -21496,7 +21504,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
21496
21504
|
if (href) ordered.push(href);
|
|
21497
21505
|
}
|
|
21498
21506
|
if (ordered.length > 0) return ordered;
|
|
21499
|
-
return Array.from(idToHref.
|
|
21507
|
+
return Array.from(idToHref.values()).sort(compareSectionPaths);
|
|
21500
21508
|
}
|
|
21501
21509
|
|
|
21502
21510
|
// src/roundtrip/patcher.ts
|
|
@@ -23505,7 +23513,7 @@ async function parseHwp(buffer, options) {
|
|
|
23505
23513
|
async function parsePdf(buffer, options) {
|
|
23506
23514
|
let parsePdfDocument;
|
|
23507
23515
|
try {
|
|
23508
|
-
const mod = await import("./parser-
|
|
23516
|
+
const mod = await import("./parser-GHZMDUGG.js");
|
|
23509
23517
|
parsePdfDocument = mod.parsePdfDocument;
|
|
23510
23518
|
} catch {
|
|
23511
23519
|
return {
|