kordoc 3.5.0 → 3.5.2
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 → -LYUGJZQG.js} +5 -5
- package/dist/{chunk-X34YWRL5.cjs → chunk-DCZVOIEO.cjs} +1 -1
- package/dist/chunk-DCZVOIEO.cjs.map +1 -0
- package/dist/{chunk-GTCJQANY.js → chunk-DN5LTND6.js} +48 -38
- package/dist/chunk-DN5LTND6.js.map +1 -0
- package/dist/{chunk-4JLD2IT7.cjs → chunk-G44XLS26.cjs} +25 -11
- package/dist/chunk-G44XLS26.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-GS7T56RP.cjs.map +1 -1
- 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-A4LSWJEC.js → chunk-NOIHZQWC.js} +16 -2
- package/dist/chunk-NOIHZQWC.js.map +1 -0
- package/dist/{chunk-AHDNELBR.js → chunk-QXXQIZBH.js} +16 -2
- package/dist/chunk-QXXQIZBH.js.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 +185 -175
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +46 -36
- 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-25ISHR7Q.cjs → parser-2O276TRF.cjs} +18 -18
- package/dist/parser-2O276TRF.cjs.map +1 -0
- package/dist/{parser-LBLPN3KY.js → parser-4FFTFIYL.js} +5 -5
- package/dist/parser-4FFTFIYL.js.map +1 -0
- package/dist/{parser-LMBDB7RM.js → parser-KDF76UCB.js} +5 -5
- package/dist/parser-KDF76UCB.js.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-MF7JFR7S.js} +5 -5
- package/dist/watch-MF7JFR7S.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 → -LYUGJZQG.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-QXXQIZBH.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 = [];
|
|
@@ -20441,7 +20453,8 @@ ${base2.join("\n")}
|
|
|
20441
20453
|
];
|
|
20442
20454
|
for (let d = 0; d < GONGMUN_LIST_LEVELS; d++) {
|
|
20443
20455
|
const { left, indent } = levelIndent(d, gongmun.bodyHeight, gongmun.numbering);
|
|
20444
|
-
|
|
20456
|
+
const sectionGap = gongmun.numbering === "report" && d === 0 ? Math.round(gongmun.bodyHeight * 0.5) : 0;
|
|
20457
|
+
base.push(paraPr(GONGMUN_LIST_BASE + d, { align: "JUSTIFY", lineSpacing: ls, left, indent, spaceBefore: sectionGap }));
|
|
20445
20458
|
}
|
|
20446
20459
|
base.push(paraPr(GONGMUN_CENTER, { align: "CENTER", lineSpacing: ls }));
|
|
20447
20460
|
return `<hh:paraProperties itemCnt="${base.length}">
|
|
@@ -20652,7 +20665,8 @@ function blocksToSectionXml(blocks, theme, gongmun) {
|
|
|
20652
20665
|
const marker2 = info?.marker ?? "";
|
|
20653
20666
|
const content = block.text || "";
|
|
20654
20667
|
const text = marker2 ? `${marker2} ${content}` : content;
|
|
20655
|
-
|
|
20668
|
+
const listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
|
|
20669
|
+
xml = generateParagraph(text, GONGMUN_LIST_BASE + depth, listCharPr);
|
|
20656
20670
|
break;
|
|
20657
20671
|
}
|
|
20658
20672
|
const indent = block.indent || 0;
|
|
@@ -21473,10 +21487,9 @@ async function resolveSectionEntryNames(zip) {
|
|
|
21473
21487
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
21474
21488
|
if (paths.length > 0) return paths;
|
|
21475
21489
|
}
|
|
21476
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort();
|
|
21490
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(compareSectionPaths);
|
|
21477
21491
|
}
|
|
21478
21492
|
function sectionPathsFromManifest(xml) {
|
|
21479
|
-
const isSectionId = (id) => /^s/i.test(id) || id.toLowerCase().includes("section");
|
|
21480
21493
|
const attr = (tag, name) => {
|
|
21481
21494
|
const m = tag.match(new RegExp(`(?:^|\\s)${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`));
|
|
21482
21495
|
return m ? m[1] ?? m[2] : "";
|
|
@@ -21484,11 +21497,8 @@ function sectionPathsFromManifest(xml) {
|
|
|
21484
21497
|
const idToHref = /* @__PURE__ */ new Map();
|
|
21485
21498
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
21486
21499
|
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);
|
|
21500
|
+
const href = normalizeSectionHref(attr(m[1], "href"));
|
|
21501
|
+
if (id && href) idToHref.set(id, href);
|
|
21492
21502
|
}
|
|
21493
21503
|
const ordered = [];
|
|
21494
21504
|
for (const m of xml.matchAll(/<opf:itemref(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
@@ -21496,7 +21506,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
21496
21506
|
if (href) ordered.push(href);
|
|
21497
21507
|
}
|
|
21498
21508
|
if (ordered.length > 0) return ordered;
|
|
21499
|
-
return Array.from(idToHref.
|
|
21509
|
+
return Array.from(idToHref.values()).sort(compareSectionPaths);
|
|
21500
21510
|
}
|
|
21501
21511
|
|
|
21502
21512
|
// src/roundtrip/patcher.ts
|
|
@@ -23505,7 +23515,7 @@ async function parseHwp(buffer, options) {
|
|
|
23505
23515
|
async function parsePdf(buffer, options) {
|
|
23506
23516
|
let parsePdfDocument;
|
|
23507
23517
|
try {
|
|
23508
|
-
const mod = await import("./parser-
|
|
23518
|
+
const mod = await import("./parser-4FFTFIYL.js");
|
|
23509
23519
|
parsePdfDocument = mod.parsePdfDocument;
|
|
23510
23520
|
} catch {
|
|
23511
23521
|
return {
|