kordoc 3.4.1 → 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 -584
- package/dist/{-YOQGQ22S.js → -BNJMPTQ2.js} +9 -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-CGHPBI3X.js → chunk-GMPDZD7Q.js} +206 -42
- package/dist/chunk-GMPDZD7Q.js.map +1 -0
- package/dist/chunk-GS7T56RP.cjs.map +1 -1
- package/dist/{chunk-FPFB7AFX.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-SE3KEL4G.js → chunk-OXOPDVNV.js} +16 -2
- package/dist/chunk-OXOPDVNV.js.map +1 -0
- package/dist/{chunk-W7JHJQ2O.cjs → chunk-RWSGBXSA.cjs} +25 -11
- package/dist/chunk-RWSGBXSA.cjs.map +1 -0
- package/dist/cli.js +10 -27
- 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 +377 -213
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.js +204 -40
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +42 -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-5HDZZWDH.js → parser-GHZMDUGG.js} +5 -5
- package/dist/parser-GHZMDUGG.js.map +1 -0
- package/dist/{parser-ET64VEEX.js → parser-XXQAMYGV.js} +5 -5
- package/dist/parser-XXQAMYGV.js.map +1 -0
- package/dist/{parser-JAZCZJI6.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-56GNC2YN.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-AIQ3ISQU.js.map +0 -1
- package/dist/chunk-CFQLK3LM.js.map +0 -1
- package/dist/chunk-CGHPBI3X.js.map +0 -1
- package/dist/chunk-FPFB7AFX.js.map +0 -1
- package/dist/chunk-SE3KEL4G.js.map +0 -1
- package/dist/chunk-W7JHJQ2O.cjs.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-5HDZZWDH.js.map +0 -1
- package/dist/parser-ET64VEEX.js.map +0 -1
- package/dist/parser-JAZCZJI6.cjs.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-56GNC2YN.js.map +0 -1
- /package/dist/{-YOQGQ22S.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.cjs
CHANGED
|
@@ -17,10 +17,12 @@
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var _chunkW7JHJQ2Ocjs = require('./chunk-W7JHJQ2O.cjs');
|
|
21
20
|
|
|
22
21
|
|
|
23
|
-
var
|
|
22
|
+
var _chunkRWSGBXSAcjs = require('./chunk-RWSGBXSA.cjs');
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
var _chunkGS7T56RPcjs = require('./chunk-GS7T56RP.cjs');
|
|
@@ -660,14 +662,27 @@ function findBrackets(eqString, startIdx, direction) {
|
|
|
660
662
|
const [s, e] = findBrackets(flipped, newStartIdx, 1);
|
|
661
663
|
return [flipped.length - e, flipped.length - s];
|
|
662
664
|
}
|
|
663
|
-
function
|
|
664
|
-
let
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
if (
|
|
668
|
-
|
|
665
|
+
function findEnclosingBrackets(eqString, startIdx) {
|
|
666
|
+
let depth = 0;
|
|
667
|
+
for (let idx = startIdx - 1; idx >= 0; idx--) {
|
|
668
|
+
const ch = eqString[idx];
|
|
669
|
+
if (ch === "}") {
|
|
670
|
+
depth += 1;
|
|
671
|
+
} else if (ch === "{") {
|
|
672
|
+
if (depth > 0) {
|
|
673
|
+
depth -= 1;
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
try {
|
|
677
|
+
const [start, end] = findBrackets(eqString, idx, 1);
|
|
678
|
+
if (start === idx && end > startIdx) return [start, end];
|
|
679
|
+
} catch (e5) {
|
|
680
|
+
return null;
|
|
681
|
+
}
|
|
682
|
+
return null;
|
|
683
|
+
}
|
|
669
684
|
}
|
|
670
|
-
return
|
|
685
|
+
return null;
|
|
671
686
|
}
|
|
672
687
|
function replaceFrac(eqString) {
|
|
673
688
|
const hmlFrac = "over";
|
|
@@ -680,7 +695,7 @@ function replaceFrac(eqString) {
|
|
|
680
695
|
const beforeFrac = eqString.slice(0, numStart);
|
|
681
696
|
const afterFrac = eqString.slice(cursor + hmlFrac.length);
|
|
682
697
|
eqString = beforeFrac + "\\frac" + numerator + afterFrac;
|
|
683
|
-
} catch (
|
|
698
|
+
} catch (e6) {
|
|
684
699
|
return eqString;
|
|
685
700
|
}
|
|
686
701
|
}
|
|
@@ -698,7 +713,7 @@ function replaceRootOf(eqString) {
|
|
|
698
713
|
const e1 = eqString.slice(elem1[0] + 1, elem1[1] - 1);
|
|
699
714
|
const e2 = eqString.slice(elem2[0] + 1, elem2[1] - 1);
|
|
700
715
|
eqString = eqString.slice(0, rootCursor) + "\\sqrt[" + e1 + "]{" + e2 + "}" + eqString.slice(elem2[1] + 1);
|
|
701
|
-
} catch (
|
|
716
|
+
} catch (e7) {
|
|
702
717
|
return eqString;
|
|
703
718
|
}
|
|
704
719
|
}
|
|
@@ -720,8 +735,9 @@ function replaceAllMatrix(eqString) {
|
|
|
720
735
|
const elem = replaceElements(input.slice(eStart, eEnd));
|
|
721
736
|
let beforeMat;
|
|
722
737
|
let afterMat;
|
|
723
|
-
|
|
724
|
-
|
|
738
|
+
const outer = matElem.removeOutterBrackets ? findEnclosingBrackets(input, cursor) : null;
|
|
739
|
+
if (outer && outer[1] >= eEnd) {
|
|
740
|
+
const [bStart, bEnd] = outer;
|
|
725
741
|
beforeMat = input.slice(0, bStart);
|
|
726
742
|
afterMat = input.slice(bEnd);
|
|
727
743
|
} else {
|
|
@@ -729,7 +745,7 @@ function replaceAllMatrix(eqString) {
|
|
|
729
745
|
afterMat = input.slice(eEnd);
|
|
730
746
|
}
|
|
731
747
|
input = beforeMat + matElem.begin + elem + matElem.end + afterMat;
|
|
732
|
-
} catch (
|
|
748
|
+
} catch (e8) {
|
|
733
749
|
return input;
|
|
734
750
|
}
|
|
735
751
|
}
|
|
@@ -747,12 +763,13 @@ function replaceAllBar(eqString) {
|
|
|
747
763
|
if (cursor === -1) break;
|
|
748
764
|
try {
|
|
749
765
|
const [eStart, eEnd] = findBrackets(input, cursor, 1);
|
|
750
|
-
const [bStart, bEnd] = findOutterBrackets(input, cursor);
|
|
751
766
|
const elem = input.slice(eStart, eEnd);
|
|
752
|
-
const
|
|
753
|
-
const
|
|
767
|
+
const outer = findEnclosingBrackets(input, cursor);
|
|
768
|
+
const [replaceStart, replaceEnd] = outer && outer[1] >= eEnd ? outer : [cursor, eEnd];
|
|
769
|
+
const beforeBar = input.slice(0, replaceStart);
|
|
770
|
+
const afterBar = input.slice(replaceEnd);
|
|
754
771
|
input = beforeBar + barElem + elem + afterBar;
|
|
755
|
-
} catch (
|
|
772
|
+
} catch (e9) {
|
|
756
773
|
return input;
|
|
757
774
|
}
|
|
758
775
|
}
|
|
@@ -776,7 +793,7 @@ function replaceAllBrace(eqString) {
|
|
|
776
793
|
const beforeBrace = input.slice(0, cursor);
|
|
777
794
|
const afterBrace = input.slice(eEnd2);
|
|
778
795
|
input = beforeBrace + braceElem + elem1 + "^" + elem2 + afterBrace;
|
|
779
|
-
} catch (
|
|
796
|
+
} catch (e10) {
|
|
780
797
|
return input;
|
|
781
798
|
}
|
|
782
799
|
}
|
|
@@ -828,7 +845,7 @@ function createSectionShared() {
|
|
|
828
845
|
function createXmlParser(warnings) {
|
|
829
846
|
return new (0, _xmldom.DOMParser)({
|
|
830
847
|
onError(level, msg2) {
|
|
831
|
-
if (level === "fatalError") throw new (0,
|
|
848
|
+
if (level === "fatalError") throw new (0, _chunkRWSGBXSAcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
|
|
832
849
|
_optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warn" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
|
|
833
850
|
}
|
|
834
851
|
});
|
|
@@ -850,10 +867,10 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
850
867
|
const xml = await file.async("text");
|
|
851
868
|
if (decompressed) {
|
|
852
869
|
decompressed.total += xml.length * 2;
|
|
853
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
870
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkRWSGBXSAcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
854
871
|
}
|
|
855
872
|
const parser = createXmlParser();
|
|
856
|
-
const doc = parser.parseFromString(
|
|
873
|
+
const doc = parser.parseFromString(_chunkRWSGBXSAcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
857
874
|
if (!doc.documentElement) continue;
|
|
858
875
|
parseCharProperties(doc, result.charProperties);
|
|
859
876
|
parseStyleElements(doc, result.styles);
|
|
@@ -862,7 +879,7 @@ async function extractHwpxStyles(zip, decompressed) {
|
|
|
862
879
|
parseBullets(domDoc, result.bullets);
|
|
863
880
|
parseParaHeadings(domDoc, result.paraHeadings);
|
|
864
881
|
break;
|
|
865
|
-
} catch (
|
|
882
|
+
} catch (e11) {
|
|
866
883
|
continue;
|
|
867
884
|
}
|
|
868
885
|
}
|
|
@@ -1075,16 +1092,16 @@ function resolveParaHeading(paraEl, ctx) {
|
|
|
1075
1092
|
return { prefix, headingLevel };
|
|
1076
1093
|
}
|
|
1077
1094
|
async function parseHwpxDocument(buffer, options) {
|
|
1078
|
-
|
|
1095
|
+
_chunkRWSGBXSAcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
|
|
1079
1096
|
let zip;
|
|
1080
1097
|
try {
|
|
1081
1098
|
zip = await _jszip2.default.loadAsync(buffer);
|
|
1082
|
-
} catch (
|
|
1099
|
+
} catch (e12) {
|
|
1083
1100
|
return extractFromBrokenZip(buffer);
|
|
1084
1101
|
}
|
|
1085
1102
|
const actualEntryCount = Object.keys(zip.files).length;
|
|
1086
1103
|
if (actualEntryCount > MAX_ZIP_ENTRIES) {
|
|
1087
|
-
throw new (0,
|
|
1104
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1088
1105
|
}
|
|
1089
1106
|
const manifestFile = zip.file("META-INF/manifest.xml");
|
|
1090
1107
|
if (manifestFile) {
|
|
@@ -1096,7 +1113,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
1096
1113
|
return comResultToParseResult(pages, pageCount, warnings2);
|
|
1097
1114
|
}
|
|
1098
1115
|
}
|
|
1099
|
-
throw new (0,
|
|
1116
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)("DRM \uC554\uD638\uD654\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. Windows + \uD55C\uCEF4 \uC624\uD53C\uC2A4 \uC124\uCE58 \uC2DC \uC790\uB3D9 \uCD94\uCD9C\uB429\uB2C8\uB2E4.");
|
|
1100
1117
|
}
|
|
1101
1118
|
}
|
|
1102
1119
|
const decompressed = { total: 0 };
|
|
@@ -1105,9 +1122,9 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
1105
1122
|
const styleMap = await extractHwpxStyles(zip, decompressed);
|
|
1106
1123
|
const warnings = [];
|
|
1107
1124
|
const sectionPaths = await resolveSectionPaths(zip);
|
|
1108
|
-
if (sectionPaths.length === 0) throw new (0,
|
|
1125
|
+
if (sectionPaths.length === 0) throw new (0, _chunkRWSGBXSAcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
1109
1126
|
metadata.pageCount = sectionPaths.length;
|
|
1110
|
-
const pageFilter = _optionalChain([options, 'optionalAccess', _12 => _12.pages]) ?
|
|
1127
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _12 => _12.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
|
|
1111
1128
|
const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
|
|
1112
1129
|
const blocks = [];
|
|
1113
1130
|
const shared = createSectionShared();
|
|
@@ -1119,12 +1136,12 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
1119
1136
|
try {
|
|
1120
1137
|
const xml = await file.async("text");
|
|
1121
1138
|
decompressed.total += xml.length * 2;
|
|
1122
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1139
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkRWSGBXSAcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1123
1140
|
blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
|
|
1124
1141
|
parsedSections++;
|
|
1125
1142
|
_optionalChain([options, 'optionalAccess', _13 => _13.onProgress, 'optionalCall', _14 => _14(parsedSections, totalTarget)]);
|
|
1126
1143
|
} catch (secErr) {
|
|
1127
|
-
if (secErr instanceof
|
|
1144
|
+
if (secErr instanceof _chunkRWSGBXSAcjs.KordocError) throw secErr;
|
|
1128
1145
|
warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
|
|
1129
1146
|
}
|
|
1130
1147
|
}
|
|
@@ -1132,7 +1149,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
1132
1149
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
|
|
1133
1150
|
detectHwpxHeadings(blocks, styleMap);
|
|
1134
1151
|
const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
1135
|
-
const markdown =
|
|
1152
|
+
const markdown = _chunkRWSGBXSAcjs.blocksToMarkdown.call(void 0, blocks);
|
|
1136
1153
|
return { markdown, blocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
|
|
1137
1154
|
}
|
|
1138
1155
|
function applyPageText(blocks, shared) {
|
|
@@ -1221,13 +1238,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1221
1238
|
let found = false;
|
|
1222
1239
|
const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
|
|
1223
1240
|
for (const path of allCandidates) {
|
|
1224
|
-
if (
|
|
1241
|
+
if (_chunkRWSGBXSAcjs.isPathTraversal.call(void 0, path)) continue;
|
|
1225
1242
|
const file = zip.file(path);
|
|
1226
1243
|
if (!file) continue;
|
|
1227
1244
|
try {
|
|
1228
1245
|
const data = await file.async("uint8array");
|
|
1229
1246
|
decompressed.total += data.length;
|
|
1230
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1247
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkRWSGBXSAcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1231
1248
|
const actualPath = path;
|
|
1232
1249
|
const ext = actualPath.includes(".") ? actualPath.split(".").pop() || "png" : "png";
|
|
1233
1250
|
const mimeType = imageExtToMime(ext);
|
|
@@ -1240,7 +1257,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
|
|
|
1240
1257
|
found = true;
|
|
1241
1258
|
break;
|
|
1242
1259
|
} catch (err) {
|
|
1243
|
-
if (err instanceof
|
|
1260
|
+
if (err instanceof _chunkRWSGBXSAcjs.KordocError) throw err;
|
|
1244
1261
|
}
|
|
1245
1262
|
}
|
|
1246
1263
|
if (!found) {
|
|
@@ -1261,17 +1278,17 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
|
|
|
1261
1278
|
const xml = await file.async("text");
|
|
1262
1279
|
if (decompressed) {
|
|
1263
1280
|
decompressed.total += xml.length * 2;
|
|
1264
|
-
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1281
|
+
if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkRWSGBXSAcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
|
|
1265
1282
|
}
|
|
1266
1283
|
parseDublinCoreMetadata(xml, metadata);
|
|
1267
1284
|
if (metadata.title || metadata.author) return;
|
|
1268
1285
|
}
|
|
1269
|
-
} catch (
|
|
1286
|
+
} catch (e13) {
|
|
1270
1287
|
}
|
|
1271
1288
|
}
|
|
1272
1289
|
function parseDublinCoreMetadata(xml, metadata) {
|
|
1273
1290
|
const parser = createXmlParser();
|
|
1274
|
-
const doc = parser.parseFromString(
|
|
1291
|
+
const doc = parser.parseFromString(_chunkRWSGBXSAcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1275
1292
|
if (!doc.documentElement) return;
|
|
1276
1293
|
const getText = (tagNames) => {
|
|
1277
1294
|
for (const tag of tagNames) {
|
|
@@ -1331,7 +1348,7 @@ function extractFromBrokenZip(buffer) {
|
|
|
1331
1348
|
}
|
|
1332
1349
|
const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
|
|
1333
1350
|
const name = new TextDecoder().decode(nameBytes);
|
|
1334
|
-
if (
|
|
1351
|
+
if (_chunkRWSGBXSAcjs.isPathTraversal.call(void 0, name)) {
|
|
1335
1352
|
pos = fileStart + compSize;
|
|
1336
1353
|
continue;
|
|
1337
1354
|
}
|
|
@@ -1349,16 +1366,16 @@ function extractFromBrokenZip(buffer) {
|
|
|
1349
1366
|
continue;
|
|
1350
1367
|
}
|
|
1351
1368
|
totalDecompressed += content.length * 2;
|
|
1352
|
-
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0,
|
|
1369
|
+
if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkRWSGBXSAcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
|
|
1353
1370
|
sectionNum++;
|
|
1354
1371
|
blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
|
|
1355
|
-
} catch (
|
|
1372
|
+
} catch (e14) {
|
|
1356
1373
|
continue;
|
|
1357
1374
|
}
|
|
1358
1375
|
}
|
|
1359
|
-
if (blocks.length === 0) throw new (0,
|
|
1376
|
+
if (blocks.length === 0) throw new (0, _chunkRWSGBXSAcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
1360
1377
|
applyPageText(blocks, shared);
|
|
1361
|
-
const markdown =
|
|
1378
|
+
const markdown = _chunkRWSGBXSAcjs.blocksToMarkdown.call(void 0, blocks);
|
|
1362
1379
|
return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
1363
1380
|
}
|
|
1364
1381
|
async function resolveSectionPaths(zip) {
|
|
@@ -1372,24 +1389,19 @@ async function resolveSectionPaths(zip) {
|
|
|
1372
1389
|
if (paths.length > 0) return paths;
|
|
1373
1390
|
}
|
|
1374
1391
|
const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
|
|
1375
|
-
return sectionFiles.map((f) => f.name).sort();
|
|
1392
|
+
return sectionFiles.map((f) => f.name).sort(_chunkRWSGBXSAcjs.compareSectionPaths);
|
|
1376
1393
|
}
|
|
1377
1394
|
function parseSectionPathsFromManifest(xml) {
|
|
1378
1395
|
const parser = createXmlParser();
|
|
1379
|
-
const doc = parser.parseFromString(
|
|
1396
|
+
const doc = parser.parseFromString(_chunkRWSGBXSAcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1380
1397
|
const items = doc.getElementsByTagName("opf:item");
|
|
1381
1398
|
const spine = doc.getElementsByTagName("opf:itemref");
|
|
1382
|
-
const isSectionId = (id) => /^s/i.test(id) || id.toLowerCase().includes("section");
|
|
1383
1399
|
const idToHref = /* @__PURE__ */ new Map();
|
|
1384
1400
|
for (let i = 0; i < items.length; i++) {
|
|
1385
1401
|
const item = items[i];
|
|
1386
1402
|
const id = item.getAttribute("id") || "";
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
if (!isSectionId(id) && !mediaType.includes("xml")) continue;
|
|
1390
|
-
if (!href.startsWith("/") && !href.startsWith("Contents/") && isSectionId(id))
|
|
1391
|
-
href = "Contents/" + href;
|
|
1392
|
-
idToHref.set(id, href);
|
|
1403
|
+
const href = _chunkRWSGBXSAcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
|
|
1404
|
+
if (id && href) idToHref.set(id, href);
|
|
1393
1405
|
}
|
|
1394
1406
|
if (spine.length > 0) {
|
|
1395
1407
|
const ordered = [];
|
|
@@ -1399,7 +1411,7 @@ function parseSectionPathsFromManifest(xml) {
|
|
|
1399
1411
|
}
|
|
1400
1412
|
if (ordered.length > 0) return ordered;
|
|
1401
1413
|
}
|
|
1402
|
-
return Array.from(idToHref.
|
|
1414
|
+
return Array.from(idToHref.values()).sort(_chunkRWSGBXSAcjs.compareSectionPaths);
|
|
1403
1415
|
}
|
|
1404
1416
|
function detectHwpxHeadings(blocks, styleMap) {
|
|
1405
1417
|
if (blocks.some((b) => b.type === "heading")) return;
|
|
@@ -1424,9 +1436,9 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
1424
1436
|
let level = 0;
|
|
1425
1437
|
if (baseFontSize > 0 && _optionalChain([block, 'access', _25 => _25.style, 'optionalAccess', _26 => _26.fontSize])) {
|
|
1426
1438
|
const ratio = block.style.fontSize / baseFontSize;
|
|
1427
|
-
if (ratio >=
|
|
1428
|
-
else if (ratio >=
|
|
1429
|
-
else if (ratio >=
|
|
1439
|
+
if (ratio >= _chunkRWSGBXSAcjs.HEADING_RATIO_H1) level = 1;
|
|
1440
|
+
else if (ratio >= _chunkRWSGBXSAcjs.HEADING_RATIO_H2) level = 2;
|
|
1441
|
+
else if (ratio >= _chunkRWSGBXSAcjs.HEADING_RATIO_H3) level = 3;
|
|
1430
1442
|
}
|
|
1431
1443
|
const compactText = text.replace(/\s+/g, "");
|
|
1432
1444
|
if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
|
|
@@ -1439,7 +1451,7 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
1439
1451
|
}
|
|
1440
1452
|
}
|
|
1441
1453
|
function buildTableWithCellMeta(state) {
|
|
1442
|
-
const table =
|
|
1454
|
+
const table = _chunkRWSGBXSAcjs.buildTable.call(void 0, state.rows);
|
|
1443
1455
|
if (state.caption) table.caption = state.caption;
|
|
1444
1456
|
const claimed = /* @__PURE__ */ new Set();
|
|
1445
1457
|
for (const row of state.rows) {
|
|
@@ -1482,7 +1494,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1482
1494
|
const cell = parentTable.cell;
|
|
1483
1495
|
(cell.blocks ??= []).push(block);
|
|
1484
1496
|
cell.hasStructure = true;
|
|
1485
|
-
let flat =
|
|
1497
|
+
let flat = _chunkRWSGBXSAcjs.convertTableToText.call(void 0, newTable.rows);
|
|
1486
1498
|
if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
|
|
1487
1499
|
if (flat) cell.text += (cell.text ? "\n" : "") + flat;
|
|
1488
1500
|
} else {
|
|
@@ -1492,7 +1504,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
|
|
|
1492
1504
|
}
|
|
1493
1505
|
function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
|
|
1494
1506
|
const parser = createXmlParser(warnings);
|
|
1495
|
-
const doc = parser.parseFromString(
|
|
1507
|
+
const doc = parser.parseFromString(_chunkRWSGBXSAcjs.stripDtd.call(void 0, xml), "text/xml");
|
|
1496
1508
|
if (!doc.documentElement) return [];
|
|
1497
1509
|
const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
|
|
1498
1510
|
ctx.shared.track.deleteDepth = 0;
|
|
@@ -1583,8 +1595,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
1583
1595
|
const cs = isNaN(rawCs) ? 1 : rawCs;
|
|
1584
1596
|
const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
|
|
1585
1597
|
const rs = isNaN(rawRs) ? 1 : rawRs;
|
|
1586
|
-
tableCtx.cell.colSpan = clampSpan(cs,
|
|
1587
|
-
tableCtx.cell.rowSpan = clampSpan(rs,
|
|
1598
|
+
tableCtx.cell.colSpan = clampSpan(cs, _chunkRWSGBXSAcjs.MAX_COLS);
|
|
1599
|
+
tableCtx.cell.rowSpan = clampSpan(rs, _chunkRWSGBXSAcjs.MAX_ROWS);
|
|
1588
1600
|
}
|
|
1589
1601
|
break;
|
|
1590
1602
|
case "p": {
|
|
@@ -1806,7 +1818,7 @@ function extractHyperlinkHref(fieldBegin) {
|
|
|
1806
1818
|
let url = (ch.textContent || "").trim();
|
|
1807
1819
|
if (!url) continue;
|
|
1808
1820
|
url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
|
|
1809
|
-
const safe =
|
|
1821
|
+
const safe = _chunkRWSGBXSAcjs.sanitizeHref.call(void 0, url);
|
|
1810
1822
|
if (safe) return safe;
|
|
1811
1823
|
}
|
|
1812
1824
|
return void 0;
|
|
@@ -1941,7 +1953,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
|
|
|
1941
1953
|
case "hyperlink": {
|
|
1942
1954
|
const url = child.getAttribute("url") || child.getAttribute("href") || "";
|
|
1943
1955
|
if (url) {
|
|
1944
|
-
const safe =
|
|
1956
|
+
const safe = _chunkRWSGBXSAcjs.sanitizeHref.call(void 0, url);
|
|
1945
1957
|
if (safe) href = safe;
|
|
1946
1958
|
}
|
|
1947
1959
|
walk(child);
|
|
@@ -2006,7 +2018,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
|
|
|
2006
2018
|
try {
|
|
2007
2019
|
const latex = hmlToLatex(raw).trim();
|
|
2008
2020
|
if (latex) text += " $" + latex + "$ ";
|
|
2009
|
-
} catch (
|
|
2021
|
+
} catch (e15) {
|
|
2010
2022
|
}
|
|
2011
2023
|
}
|
|
2012
2024
|
break;
|
|
@@ -2125,13 +2137,13 @@ function decompressStream(data) {
|
|
|
2125
2137
|
if (data.length >= 2 && data[0] === 120) {
|
|
2126
2138
|
try {
|
|
2127
2139
|
return _zlib.inflateSync.call(void 0, data, opts);
|
|
2128
|
-
} catch (
|
|
2140
|
+
} catch (e16) {
|
|
2129
2141
|
}
|
|
2130
2142
|
}
|
|
2131
2143
|
return _zlib.inflateRawSync.call(void 0, data, opts);
|
|
2132
2144
|
}
|
|
2133
2145
|
function parseFileHeader(data) {
|
|
2134
|
-
if (data.length < 40) throw new (0,
|
|
2146
|
+
if (data.length < 40) throw new (0, _chunkRWSGBXSAcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
|
|
2135
2147
|
const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
|
|
2136
2148
|
return {
|
|
2137
2149
|
signature: sig,
|
|
@@ -2245,7 +2257,7 @@ function parseDocInfo(records) {
|
|
|
2245
2257
|
offset += 2;
|
|
2246
2258
|
const charShapeId = offset + 2 <= rec.data.length ? rec.data.readUInt16LE(offset) : 0;
|
|
2247
2259
|
styles.push({ name, nameKo, charShapeId, paraShapeId, type });
|
|
2248
|
-
} catch (
|
|
2260
|
+
} catch (e17) {
|
|
2249
2261
|
}
|
|
2250
2262
|
}
|
|
2251
2263
|
}
|
|
@@ -2545,7 +2557,7 @@ function normalizeBinPayload(data) {
|
|
|
2545
2557
|
try {
|
|
2546
2558
|
const inflated = decompressStream(data);
|
|
2547
2559
|
if (inflated.length > 0) return inflated;
|
|
2548
|
-
} catch (
|
|
2560
|
+
} catch (e18) {
|
|
2549
2561
|
}
|
|
2550
2562
|
return data;
|
|
2551
2563
|
}
|
|
@@ -3354,7 +3366,7 @@ function decryptViewText(viewTextRaw, compressed) {
|
|
|
3354
3366
|
if (compressed) {
|
|
3355
3367
|
try {
|
|
3356
3368
|
return decompressStream(Buffer.from(decrypted));
|
|
3357
|
-
} catch (
|
|
3369
|
+
} catch (e19) {
|
|
3358
3370
|
return Buffer.from(decrypted);
|
|
3359
3371
|
}
|
|
3360
3372
|
}
|
|
@@ -3650,12 +3662,12 @@ function parseHwp5Document(buffer, options) {
|
|
|
3650
3662
|
const warnings = [];
|
|
3651
3663
|
try {
|
|
3652
3664
|
cfb = CFB.parse(buffer);
|
|
3653
|
-
} catch (
|
|
3665
|
+
} catch (e20) {
|
|
3654
3666
|
try {
|
|
3655
3667
|
lenientCfb = parseLenientCfb(buffer);
|
|
3656
3668
|
warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
|
|
3657
|
-
} catch (
|
|
3658
|
-
throw new (0,
|
|
3669
|
+
} catch (e21) {
|
|
3670
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
|
|
3659
3671
|
}
|
|
3660
3672
|
}
|
|
3661
3673
|
const findStream = (path) => {
|
|
@@ -3666,11 +3678,11 @@ function parseHwp5Document(buffer, options) {
|
|
|
3666
3678
|
return lenientCfb.findStream(path);
|
|
3667
3679
|
};
|
|
3668
3680
|
const headerData = findStream("/FileHeader");
|
|
3669
|
-
if (!headerData) throw new (0,
|
|
3681
|
+
if (!headerData) throw new (0, _chunkRWSGBXSAcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
|
|
3670
3682
|
const header = parseFileHeader(headerData);
|
|
3671
|
-
if (header.signature !== "HWP Document File") throw new (0,
|
|
3672
|
-
if (header.flags & FLAG_ENCRYPTED) throw new (0,
|
|
3673
|
-
if (header.flags & FLAG_DRM) throw new (0,
|
|
3683
|
+
if (header.signature !== "HWP Document File") throw new (0, _chunkRWSGBXSAcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
3684
|
+
if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkRWSGBXSAcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3685
|
+
if (header.flags & FLAG_DRM) throw new (0, _chunkRWSGBXSAcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
3674
3686
|
const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
|
|
3675
3687
|
const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
|
|
3676
3688
|
const metadata = {
|
|
@@ -3679,9 +3691,9 @@ function parseHwp5Document(buffer, options) {
|
|
|
3679
3691
|
if (cfb) extractHwp5Metadata(cfb, metadata);
|
|
3680
3692
|
const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
|
|
3681
3693
|
const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
|
|
3682
|
-
if (sections.length === 0) throw new (0,
|
|
3694
|
+
if (sections.length === 0) throw new (0, _chunkRWSGBXSAcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
3683
3695
|
metadata.pageCount = sections.length;
|
|
3684
|
-
const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ?
|
|
3696
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
|
|
3685
3697
|
const totalTarget = pageFilter ? pageFilter.size : sections.length;
|
|
3686
3698
|
const bodyBlocks = [];
|
|
3687
3699
|
const doc = createHwp5DocState();
|
|
@@ -3693,25 +3705,25 @@ function parseHwp5Document(buffer, options) {
|
|
|
3693
3705
|
const sectionData = sections[si];
|
|
3694
3706
|
const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
|
|
3695
3707
|
totalDecompressed += data.length;
|
|
3696
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3708
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkRWSGBXSAcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3697
3709
|
const records = readRecords(data);
|
|
3698
3710
|
const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
|
|
3699
3711
|
bodyBlocks.push(...sectionBlocks);
|
|
3700
3712
|
parsedSections++;
|
|
3701
3713
|
_optionalChain([options, 'optionalAccess', _52 => _52.onProgress, 'optionalCall', _53 => _53(parsedSections, totalTarget)]);
|
|
3702
3714
|
} catch (secErr) {
|
|
3703
|
-
if (secErr instanceof
|
|
3715
|
+
if (secErr instanceof _chunkRWSGBXSAcjs.KordocError) throw secErr;
|
|
3704
3716
|
warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
|
|
3705
3717
|
}
|
|
3706
3718
|
}
|
|
3707
3719
|
const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
|
|
3708
3720
|
const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
|
|
3709
|
-
const flatBlocks =
|
|
3721
|
+
const flatBlocks = _chunkRWSGBXSAcjs.flattenLayoutTables.call(void 0, blocks);
|
|
3710
3722
|
if (docInfo) {
|
|
3711
3723
|
detectHwp5Headings(flatBlocks, docInfo);
|
|
3712
3724
|
}
|
|
3713
3725
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3714
|
-
const markdown =
|
|
3726
|
+
const markdown = _chunkRWSGBXSAcjs.blocksToMarkdown.call(void 0, flatBlocks);
|
|
3715
3727
|
return { markdown, blocks: flatBlocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
|
|
3716
3728
|
}
|
|
3717
3729
|
function parseDocInfoStream(cfb, compressed) {
|
|
@@ -3721,7 +3733,7 @@ function parseDocInfoStream(cfb, compressed) {
|
|
|
3721
3733
|
const data = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
3722
3734
|
const records = readRecords(data);
|
|
3723
3735
|
return parseDocInfo(records);
|
|
3724
|
-
} catch (
|
|
3736
|
+
} catch (e22) {
|
|
3725
3737
|
return null;
|
|
3726
3738
|
}
|
|
3727
3739
|
}
|
|
@@ -3730,7 +3742,7 @@ function parseDocInfoFromStream(raw, compressed) {
|
|
|
3730
3742
|
try {
|
|
3731
3743
|
const data = compressed ? decompressStream(raw) : raw;
|
|
3732
3744
|
return parseDocInfo(readRecords(data));
|
|
3733
|
-
} catch (
|
|
3745
|
+
} catch (e23) {
|
|
3734
3746
|
return null;
|
|
3735
3747
|
}
|
|
3736
3748
|
}
|
|
@@ -3771,9 +3783,9 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
3771
3783
|
let level = 0;
|
|
3772
3784
|
if (_optionalChain([block, 'access', _58 => _58.style, 'optionalAccess', _59 => _59.fontSize]) && baseFontSize > 0) {
|
|
3773
3785
|
const ratio = block.style.fontSize / baseFontSize;
|
|
3774
|
-
if (ratio >=
|
|
3775
|
-
else if (ratio >=
|
|
3776
|
-
else if (ratio >=
|
|
3786
|
+
if (ratio >= _chunkRWSGBXSAcjs.HEADING_RATIO_H1) level = 1;
|
|
3787
|
+
else if (ratio >= _chunkRWSGBXSAcjs.HEADING_RATIO_H2) level = 2;
|
|
3788
|
+
else if (ratio >= _chunkRWSGBXSAcjs.HEADING_RATIO_H3) level = 3;
|
|
3777
3789
|
}
|
|
3778
3790
|
if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
|
|
3779
3791
|
if (level === 0) level = 2;
|
|
@@ -3815,7 +3827,7 @@ function extractHwp5Metadata(cfb, metadata) {
|
|
|
3815
3827
|
else if (propId === 4) metadata.author = str;
|
|
3816
3828
|
else if (propId === 6) metadata.description = str;
|
|
3817
3829
|
}
|
|
3818
|
-
} catch (
|
|
3830
|
+
} catch (e24) {
|
|
3819
3831
|
}
|
|
3820
3832
|
}
|
|
3821
3833
|
function findViewTextSections(cfb, compressed) {
|
|
@@ -3826,7 +3838,7 @@ function findViewTextSections(cfb, compressed) {
|
|
|
3826
3838
|
try {
|
|
3827
3839
|
const decrypted = decryptViewText(Buffer.from(entry.content), compressed);
|
|
3828
3840
|
sections.push({ idx: i, content: decrypted });
|
|
3829
|
-
} catch (
|
|
3841
|
+
} catch (e25) {
|
|
3830
3842
|
break;
|
|
3831
3843
|
}
|
|
3832
3844
|
}
|
|
@@ -3858,7 +3870,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3858
3870
|
if (!raw) break;
|
|
3859
3871
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3860
3872
|
totalDecompressed += content.length;
|
|
3861
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3873
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkRWSGBXSAcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3862
3874
|
sections.push({ idx: i, content });
|
|
3863
3875
|
}
|
|
3864
3876
|
if (sections.length === 0) {
|
|
@@ -3870,7 +3882,7 @@ function findSectionsLenient(lcfb, compressed) {
|
|
|
3870
3882
|
if (raw) {
|
|
3871
3883
|
const content = compressed ? decompressStream(raw) : raw;
|
|
3872
3884
|
totalDecompressed += content.length;
|
|
3873
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3885
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkRWSGBXSAcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3874
3886
|
sections.push({ idx, content });
|
|
3875
3887
|
}
|
|
3876
3888
|
}
|
|
@@ -3887,9 +3899,9 @@ function findViewTextSectionsLenient(lcfb, compressed) {
|
|
|
3887
3899
|
try {
|
|
3888
3900
|
const content = decryptViewText(raw, compressed);
|
|
3889
3901
|
totalDecompressed += content.length;
|
|
3890
|
-
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0,
|
|
3902
|
+
if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkRWSGBXSAcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
|
|
3891
3903
|
sections.push({ idx: i, content });
|
|
3892
|
-
} catch (
|
|
3904
|
+
} catch (e26) {
|
|
3893
3905
|
break;
|
|
3894
3906
|
}
|
|
3895
3907
|
}
|
|
@@ -3990,7 +4002,7 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
3990
4002
|
const ctrl = ctrls[r.ctrlIdx];
|
|
3991
4003
|
if (!_optionalChain([ctrl, 'optionalAccess', _66 => _66.href]) || r.end <= r.start) continue;
|
|
3992
4004
|
if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
|
|
3993
|
-
const href =
|
|
4005
|
+
const href = _chunkRWSGBXSAcjs.sanitizeHref.call(void 0, ctrl.href);
|
|
3994
4006
|
if (!href) continue;
|
|
3995
4007
|
const anchor = text.slice(r.start, r.end);
|
|
3996
4008
|
if (!anchor.trim()) continue;
|
|
@@ -4223,8 +4235,8 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4223
4235
|
let tableIdx = -1;
|
|
4224
4236
|
for (let i2 = childStart; i2 < childEnd; i2++) {
|
|
4225
4237
|
if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
|
|
4226
|
-
rows = Math.min(records[i2].data.readUInt16LE(4),
|
|
4227
|
-
cols = Math.min(records[i2].data.readUInt16LE(6),
|
|
4238
|
+
rows = Math.min(records[i2].data.readUInt16LE(4), _chunkRWSGBXSAcjs.MAX_ROWS);
|
|
4239
|
+
cols = Math.min(records[i2].data.readUInt16LE(6), _chunkRWSGBXSAcjs.MAX_COLS);
|
|
4228
4240
|
tableIdx = i2;
|
|
4229
4241
|
break;
|
|
4230
4242
|
}
|
|
@@ -4273,7 +4285,7 @@ function parseTableControl(ctrl, records, ctx) {
|
|
|
4273
4285
|
return table2;
|
|
4274
4286
|
}
|
|
4275
4287
|
const cellRows = arrangeCells(rows, cols, cells);
|
|
4276
|
-
const table =
|
|
4288
|
+
const table = _chunkRWSGBXSAcjs.buildTable.call(void 0, cellRows);
|
|
4277
4289
|
if (caption && table.rows > 0) table.caption = caption;
|
|
4278
4290
|
return table.rows > 0 ? table : null;
|
|
4279
4291
|
}
|
|
@@ -4290,8 +4302,8 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4290
4302
|
rowAddr = rec.data.readUInt16LE(10);
|
|
4291
4303
|
const cs = rec.data.readUInt16LE(12);
|
|
4292
4304
|
const rs = rec.data.readUInt16LE(14);
|
|
4293
|
-
if (cs > 0) colSpan = Math.min(cs,
|
|
4294
|
-
if (rs > 0) rowSpan = Math.min(rs,
|
|
4305
|
+
if (cs > 0) colSpan = Math.min(cs, _chunkRWSGBXSAcjs.MAX_COLS);
|
|
4306
|
+
if (rs > 0) rowSpan = Math.min(rs, _chunkRWSGBXSAcjs.MAX_ROWS);
|
|
4295
4307
|
}
|
|
4296
4308
|
const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
|
|
4297
4309
|
const parts = [];
|
|
@@ -4301,7 +4313,7 @@ function parseCell(records, lhIdx, end, ctx) {
|
|
|
4301
4313
|
parts.push(``);
|
|
4302
4314
|
hasStructure = true;
|
|
4303
4315
|
} else if (b.type === "table" && b.table) {
|
|
4304
|
-
const flat =
|
|
4316
|
+
const flat = _chunkRWSGBXSAcjs.convertTableToText.call(void 0, b.table.cells);
|
|
4305
4317
|
if (flat) parts.push(flat);
|
|
4306
4318
|
hasStructure = true;
|
|
4307
4319
|
} else if (b.text) {
|
|
@@ -16735,7 +16747,7 @@ function getTextContent(el) {
|
|
|
16735
16747
|
return _nullishCoalesce(_optionalChain([el, 'access', _79 => _79.textContent, 'optionalAccess', _80 => _80.trim, 'call', _81 => _81()]), () => ( ""));
|
|
16736
16748
|
}
|
|
16737
16749
|
function parseXml(text) {
|
|
16738
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
16750
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkRWSGBXSAcjs.stripDtd.call(void 0, text), "text/xml");
|
|
16739
16751
|
}
|
|
16740
16752
|
function parseSharedStrings(xml) {
|
|
16741
16753
|
const doc = parseXml(xml);
|
|
@@ -16879,7 +16891,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16879
16891
|
cellRows.push(row);
|
|
16880
16892
|
}
|
|
16881
16893
|
if (cellRows.length > 0) {
|
|
16882
|
-
const table =
|
|
16894
|
+
const table = _chunkRWSGBXSAcjs.buildTable.call(void 0, cellRows);
|
|
16883
16895
|
if (table.rows > 0) {
|
|
16884
16896
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
16885
16897
|
}
|
|
@@ -16887,12 +16899,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
|
|
|
16887
16899
|
return blocks;
|
|
16888
16900
|
}
|
|
16889
16901
|
async function parseXlsxDocument(buffer, options) {
|
|
16890
|
-
|
|
16902
|
+
_chunkRWSGBXSAcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
|
|
16891
16903
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
16892
16904
|
const warnings = [];
|
|
16893
16905
|
const workbookFile = zip.file("xl/workbook.xml");
|
|
16894
16906
|
if (!workbookFile) {
|
|
16895
|
-
throw new (0,
|
|
16907
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16896
16908
|
}
|
|
16897
16909
|
let sharedStrings = [];
|
|
16898
16910
|
const ssFile = zip.file("xl/sharedStrings.xml");
|
|
@@ -16901,7 +16913,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16901
16913
|
}
|
|
16902
16914
|
const sheets = parseWorkbook(await workbookFile.async("text"));
|
|
16903
16915
|
if (sheets.length === 0) {
|
|
16904
|
-
throw new (0,
|
|
16916
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
16905
16917
|
}
|
|
16906
16918
|
let relsMap = /* @__PURE__ */ new Map();
|
|
16907
16919
|
const relsFile = zip.file("xl/_rels/workbook.xml.rels");
|
|
@@ -16910,7 +16922,7 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16910
16922
|
}
|
|
16911
16923
|
let pageFilter = null;
|
|
16912
16924
|
if (_optionalChain([options, 'optionalAccess', _84 => _84.pages])) {
|
|
16913
|
-
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-
|
|
16925
|
+
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
16914
16926
|
pageFilter = parsePageRange2(options.pages, sheets.length);
|
|
16915
16927
|
}
|
|
16916
16928
|
const blocks = [];
|
|
@@ -16970,10 +16982,10 @@ async function parseXlsxDocument(buffer, options) {
|
|
|
16970
16982
|
if (created) metadata.createdAt = created;
|
|
16971
16983
|
const modified = getFirst("dcterms:modified");
|
|
16972
16984
|
if (modified) metadata.modifiedAt = modified;
|
|
16973
|
-
} catch (
|
|
16985
|
+
} catch (e27) {
|
|
16974
16986
|
}
|
|
16975
16987
|
}
|
|
16976
|
-
const markdown =
|
|
16988
|
+
const markdown = _chunkRWSGBXSAcjs.blocksToMarkdown.call(void 0, blocks);
|
|
16977
16989
|
return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
|
|
16978
16990
|
}
|
|
16979
16991
|
|
|
@@ -17380,11 +17392,11 @@ function processGlobals(records) {
|
|
|
17380
17392
|
let encrypted = false;
|
|
17381
17393
|
const firstBof = records[0];
|
|
17382
17394
|
if (!firstBof || firstBof.opcode !== OP_BOF) {
|
|
17383
|
-
throw new (0,
|
|
17395
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
|
|
17384
17396
|
}
|
|
17385
17397
|
const bof = decodeBof(firstBof.data);
|
|
17386
17398
|
if (!bof || bof.dt !== DT_GLOBALS) {
|
|
17387
|
-
throw new (0,
|
|
17399
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
|
|
17388
17400
|
}
|
|
17389
17401
|
let i = 1;
|
|
17390
17402
|
while (i < records.length) {
|
|
@@ -17499,7 +17511,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
|
|
|
17499
17511
|
cellRows.push(row);
|
|
17500
17512
|
}
|
|
17501
17513
|
if (cellRows.length > 0) {
|
|
17502
|
-
const table =
|
|
17514
|
+
const table = _chunkRWSGBXSAcjs.buildTable.call(void 0, cellRows);
|
|
17503
17515
|
if (table.rows > 0) {
|
|
17504
17516
|
blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
|
|
17505
17517
|
}
|
|
@@ -17512,21 +17524,21 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17512
17524
|
try {
|
|
17513
17525
|
cfb = parseLenientCfb(buf);
|
|
17514
17526
|
} catch (e) {
|
|
17515
|
-
throw new (0,
|
|
17527
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)(
|
|
17516
17528
|
`XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
|
|
17517
17529
|
);
|
|
17518
17530
|
}
|
|
17519
17531
|
const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
|
|
17520
17532
|
if (!wb) {
|
|
17521
|
-
throw new (0,
|
|
17533
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
|
|
17522
17534
|
}
|
|
17523
17535
|
const records = readRecords2(wb);
|
|
17524
17536
|
if (records.length === 0) {
|
|
17525
|
-
throw new (0,
|
|
17537
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
|
|
17526
17538
|
}
|
|
17527
17539
|
const firstBof = decodeBof(records[0].data);
|
|
17528
17540
|
if (firstBof && firstBof.vers !== 1536) {
|
|
17529
|
-
throw new (0,
|
|
17541
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)(
|
|
17530
17542
|
`XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
|
|
17531
17543
|
);
|
|
17532
17544
|
}
|
|
@@ -17548,7 +17560,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17548
17560
|
const totalSheets = Math.min(globals.sheets.length, MAX_SHEETS2);
|
|
17549
17561
|
let pageFilter = null;
|
|
17550
17562
|
if (_optionalChain([options, 'optionalAccess', _89 => _89.pages])) {
|
|
17551
|
-
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-
|
|
17563
|
+
const { parsePageRange: parsePageRange2 } = await Promise.resolve().then(() => _interopRequireWildcard(require("./page-range-P7SDW6LR.cjs")));
|
|
17552
17564
|
pageFilter = parsePageRange2(options.pages, totalSheets);
|
|
17553
17565
|
}
|
|
17554
17566
|
const allBlocks = [];
|
|
@@ -17586,7 +17598,7 @@ async function parseXlsDocument(buffer, options) {
|
|
|
17586
17598
|
pageCount: totalSheets
|
|
17587
17599
|
};
|
|
17588
17600
|
return {
|
|
17589
|
-
markdown:
|
|
17601
|
+
markdown: _chunkRWSGBXSAcjs.blocksToMarkdown.call(void 0, allBlocks),
|
|
17590
17602
|
blocks: allBlocks,
|
|
17591
17603
|
metadata,
|
|
17592
17604
|
warnings: warnings.length > 0 ? warnings : void 0
|
|
@@ -18024,7 +18036,7 @@ function getAttr(el, localName2) {
|
|
|
18024
18036
|
return null;
|
|
18025
18037
|
}
|
|
18026
18038
|
function parseXml2(text) {
|
|
18027
|
-
return new (0, _xmldom.DOMParser)().parseFromString(
|
|
18039
|
+
return new (0, _xmldom.DOMParser)().parseFromString(_chunkRWSGBXSAcjs.stripDtd.call(void 0, text), "text/xml");
|
|
18028
18040
|
}
|
|
18029
18041
|
function parseStyles(xml) {
|
|
18030
18042
|
const doc = parseXml2(xml);
|
|
@@ -18336,19 +18348,19 @@ async function extractImages(zip, rels, doc) {
|
|
|
18336
18348
|
const filename = `image_${String(imgIdx).padStart(3, "0")}.${ext}`;
|
|
18337
18349
|
images.push({ filename, data, mimeType: _nullishCoalesce(mimeMap[ext], () => ( "image/png")) });
|
|
18338
18350
|
blocks.push({ type: "image", text: filename });
|
|
18339
|
-
} catch (
|
|
18351
|
+
} catch (e28) {
|
|
18340
18352
|
}
|
|
18341
18353
|
}
|
|
18342
18354
|
}
|
|
18343
18355
|
return { blocks, images };
|
|
18344
18356
|
}
|
|
18345
18357
|
async function parseDocxDocument(buffer, options) {
|
|
18346
|
-
|
|
18358
|
+
_chunkRWSGBXSAcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
|
|
18347
18359
|
const zip = await _jszip2.default.loadAsync(buffer);
|
|
18348
18360
|
const warnings = [];
|
|
18349
18361
|
const docFile = zip.file("word/document.xml");
|
|
18350
18362
|
if (!docFile) {
|
|
18351
|
-
throw new (0,
|
|
18363
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18352
18364
|
}
|
|
18353
18365
|
let rels = /* @__PURE__ */ new Map();
|
|
18354
18366
|
const relsFile = zip.file("word/_rels/document.xml.rels");
|
|
@@ -18360,7 +18372,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18360
18372
|
if (stylesFile) {
|
|
18361
18373
|
try {
|
|
18362
18374
|
styles = parseStyles(await stylesFile.async("text"));
|
|
18363
|
-
} catch (
|
|
18375
|
+
} catch (e29) {
|
|
18364
18376
|
}
|
|
18365
18377
|
}
|
|
18366
18378
|
let numbering = /* @__PURE__ */ new Map();
|
|
@@ -18368,7 +18380,7 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18368
18380
|
if (numFile) {
|
|
18369
18381
|
try {
|
|
18370
18382
|
numbering = parseNumbering(await numFile.async("text"));
|
|
18371
|
-
} catch (
|
|
18383
|
+
} catch (e30) {
|
|
18372
18384
|
}
|
|
18373
18385
|
}
|
|
18374
18386
|
let footnotes = /* @__PURE__ */ new Map();
|
|
@@ -18376,14 +18388,14 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18376
18388
|
if (fnFile) {
|
|
18377
18389
|
try {
|
|
18378
18390
|
footnotes = parseFootnotes(await fnFile.async("text"));
|
|
18379
|
-
} catch (
|
|
18391
|
+
} catch (e31) {
|
|
18380
18392
|
}
|
|
18381
18393
|
}
|
|
18382
18394
|
const docXml = await docFile.async("text");
|
|
18383
18395
|
const doc = parseXml2(docXml);
|
|
18384
18396
|
const body = findElements(doc, "body");
|
|
18385
18397
|
if (body.length === 0) {
|
|
18386
|
-
throw new (0,
|
|
18398
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
18387
18399
|
}
|
|
18388
18400
|
const blocks = [];
|
|
18389
18401
|
const bodyEl = body[0];
|
|
@@ -18416,11 +18428,11 @@ async function parseDocxDocument(buffer, options) {
|
|
|
18416
18428
|
if (created) metadata.createdAt = created;
|
|
18417
18429
|
const modified = getFirst("dcterms:modified");
|
|
18418
18430
|
if (modified) metadata.modifiedAt = modified;
|
|
18419
|
-
} catch (
|
|
18431
|
+
} catch (e32) {
|
|
18420
18432
|
}
|
|
18421
18433
|
}
|
|
18422
18434
|
const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
|
|
18423
|
-
const markdown =
|
|
18435
|
+
const markdown = _chunkRWSGBXSAcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18424
18436
|
return {
|
|
18425
18437
|
markdown,
|
|
18426
18438
|
blocks,
|
|
@@ -18443,7 +18455,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18443
18455
|
}
|
|
18444
18456
|
const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
|
|
18445
18457
|
const normalized = text.replace(/ /g, " ");
|
|
18446
|
-
const xml =
|
|
18458
|
+
const xml = _chunkRWSGBXSAcjs.stripDtd.call(void 0, normalized);
|
|
18447
18459
|
const warnings = [];
|
|
18448
18460
|
const parser = new (0, _xmldom.DOMParser)({
|
|
18449
18461
|
onError: (_level, msg2) => {
|
|
@@ -18471,7 +18483,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18471
18483
|
return { markdown: "", blocks: [], metadata, warnings };
|
|
18472
18484
|
}
|
|
18473
18485
|
const blocks = [];
|
|
18474
|
-
const pageFilter = _optionalChain([options, 'optionalAccess', _123 => _123.pages]) ?
|
|
18486
|
+
const pageFilter = _optionalChain([options, 'optionalAccess', _123 => _123.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, countSections(body)) : null;
|
|
18475
18487
|
let sectionIdx = 0;
|
|
18476
18488
|
const children = body.childNodes;
|
|
18477
18489
|
for (let i = 0; i < children.length; i++) {
|
|
@@ -18483,7 +18495,7 @@ function parseHwpmlDocument(buffer, options) {
|
|
|
18483
18495
|
parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
|
|
18484
18496
|
}
|
|
18485
18497
|
const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
|
|
18486
|
-
const markdown =
|
|
18498
|
+
const markdown = _chunkRWSGBXSAcjs.blocksToMarkdown.call(void 0, blocks);
|
|
18487
18499
|
return {
|
|
18488
18500
|
markdown,
|
|
18489
18501
|
blocks,
|
|
@@ -18625,7 +18637,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
|
|
|
18625
18637
|
const cellRows = grid.map(
|
|
18626
18638
|
(row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
|
|
18627
18639
|
);
|
|
18628
|
-
const table =
|
|
18640
|
+
const table = _chunkRWSGBXSAcjs.buildTable.call(void 0, cellRows);
|
|
18629
18641
|
blocks.push({ type: "table", table, pageNumber: sectionNum });
|
|
18630
18642
|
}
|
|
18631
18643
|
function extractCellText(cellEl) {
|
|
@@ -19135,7 +19147,7 @@ function decodeXmlEntities(text) {
|
|
|
19135
19147
|
try {
|
|
19136
19148
|
const code = ent[1] === "x" || ent[1] === "X" ? parseInt(ent.slice(2), 16) : parseInt(ent.slice(1), 10);
|
|
19137
19149
|
if (!isNaN(code) && code >= 0 && code <= 1114111) return String.fromCodePoint(code);
|
|
19138
|
-
} catch (
|
|
19150
|
+
} catch (e33) {
|
|
19139
19151
|
}
|
|
19140
19152
|
return m;
|
|
19141
19153
|
});
|
|
@@ -19652,19 +19664,19 @@ function parseCentralDirectory(buf) {
|
|
|
19652
19664
|
}
|
|
19653
19665
|
}
|
|
19654
19666
|
}
|
|
19655
|
-
if (eocdOffset < 0) throw new (0,
|
|
19667
|
+
if (eocdOffset < 0) throw new (0, _chunkRWSGBXSAcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19656
19668
|
const totalEntries = view.getUint16(eocdOffset + 10, true);
|
|
19657
19669
|
const cdSize = view.getUint32(eocdOffset + 12, true);
|
|
19658
19670
|
const cdOffset = view.getUint32(eocdOffset + 16, true);
|
|
19659
|
-
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0,
|
|
19671
|
+
if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkRWSGBXSAcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19660
19672
|
if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
|
|
19661
|
-
throw new (0,
|
|
19673
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19662
19674
|
}
|
|
19663
19675
|
const decoder = new TextDecoder("utf-8");
|
|
19664
19676
|
const entries = [];
|
|
19665
19677
|
let pos = cdOffset;
|
|
19666
19678
|
for (let i = 0; i < totalEntries; i++) {
|
|
19667
|
-
if (view.getUint32(pos, true) !== CD_SIG) throw new (0,
|
|
19679
|
+
if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkRWSGBXSAcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
|
|
19668
19680
|
const flags = view.getUint16(pos + 8, true);
|
|
19669
19681
|
const method = view.getUint16(pos + 10, true);
|
|
19670
19682
|
const crc = view.getUint32(pos + 16, true);
|
|
@@ -19675,7 +19687,7 @@ function parseCentralDirectory(buf) {
|
|
|
19675
19687
|
const commentLen = view.getUint16(pos + 32, true);
|
|
19676
19688
|
const localOffset = view.getUint32(pos + 42, true);
|
|
19677
19689
|
if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
|
|
19678
|
-
throw new (0,
|
|
19690
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
|
|
19679
19691
|
}
|
|
19680
19692
|
const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
|
|
19681
19693
|
const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
|
|
@@ -19704,7 +19716,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19704
19716
|
const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
|
|
19705
19717
|
const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
|
|
19706
19718
|
for (const name of replacements.keys()) {
|
|
19707
|
-
if (!entries.some((e) => e.name === name)) throw new (0,
|
|
19719
|
+
if (!entries.some((e) => e.name === name)) throw new (0, _chunkRWSGBXSAcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
|
|
19708
19720
|
}
|
|
19709
19721
|
const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
|
|
19710
19722
|
const segments = [];
|
|
@@ -19722,7 +19734,7 @@ function patchZipEntries(original, replacements) {
|
|
|
19722
19734
|
offset += seg.length;
|
|
19723
19735
|
continue;
|
|
19724
19736
|
}
|
|
19725
|
-
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0,
|
|
19737
|
+
if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkRWSGBXSAcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
|
|
19726
19738
|
const nameLen = view.getUint16(e.localOffset + 26, true);
|
|
19727
19739
|
const extraLen = view.getUint16(e.localOffset + 28, true);
|
|
19728
19740
|
const headerLen = 30 + nameLen + extraLen;
|
|
@@ -19777,7 +19789,7 @@ async function fillHwpx(hwpxBuffer, values) {
|
|
|
19777
19789
|
const zip = await _jszip2.default.loadAsync(hwpxBuffer);
|
|
19778
19790
|
const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
|
|
19779
19791
|
if (sectionPaths.length === 0) {
|
|
19780
|
-
throw new (0,
|
|
19792
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
19781
19793
|
}
|
|
19782
19794
|
const normalizedValues = normalizeValues(values);
|
|
19783
19795
|
const matchedLabels = /* @__PURE__ */ new Set();
|
|
@@ -20013,8 +20025,30 @@ var PRESET_DEFAULTS = {
|
|
|
20013
20025
|
notice: { bodyPt: 15, lineSpacing: 160, numbering: "standard" },
|
|
20014
20026
|
minutes: { bodyPt: 14, lineSpacing: 130, numbering: "standard" }
|
|
20015
20027
|
};
|
|
20028
|
+
var PRESET_ALIAS = {
|
|
20029
|
+
official: "official",
|
|
20030
|
+
\uAE30\uC548\uBB38: "official",
|
|
20031
|
+
\uC2DC\uD589\uBB38: "official",
|
|
20032
|
+
\uACF5\uBB38: "official",
|
|
20033
|
+
\uACF5\uBB38\uC11C: "official",
|
|
20034
|
+
report: "report",
|
|
20035
|
+
\uBCF4\uACE0\uC11C: "report",
|
|
20036
|
+
plan: "plan",
|
|
20037
|
+
\uACC4\uD68D\uC11C: "plan",
|
|
20038
|
+
\uACC4\uD68D: "plan",
|
|
20039
|
+
notice: "notice",
|
|
20040
|
+
\uD1B5\uC9C0: "notice",
|
|
20041
|
+
\uC54C\uB9BC: "notice",
|
|
20042
|
+
\uC548\uB0B4: "notice",
|
|
20043
|
+
minutes: "minutes",
|
|
20044
|
+
\uD68C\uC758\uB85D: "minutes"
|
|
20045
|
+
};
|
|
20046
|
+
function normalizeGongmunPreset(preset) {
|
|
20047
|
+
if (!preset) return "official";
|
|
20048
|
+
return _nullishCoalesce(PRESET_ALIAS[preset.trim()], () => ( "official"));
|
|
20049
|
+
}
|
|
20016
20050
|
function resolveGongmun(opts) {
|
|
20017
|
-
const preset =
|
|
20051
|
+
const preset = normalizeGongmunPreset(opts.preset);
|
|
20018
20052
|
const d = PRESET_DEFAULTS[preset];
|
|
20019
20053
|
const bodyPt = _nullishCoalesce(opts.bodyPt, () => ( d.bodyPt));
|
|
20020
20054
|
return {
|
|
@@ -20927,7 +20961,7 @@ function escapeGfm(text) {
|
|
|
20927
20961
|
}
|
|
20928
20962
|
var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
|
|
20929
20963
|
function sanitizeText(text) {
|
|
20930
|
-
let result =
|
|
20964
|
+
let result = _chunkRWSGBXSAcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
|
|
20931
20965
|
if (result.length <= 30 && result.includes(" ")) {
|
|
20932
20966
|
const tokens = result.split(" ");
|
|
20933
20967
|
const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-ㄱ-ㆎ]/.test(t)).length;
|
|
@@ -21384,6 +21418,67 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
|
|
|
21384
21418
|
return 1;
|
|
21385
21419
|
}
|
|
21386
21420
|
|
|
21421
|
+
// src/roundtrip/table-insert.ts
|
|
21422
|
+
var TABLE_USABLE_WIDTH = 44e3;
|
|
21423
|
+
var TABLE_ROW_HEIGHT = 1500;
|
|
21424
|
+
function collectMaxNumericId(xmls) {
|
|
21425
|
+
let max = -1;
|
|
21426
|
+
for (const xml of xmls) {
|
|
21427
|
+
for (const m of xml.matchAll(/\bid(?:Ref)?="(\d{1,10})"/g)) {
|
|
21428
|
+
const v = parseInt(m[1], 10);
|
|
21429
|
+
if (!isNaN(v) && v > max) max = v;
|
|
21430
|
+
}
|
|
21431
|
+
}
|
|
21432
|
+
return max;
|
|
21433
|
+
}
|
|
21434
|
+
function cellBorderFillXml(id) {
|
|
21435
|
+
return `<hh:borderFill id="${id}" threeD="0" shadow="0" centerLine="0" breakCellSeparateLine="0"><hh:slash type="NONE" Crooked="0" isCounter="0"/><hh:backSlash type="NONE" Crooked="0" isCounter="0"/><hh:leftBorder type="SOLID" width="0.12 mm" color="#000000"/><hh:rightBorder type="SOLID" width="0.12 mm" color="#000000"/><hh:topBorder type="SOLID" width="0.12 mm" color="#000000"/><hh:bottomBorder type="SOLID" width="0.12 mm" color="#000000"/><hh:diagonal type="NONE" width="0.1 mm" color="#000000"/><hh:fillInfo/></hh:borderFill>`;
|
|
21436
|
+
}
|
|
21437
|
+
function injectCellBorderFill(headerXml, newId) {
|
|
21438
|
+
const openM = headerXml.match(/<hh:borderFills\b([^>]*)>/);
|
|
21439
|
+
if (!openM || openM.index === void 0) return null;
|
|
21440
|
+
const closeIdx = headerXml.indexOf("</hh:borderFills>");
|
|
21441
|
+
if (closeIdx < 0) return null;
|
|
21442
|
+
const splices = [];
|
|
21443
|
+
const itemCntM = openM[1].match(/\bitemCnt="(\d+)"/);
|
|
21444
|
+
if (itemCntM && itemCntM.index !== void 0) {
|
|
21445
|
+
const cnt = parseInt(itemCntM[1], 10);
|
|
21446
|
+
const attrStart = openM.index + "<hh:borderFills".length + itemCntM.index;
|
|
21447
|
+
const valStart = attrStart + itemCntM[0].indexOf('"') + 1;
|
|
21448
|
+
const valEnd = valStart + String(cnt).length;
|
|
21449
|
+
splices.push({ start: valStart, end: valEnd, replacement: String(cnt + 1) });
|
|
21450
|
+
}
|
|
21451
|
+
splices.push({ start: closeIdx, end: closeIdx, replacement: cellBorderFillXml(newId) });
|
|
21452
|
+
return { borderFillId: newId, headerSplices: splices };
|
|
21453
|
+
}
|
|
21454
|
+
function cellPlainText(raw) {
|
|
21455
|
+
let t = unescapeGfmCell(raw);
|
|
21456
|
+
t = t.replace(/\*\*\*([^*]+)\*\*\*/g, "$1").replace(/\*\*([^*]+)\*\*/g, "$1").replace(/\*([^*]+)\*/g, "$1").replace(/`([^`]+)`/g, "$1");
|
|
21457
|
+
return t.replace(/\s*\n\s*/g, " ").trim();
|
|
21458
|
+
}
|
|
21459
|
+
function buildTableParagraphXml(rows, opts) {
|
|
21460
|
+
const { borderFillId, outerParaPrId, cellParaPrId, cellCharPrId, tableId } = opts;
|
|
21461
|
+
const rowCnt = rows.length;
|
|
21462
|
+
const colCnt = Math.max(...rows.map((r) => r.length), 1);
|
|
21463
|
+
const cellW = Math.floor(TABLE_USABLE_WIDTH / colCnt);
|
|
21464
|
+
const cellH = TABLE_ROW_HEIGHT;
|
|
21465
|
+
const tblW = cellW * colCnt;
|
|
21466
|
+
const tblH = cellH * rowCnt;
|
|
21467
|
+
const trElements = rows.map((row, rowIdx) => {
|
|
21468
|
+
const cells = row.length < colCnt ? [...row, ...Array(colCnt - row.length).fill("")] : row;
|
|
21469
|
+
const isHeaderRow = rowIdx === 0;
|
|
21470
|
+
const tdElements = cells.map((cell, colIdx) => {
|
|
21471
|
+
const text = escapeXmlText(cellPlainText(cell));
|
|
21472
|
+
const cellP = `<hp:p paraPrIDRef="${cellParaPrId}" styleIDRef="0"><hp:run charPrIDRef="${cellCharPrId}"><hp:t>${text}</hp:t></hp:run></hp:p>`;
|
|
21473
|
+
return `<hp:tc name="" header="${isHeaderRow ? 1 : 0}" hasMargin="0" protect="0" editable="1" dirty="0" borderFillIDRef="${borderFillId}"><hp:subList id="" textDirection="HORIZONTAL" lineWrap="BREAK" vertAlign="TOP" linkListIDRef="0" linkListNextIDRef="0" textWidth="0" textHeight="0" hasTextRef="0" hasNumRef="0">${cellP}</hp:subList><hp:cellAddr colAddr="${colIdx}" rowAddr="${rowIdx}"/><hp:cellSpan colSpan="1" rowSpan="1"/><hp:cellSz width="${cellW}" height="${cellH}"/><hp:cellMargin left="141" right="141" top="141" bottom="141"/></hp:tc>`;
|
|
21474
|
+
}).join("");
|
|
21475
|
+
return `<hp:tr>${tdElements}</hp:tr>`;
|
|
21476
|
+
}).join("");
|
|
21477
|
+
const tblInner = `<hp:sz width="${tblW}" widthRelTo="ABSOLUTE" height="${tblH}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="1" affectLSpacing="0" flowWithText="0" allowOverlap="0" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="PARA" vertAlign="TOP" horzAlign="LEFT" vertOffset="0" horzOffset="0"/><hp:outMargin left="0" right="0" top="0" bottom="0"/><hp:inMargin left="510" right="510" top="141" bottom="141"/>` + trElements;
|
|
21478
|
+
const tbl = `<hp:tbl id="${tableId}" zOrder="0" numberingType="TABLE" pageBreak="CELL" repeatHeader="0" rowCnt="${rowCnt}" colCnt="${colCnt}" cellSpacing="0" borderFillIDRef="${borderFillId}" noShading="0">${tblInner}</hp:tbl>`;
|
|
21479
|
+
return `<hp:p paraPrIDRef="${outerParaPrId}" styleIDRef="0"><hp:run charPrIDRef="${cellCharPrId}">${tbl}</hp:run></hp:p>`;
|
|
21480
|
+
}
|
|
21481
|
+
|
|
21387
21482
|
// src/roundtrip/hwpx-entries.ts
|
|
21388
21483
|
async function resolveSectionEntryNames(zip) {
|
|
21389
21484
|
for (const mp of ["Contents/content.hpf", "content.hpf"]) {
|
|
@@ -21393,10 +21488,9 @@ async function resolveSectionEntryNames(zip) {
|
|
|
21393
21488
|
const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
|
|
21394
21489
|
if (paths.length > 0) return paths;
|
|
21395
21490
|
}
|
|
21396
|
-
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort();
|
|
21491
|
+
return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkRWSGBXSAcjs.compareSectionPaths);
|
|
21397
21492
|
}
|
|
21398
21493
|
function sectionPathsFromManifest(xml) {
|
|
21399
|
-
const isSectionId = (id) => /^s/i.test(id) || id.toLowerCase().includes("section");
|
|
21400
21494
|
const attr = (tag, name) => {
|
|
21401
21495
|
const m = tag.match(new RegExp(`(?:^|\\s)${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`));
|
|
21402
21496
|
return m ? _nullishCoalesce(m[1], () => ( m[2])) : "";
|
|
@@ -21404,11 +21498,8 @@ function sectionPathsFromManifest(xml) {
|
|
|
21404
21498
|
const idToHref = /* @__PURE__ */ new Map();
|
|
21405
21499
|
for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
21406
21500
|
const id = attr(m[1], "id");
|
|
21407
|
-
|
|
21408
|
-
|
|
21409
|
-
if (!isSectionId(id) && !mediaType.includes("xml")) continue;
|
|
21410
|
-
if (!href.startsWith("/") && !href.startsWith("Contents/") && isSectionId(id)) href = "Contents/" + href;
|
|
21411
|
-
if (id) idToHref.set(id, href);
|
|
21501
|
+
const href = _chunkRWSGBXSAcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
|
|
21502
|
+
if (id && href) idToHref.set(id, href);
|
|
21412
21503
|
}
|
|
21413
21504
|
const ordered = [];
|
|
21414
21505
|
for (const m of xml.matchAll(/<opf:itemref(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
|
|
@@ -21416,7 +21507,7 @@ function sectionPathsFromManifest(xml) {
|
|
|
21416
21507
|
if (href) ordered.push(href);
|
|
21417
21508
|
}
|
|
21418
21509
|
if (ordered.length > 0) return ordered;
|
|
21419
|
-
return Array.from(idToHref.
|
|
21510
|
+
return Array.from(idToHref.values()).sort(_chunkRWSGBXSAcjs.compareSectionPaths);
|
|
21420
21511
|
}
|
|
21421
21512
|
|
|
21422
21513
|
// src/roundtrip/patcher.ts
|
|
@@ -21433,7 +21524,7 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
21433
21524
|
let zip;
|
|
21434
21525
|
try {
|
|
21435
21526
|
zip = await _jszip2.default.loadAsync(original);
|
|
21436
|
-
} catch (
|
|
21527
|
+
} catch (e34) {
|
|
21437
21528
|
return { success: false, applied: 0, skipped, error: "ZIP \uB85C\uB4DC \uC2E4\uD328" };
|
|
21438
21529
|
}
|
|
21439
21530
|
const sectionPaths = await resolveSectionEntryNames(zip);
|
|
@@ -21445,6 +21536,13 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
21445
21536
|
const xml = await zip.file(sectionPaths[i]).async("text");
|
|
21446
21537
|
scans.push(scanSectionXml(xml, i));
|
|
21447
21538
|
}
|
|
21539
|
+
let tableInsert;
|
|
21540
|
+
const headerEntryName = await resolveHeaderEntryName(zip);
|
|
21541
|
+
if (headerEntryName) {
|
|
21542
|
+
const headerXml = await zip.file(headerEntryName).async("text");
|
|
21543
|
+
const maxId = collectMaxNumericId([...scans.map((s) => s.xml), headerXml]);
|
|
21544
|
+
tableInsert = { headerEntryName, headerXml, headerSplices: [], borderFillId: null, nextId: maxId + 1 };
|
|
21545
|
+
}
|
|
21448
21546
|
const origUnits = buildOrigUnits(origBlocks);
|
|
21449
21547
|
const editedUnits = splitMarkdownUnits(editedMarkdown);
|
|
21450
21548
|
const pairs = alignUnits(origUnits.map((u) => u.raw), editedUnits.map((u) => u.raw));
|
|
@@ -21464,7 +21562,8 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
21464
21562
|
scanTables,
|
|
21465
21563
|
obTableOrdinals,
|
|
21466
21564
|
sectionSplices,
|
|
21467
|
-
skipped
|
|
21565
|
+
skipped,
|
|
21566
|
+
tableInsert
|
|
21468
21567
|
});
|
|
21469
21568
|
} else if (oi !== null) {
|
|
21470
21569
|
skipped.push({ reason: "\uBE14\uB85D \uC0AD\uC81C\uB294 \uBBF8\uC9C0\uC6D0 (v1) \u2014 \uC6D0\uBCF8 \uC720\uC9C0", before: summarize(origUnits[oi].raw) });
|
|
@@ -21481,6 +21580,10 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
21481
21580
|
const newXml = applySplices(scans[i].xml, sectionSplices[i]);
|
|
21482
21581
|
replacements.set(sectionPaths[i], encoder.encode(newXml));
|
|
21483
21582
|
}
|
|
21583
|
+
if (tableInsert && tableInsert.headerSplices.length > 0) {
|
|
21584
|
+
const newHeader = applySplices(tableInsert.headerXml, tableInsert.headerSplices);
|
|
21585
|
+
replacements.set(tableInsert.headerEntryName, encoder.encode(newHeader));
|
|
21586
|
+
}
|
|
21484
21587
|
} catch (err) {
|
|
21485
21588
|
return { success: false, applied: 0, skipped, error: `\uC18C\uC2A4\uB9F5 splice \uC2E4\uD328: ${err instanceof Error ? err.message : String(err)}` };
|
|
21486
21589
|
}
|
|
@@ -21514,9 +21617,9 @@ function buildOrigUnits(blocks) {
|
|
|
21514
21617
|
if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
|
|
21515
21618
|
const next = blocks[i + 1];
|
|
21516
21619
|
if (_optionalChain([next, 'optionalAccess', _198 => _198.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
|
|
21517
|
-
chunk =
|
|
21620
|
+
chunk = _chunkRWSGBXSAcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
|
|
21518
21621
|
} else {
|
|
21519
|
-
chunk =
|
|
21622
|
+
chunk = _chunkRWSGBXSAcjs.blocksToMarkdown.call(void 0, [block]);
|
|
21520
21623
|
}
|
|
21521
21624
|
if (chunk) {
|
|
21522
21625
|
const subUnits = splitMarkdownUnits(chunk);
|
|
@@ -21693,14 +21796,52 @@ function handleModifiedUnit(orig, edited, ctx) {
|
|
|
21693
21796
|
if (orig.kind === "html-table") return patchHtmlTable(block.table, scanTable, orig, edited, ctx, skip);
|
|
21694
21797
|
return patchTextChunkTable(block.table, scanTable, orig, edited, ctx, skip);
|
|
21695
21798
|
}
|
|
21696
|
-
if ((block.type === "paragraph" || block.type === "heading") && orig.kind === "text"
|
|
21697
|
-
return patchParagraphUnit(block, orig, edited, ctx, skip);
|
|
21799
|
+
if ((block.type === "paragraph" || block.type === "heading") && orig.kind === "text") {
|
|
21800
|
+
if (edited.kind === "text") return patchParagraphUnit(block, orig, edited, ctx, skip);
|
|
21801
|
+
if (edited.kind === "gfm-table") return convertParagraphToTable(block, orig, edited, ctx, skip);
|
|
21802
|
+
if (edited.kind === "html-table") return skip("\uBB38\uB2E8\u2192\uBCD1\uD569\uD45C(HTML) \uBCC0\uD658\uC740 \uBBF8\uC9C0\uC6D0 \u2014 GFM \uD45C(| \uD5E4\uB354 | \u2026 |)\uB85C \uC791\uC131\uD558\uC138\uC694");
|
|
21698
21803
|
}
|
|
21699
21804
|
return skip("\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uBE14\uB85D \uC720\uD615 \uBCC0\uACBD");
|
|
21700
21805
|
}
|
|
21806
|
+
function extractParaPrIdRef(xml, start) {
|
|
21807
|
+
const gt = xml.indexOf(">", start);
|
|
21808
|
+
if (gt < 0) return null;
|
|
21809
|
+
const m = xml.slice(start, gt + 1).match(/paraPrIDRef="(\d+)"/);
|
|
21810
|
+
return m ? parseInt(m[1], 10) : null;
|
|
21811
|
+
}
|
|
21812
|
+
function convertParagraphToTable(block, orig, edited, ctx, skip) {
|
|
21813
|
+
const ti = ctx.tableInsert;
|
|
21814
|
+
if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
|
|
21815
|
+
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
21816
|
+
if (!_optionalChain([mapping, 'optionalAccess', _201 => _201.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED) \u2014 \uD45C \uBCC0\uD658 \uBD88\uAC00");
|
|
21817
|
+
const para = mapping.para;
|
|
21818
|
+
if (para.kind !== "body") return skip("\uBCF8\uBB38 \uC678 \uC601\uC5ED(\uD45C \uC140/\uAE00\uC0C1\uC790) \uBB38\uB2E8\uC758 \uD45C \uBCC0\uD658\uC740 \uBBF8\uC9C0\uC6D0");
|
|
21819
|
+
const scan = ctx.scans[para.sectionIndex];
|
|
21820
|
+
if (!scan) return skip("\uC139\uC158 \uB9E4\uD551 \uC2E4\uD328");
|
|
21821
|
+
const pEnd = findElementEnd(scan.xml, para.start);
|
|
21822
|
+
if (pEnd < 0) return skip("\uBB38\uB2E8 \uB05D \uC704\uCE58 \uD0D0\uC0C9 \uC2E4\uD328");
|
|
21823
|
+
const rows = parseGfmTable(edited.lines);
|
|
21824
|
+
if (rows.length === 0 || rows.every((r) => r.length === 0)) return skip("\uD45C \uB0B4\uC6A9\uC774 \uBE44\uC5B4 \uC788\uC74C");
|
|
21825
|
+
if (ti.borderFillId === null) {
|
|
21826
|
+
const inj = injectCellBorderFill(ti.headerXml, ti.nextId++);
|
|
21827
|
+
if (!inj) return skip("header <hh:borderFills> \uAD6C\uC870\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC5B4 \uD45C \uD14C\uB450\uB9AC \uC0DD\uC131 \uBD88\uAC00");
|
|
21828
|
+
ti.borderFillId = inj.borderFillId;
|
|
21829
|
+
ti.headerSplices.push(...inj.headerSplices);
|
|
21830
|
+
}
|
|
21831
|
+
const outerParaPrId = _nullishCoalesce(extractParaPrIdRef(scan.xml, para.start), () => ( 0));
|
|
21832
|
+
const tableXml = buildTableParagraphXml(rows, {
|
|
21833
|
+
borderFillId: ti.borderFillId,
|
|
21834
|
+
outerParaPrId,
|
|
21835
|
+
cellParaPrId: 0,
|
|
21836
|
+
cellCharPrId: 0,
|
|
21837
|
+
tableId: ti.nextId++
|
|
21838
|
+
});
|
|
21839
|
+
ctx.sectionSplices[para.sectionIndex].push({ start: para.start, end: pEnd, replacement: tableXml });
|
|
21840
|
+
return 1;
|
|
21841
|
+
}
|
|
21701
21842
|
function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
21702
21843
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
21703
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
21844
|
+
if (!_optionalChain([mapping, 'optionalAccess', _202 => _202.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
|
|
21704
21845
|
if (block.text && block.text.includes("\n")) {
|
|
21705
21846
|
return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
|
|
21706
21847
|
}
|
|
@@ -21731,7 +21872,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
|
|
|
21731
21872
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
21732
21873
|
return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
|
|
21733
21874
|
}
|
|
21734
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access',
|
|
21875
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _203 => _203.scans, 'access', _204 => _204[mapping.para.sectionIndex], 'optionalAccess', _205 => _205.xml]));
|
|
21735
21876
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
21736
21877
|
ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
21737
21878
|
return 1;
|
|
@@ -21778,6 +21919,24 @@ function unitToBlock(u) {
|
|
|
21778
21919
|
function u8ToArrayBuffer(u8) {
|
|
21779
21920
|
return u8.buffer.slice(u8.byteOffset, u8.byteOffset + u8.byteLength);
|
|
21780
21921
|
}
|
|
21922
|
+
async function resolveHeaderEntryName(zip) {
|
|
21923
|
+
for (const p of ["Contents/header.xml", "header.xml"]) {
|
|
21924
|
+
if (zip.file(p)) return p;
|
|
21925
|
+
}
|
|
21926
|
+
for (const mp of ["Contents/content.hpf", "content.hpf"]) {
|
|
21927
|
+
const f = zip.file(mp);
|
|
21928
|
+
if (!f) continue;
|
|
21929
|
+
const xml = await f.async("text");
|
|
21930
|
+
const m = xml.match(/<opf:item\b[^>]*\bid="header"[^>]*\bhref="([^"]+)"/i) || xml.match(/<opf:item\b[^>]*\bhref="([^"]*header[^"]*\.xml)"/i);
|
|
21931
|
+
if (m) {
|
|
21932
|
+
let href = m[1];
|
|
21933
|
+
if (!href.startsWith("/") && !href.startsWith("Contents/")) href = "Contents/" + href;
|
|
21934
|
+
if (zip.file(href)) return href;
|
|
21935
|
+
}
|
|
21936
|
+
}
|
|
21937
|
+
const found = Object.keys(zip.files).find((n) => /header\.xml$/i.test(n));
|
|
21938
|
+
return _nullishCoalesce(found, () => ( null));
|
|
21939
|
+
}
|
|
21781
21940
|
|
|
21782
21941
|
// src/roundtrip/hwp5-patch.ts
|
|
21783
21942
|
|
|
@@ -21899,7 +22058,7 @@ var Surgeon = (_class3 = class {
|
|
|
21899
22058
|
/** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
|
|
21900
22059
|
findEntry(path) {
|
|
21901
22060
|
const parts = path.replace(/^\//, "").split("/");
|
|
21902
|
-
let scope = _nullishCoalesce(_optionalChain([this, 'access',
|
|
22061
|
+
let scope = _nullishCoalesce(_optionalChain([this, 'access', _206 => _206.entries, 'access', _207 => _207[0], 'optionalAccess', _208 => _208.child]), () => ( -1));
|
|
21903
22062
|
let current;
|
|
21904
22063
|
for (const part of parts) {
|
|
21905
22064
|
const search = (idx) => {
|
|
@@ -22105,7 +22264,7 @@ function readRecordsStrict(stream) {
|
|
|
22105
22264
|
function serializeRecords(recs, repl) {
|
|
22106
22265
|
const parts = [];
|
|
22107
22266
|
for (let i = 0; i < recs.length; i++) {
|
|
22108
|
-
const data = _nullishCoalesce(_optionalChain([repl, 'optionalAccess',
|
|
22267
|
+
const data = _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _209 => _209.get, 'call', _210 => _210(i)]), () => ( recs[i].data));
|
|
22109
22268
|
const ext = data.length >= 4095;
|
|
22110
22269
|
const header = Buffer.alloc(ext ? 8 : 4);
|
|
22111
22270
|
header.writeUInt32LE((recs[i].tagId & 1023 | (recs[i].level & 1023) << 10 | (ext ? 4095 : data.length) << 20) >>> 0, 0);
|
|
@@ -22228,7 +22387,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
22228
22387
|
return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
|
|
22229
22388
|
}
|
|
22230
22389
|
const fhEntry = CFB2.find(cfb, "/FileHeader");
|
|
22231
|
-
if (!_optionalChain([fhEntry, 'optionalAccess',
|
|
22390
|
+
if (!_optionalChain([fhEntry, 'optionalAccess', _211 => _211.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
|
|
22232
22391
|
let flags;
|
|
22233
22392
|
try {
|
|
22234
22393
|
flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
|
|
@@ -22250,7 +22409,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
22250
22409
|
const scans = [];
|
|
22251
22410
|
for (let i = 0; i < sectionPaths.length; i++) {
|
|
22252
22411
|
const entry = CFB2.find(cfb, sectionPaths[i]);
|
|
22253
|
-
if (!_optionalChain([entry, 'optionalAccess',
|
|
22412
|
+
if (!_optionalChain([entry, 'optionalAccess', _212 => _212.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
|
|
22254
22413
|
let stream;
|
|
22255
22414
|
try {
|
|
22256
22415
|
stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
|
|
@@ -22301,7 +22460,7 @@ async function patchHwp(original, editedMarkdown, options) {
|
|
|
22301
22460
|
}
|
|
22302
22461
|
}
|
|
22303
22462
|
let verification;
|
|
22304
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
22463
|
+
if (_optionalChain([options, 'optionalAccess', _213 => _213.verify]) !== false) {
|
|
22305
22464
|
try {
|
|
22306
22465
|
const reparsed = parseHwp5Document(Buffer.from(data));
|
|
22307
22466
|
verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
|
|
@@ -22390,7 +22549,7 @@ function tableContentScore(irTable, scanTable) {
|
|
|
22390
22549
|
for (const [key, scanCell] of scanTable.cells) {
|
|
22391
22550
|
const comma = key.indexOf(",");
|
|
22392
22551
|
const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
|
|
22393
|
-
const irCell = _optionalChain([irTable, 'access',
|
|
22552
|
+
const irCell = _optionalChain([irTable, 'access', _214 => _214.cells, 'access', _215 => _215[r], 'optionalAccess', _216 => _216[c]]);
|
|
22394
22553
|
if (!irCell) continue;
|
|
22395
22554
|
const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
|
|
22396
22555
|
const b = normForMatch(stripCellTokens(irCell.text));
|
|
@@ -22416,14 +22575,17 @@ function handleModified(orig, edited, ctx) {
|
|
|
22416
22575
|
if (orig.kind === "html-table") return patchHtmlCells5(block.table, scanTable, orig, edited, ctx, skip);
|
|
22417
22576
|
return patchTextChunk5(block.table, scanTable, orig, edited, ctx, skip);
|
|
22418
22577
|
}
|
|
22419
|
-
if ((block.type === "paragraph" || block.type === "heading") && orig.kind === "text"
|
|
22420
|
-
return patchParagraph(block, orig, edited, ctx, skip);
|
|
22578
|
+
if ((block.type === "paragraph" || block.type === "heading") && orig.kind === "text") {
|
|
22579
|
+
if (edited.kind === "text") return patchParagraph(block, orig, edited, ctx, skip);
|
|
22580
|
+
if (edited.kind === "gfm-table" || edited.kind === "html-table") {
|
|
22581
|
+
return skip("HWP5(.hwp) \uBC14\uC774\uB108\uB9AC\uB294 \uBB38\uB2E8\u2192\uD45C \uC778\uD50C\uB808\uC774\uC2A4 \uBCC0\uD658 \uBBF8\uC9C0\uC6D0 \u2014 generate\uB85C \uC0C8 \uBB38\uC11C\uB97C \uB9CC\uB4E4\uAC70\uB098, HWPX(.hwpx)\uB85C \uC800\uC7A5 \uD6C4 patch\uD558\uC138\uC694");
|
|
22582
|
+
}
|
|
22421
22583
|
}
|
|
22422
22584
|
return skip("\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uBE14\uB85D \uC720\uD615 \uBCC0\uACBD");
|
|
22423
22585
|
}
|
|
22424
22586
|
function patchParagraph(block, orig, edited, ctx, skip) {
|
|
22425
22587
|
const mapping = ctx.paraMap.get(orig.blockIdx);
|
|
22426
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
22588
|
+
if (!_optionalChain([mapping, 'optionalAccess', _217 => _217.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
|
|
22427
22589
|
if (block.text && block.text.includes("\n")) {
|
|
22428
22590
|
return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
|
|
22429
22591
|
}
|
|
@@ -22602,7 +22764,7 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
|
|
|
22602
22764
|
};
|
|
22603
22765
|
const cell = scanTable.cells.get(`${gridR},${gridC}`);
|
|
22604
22766
|
if (!cell) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
|
|
22605
|
-
const irCell = _optionalChain([table, 'access',
|
|
22767
|
+
const irCell = _optionalChain([table, 'access', _218 => _218.cells, 'access', _219 => _219[gridR], 'optionalAccess', _220 => _220[gridC]]);
|
|
22606
22768
|
const scanJoined = cell.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
|
|
22607
22769
|
if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
|
|
22608
22770
|
if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
|
|
@@ -22845,7 +23007,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
|
|
|
22845
23007
|
const block = st.blocks[blockIndex];
|
|
22846
23008
|
if (!block) return void 0;
|
|
22847
23009
|
if (block.type === "paragraph" || block.type === "heading") {
|
|
22848
|
-
const para = _optionalChain([st, 'access',
|
|
23010
|
+
const para = _optionalChain([st, 'access', _221 => _221.paraMap, 'access', _222 => _222.get, 'call', _223 => _223(blockIndex), 'optionalAccess', _224 => _224.para]);
|
|
22849
23011
|
if (!para) return void 0;
|
|
22850
23012
|
return { kind: "paragraph", sectionIndex: para.sectionIndex, xmlStart: para.start };
|
|
22851
23013
|
}
|
|
@@ -22870,7 +23032,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
|
|
|
22870
23032
|
if (block.text && block.text.includes("\n")) {
|
|
22871
23033
|
return { capability: "locked", reason: "\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)" };
|
|
22872
23034
|
}
|
|
22873
|
-
if (!_optionalChain([st, 'access',
|
|
23035
|
+
if (!_optionalChain([st, 'access', _225 => _225.paraMap, 'access', _226 => _226.get, 'call', _227 => _227(blockIndex), 'optionalAccess', _228 => _228.para])) {
|
|
22874
23036
|
return { capability: "locked", reason: "\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)" };
|
|
22875
23037
|
}
|
|
22876
23038
|
return { capability: "text" };
|
|
@@ -22936,7 +23098,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
|
|
|
22936
23098
|
continue;
|
|
22937
23099
|
}
|
|
22938
23100
|
if (block.type === "table" && block.table) {
|
|
22939
|
-
if (!_optionalChain([edit, 'access',
|
|
23101
|
+
if (!_optionalChain([edit, 'access', _229 => _229.cells, 'optionalAccess', _230 => _230.length])) {
|
|
22940
23102
|
skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
|
|
22941
23103
|
continue;
|
|
22942
23104
|
}
|
|
@@ -22956,7 +23118,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
|
|
|
22956
23118
|
skipped.push({ reason: "\uAC19\uC740 \uC140\uC5D0 \uC911\uBCF5 \uD3B8\uC9D1 \u2014 \uBA3C\uC800 \uC801\uC6A9\uB41C \uD3B8\uC9D1 \uC720\uC9C0", after: summarize(cellEdit.text) });
|
|
22957
23119
|
continue;
|
|
22958
23120
|
}
|
|
22959
|
-
const irCell = _optionalChain([block, 'access',
|
|
23121
|
+
const irCell = _optionalChain([block, 'access', _231 => _231.table, 'access', _232 => _232.cells, 'access', _233 => _233[cellEdit.row], 'optionalAccess', _234 => _234[cellEdit.col]]);
|
|
22960
23122
|
if (!irCell) {
|
|
22961
23123
|
skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
|
|
22962
23124
|
continue;
|
|
@@ -23011,7 +23173,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
|
|
|
23011
23173
|
}
|
|
23012
23174
|
if (replacements.size === 0) {
|
|
23013
23175
|
let changes2;
|
|
23014
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
23176
|
+
if (_optionalChain([options, 'optionalAccess', _235 => _235.verify]) !== false) {
|
|
23015
23177
|
const units = splitMarkdownUnits(st.markdown);
|
|
23016
23178
|
changes2 = diffUnitLists(units, units);
|
|
23017
23179
|
}
|
|
@@ -23032,7 +23194,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
|
|
|
23032
23194
|
}
|
|
23033
23195
|
this.state = newState;
|
|
23034
23196
|
let changes;
|
|
23035
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
23197
|
+
if (_optionalChain([options, 'optionalAccess', _236 => _236.verify]) !== false) {
|
|
23036
23198
|
changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
|
|
23037
23199
|
}
|
|
23038
23200
|
return { success: true, data: new Uint8Array(data), applied, skipped, changes };
|
|
@@ -23052,7 +23214,7 @@ var HwpxSession = (_class4 = class _HwpxSession {
|
|
|
23052
23214
|
return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
|
|
23053
23215
|
}
|
|
23054
23216
|
const mapping = st.paraMap.get(blockIndex);
|
|
23055
|
-
if (!_optionalChain([mapping, 'optionalAccess',
|
|
23217
|
+
if (!_optionalChain([mapping, 'optionalAccess', _237 => _237.para])) {
|
|
23056
23218
|
return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
|
|
23057
23219
|
}
|
|
23058
23220
|
let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
|
|
@@ -23072,14 +23234,14 @@ var HwpxSession = (_class4 = class _HwpxSession {
|
|
|
23072
23234
|
if (sanitizeText(newPlain) !== newPlain) {
|
|
23073
23235
|
return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
|
|
23074
23236
|
}
|
|
23075
|
-
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access',
|
|
23237
|
+
const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _238 => _238.scans, 'access', _239 => _239[mapping.para.sectionIndex], 'optionalAccess', _240 => _240.xml]));
|
|
23076
23238
|
if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
|
|
23077
23239
|
sectionSplices[mapping.para.sectionIndex].push(...splices);
|
|
23078
23240
|
return 1;
|
|
23079
23241
|
}
|
|
23080
23242
|
}, _class4);
|
|
23081
23243
|
function cellStaticCheck(table, scanTable, r, c) {
|
|
23082
|
-
const irCell = _optionalChain([table, 'access',
|
|
23244
|
+
const irCell = _optionalChain([table, 'access', _241 => _241.cells, 'access', _242 => _242[r], 'optionalAccess', _243 => _243[c]]);
|
|
23083
23245
|
if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
|
|
23084
23246
|
const cell = scanTable.cellByAnchor.get(`${r},${c}`);
|
|
23085
23247
|
if (!cell) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
|
|
@@ -23163,11 +23325,11 @@ var md = new (0, _markdownit2.default)({
|
|
|
23163
23325
|
breaks: false
|
|
23164
23326
|
});
|
|
23165
23327
|
function renderHtml(markdown, options) {
|
|
23166
|
-
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
23167
|
-
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
23328
|
+
const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _244 => _244.preset]), () => ( "default"));
|
|
23329
|
+
const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _245 => _245.extraCss]), () => ( "")));
|
|
23168
23330
|
const body = md.render(markdown);
|
|
23169
|
-
const watermark = _optionalChain([options, 'optionalAccess',
|
|
23170
|
-
const watermarkCss = _optionalChain([options, 'optionalAccess',
|
|
23331
|
+
const watermark = _optionalChain([options, 'optionalAccess', _246 => _246.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
|
|
23332
|
+
const watermarkCss = _optionalChain([options, 'optionalAccess', _247 => _247.watermark]) ? `
|
|
23171
23333
|
.watermark {
|
|
23172
23334
|
position: fixed;
|
|
23173
23335
|
top: 50%; left: 50%;
|
|
@@ -23197,14 +23359,14 @@ async function htmlToPdf(html, options) {
|
|
|
23197
23359
|
let puppeteer;
|
|
23198
23360
|
try {
|
|
23199
23361
|
puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
|
|
23200
|
-
} catch (
|
|
23201
|
-
throw new (0,
|
|
23362
|
+
} catch (e35) {
|
|
23363
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)(
|
|
23202
23364
|
"PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
|
|
23203
23365
|
);
|
|
23204
23366
|
}
|
|
23205
23367
|
const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
|
|
23206
23368
|
if (!executablePath) {
|
|
23207
|
-
throw new (0,
|
|
23369
|
+
throw new (0, _chunkRWSGBXSAcjs.KordocError)(
|
|
23208
23370
|
"Chromium \uC2E4\uD589 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. PUPPETEER_EXECUTABLE_PATH \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694."
|
|
23209
23371
|
);
|
|
23210
23372
|
}
|
|
@@ -23216,10 +23378,10 @@ async function htmlToPdf(html, options) {
|
|
|
23216
23378
|
try {
|
|
23217
23379
|
const page = await browser.newPage();
|
|
23218
23380
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
23219
|
-
const margin = _optionalChain([options, 'optionalAccess',
|
|
23381
|
+
const margin = _optionalChain([options, 'optionalAccess', _248 => _248.margin]);
|
|
23220
23382
|
const pdf = await page.pdf({
|
|
23221
|
-
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
23222
|
-
landscape: _optionalChain([options, 'optionalAccess',
|
|
23383
|
+
format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _249 => _249.pageSize]), () => ( "A4")),
|
|
23384
|
+
landscape: _optionalChain([options, 'optionalAccess', _250 => _250.orientation]) === "landscape",
|
|
23223
23385
|
printBackground: true,
|
|
23224
23386
|
margin: margin ? {
|
|
23225
23387
|
top: toCss(margin.top),
|
|
@@ -23227,9 +23389,9 @@ async function htmlToPdf(html, options) {
|
|
|
23227
23389
|
bottom: toCss(margin.bottom),
|
|
23228
23390
|
left: toCss(margin.left)
|
|
23229
23391
|
} : void 0,
|
|
23230
|
-
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess',
|
|
23231
|
-
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
23232
|
-
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess',
|
|
23392
|
+
displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _251 => _251.header]) || _optionalChain([options, 'optionalAccess', _252 => _252.footer])),
|
|
23393
|
+
headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _253 => _253.header]), () => ( "<div></div>")),
|
|
23394
|
+
footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _254 => _254.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
|
|
23233
23395
|
});
|
|
23234
23396
|
return Buffer.from(pdf);
|
|
23235
23397
|
} finally {
|
|
@@ -23263,24 +23425,24 @@ async function markdownToPdf(markdown, options) {
|
|
|
23263
23425
|
return htmlToPdf(html, options);
|
|
23264
23426
|
}
|
|
23265
23427
|
async function blocksToPdf(blocks, options) {
|
|
23266
|
-
const markdown =
|
|
23428
|
+
const markdown = _chunkRWSGBXSAcjs.blocksToMarkdown.call(void 0, blocks);
|
|
23267
23429
|
return markdownToPdf(markdown, options);
|
|
23268
23430
|
}
|
|
23269
23431
|
|
|
23270
23432
|
// src/index.ts
|
|
23271
23433
|
async function parse(input, options) {
|
|
23272
23434
|
let buffer;
|
|
23273
|
-
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess',
|
|
23435
|
+
const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _255 => _255.filePath]) ? { ...options, filePath: input } : options;
|
|
23274
23436
|
if (typeof input === "string") {
|
|
23275
23437
|
try {
|
|
23276
23438
|
const buf = await _promises.readFile.call(void 0, input);
|
|
23277
|
-
buffer =
|
|
23439
|
+
buffer = _chunkRWSGBXSAcjs.toArrayBuffer.call(void 0, buf);
|
|
23278
23440
|
} catch (err) {
|
|
23279
23441
|
const msg2 = err instanceof Error && "code" in err && err.code === "ENOENT" ? `\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input}` : `\uD30C\uC77C \uC77D\uAE30 \uC2E4\uD328: ${input}`;
|
|
23280
23442
|
return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
|
|
23281
23443
|
}
|
|
23282
23444
|
} else if (Buffer.isBuffer(input)) {
|
|
23283
|
-
buffer =
|
|
23445
|
+
buffer = _chunkRWSGBXSAcjs.toArrayBuffer.call(void 0, input);
|
|
23284
23446
|
} else {
|
|
23285
23447
|
buffer = input;
|
|
23286
23448
|
}
|
|
@@ -23315,21 +23477,21 @@ async function parseHwp3(buffer, options) {
|
|
|
23315
23477
|
const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
|
|
23316
23478
|
return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
|
|
23317
23479
|
} catch (err) {
|
|
23318
|
-
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23480
|
+
return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkRWSGBXSAcjs.classifyError.call(void 0, err) };
|
|
23319
23481
|
}
|
|
23320
23482
|
}
|
|
23321
23483
|
async function parseHwpx(buffer, options) {
|
|
23322
23484
|
try {
|
|
23323
23485
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
|
|
23324
|
-
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
23486
|
+
return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _256 => _256.length]) ? images : void 0 };
|
|
23325
23487
|
} catch (err) {
|
|
23326
|
-
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23488
|
+
return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkRWSGBXSAcjs.classifyError.call(void 0, err) };
|
|
23327
23489
|
}
|
|
23328
23490
|
}
|
|
23329
23491
|
async function parseHwp(buffer, options) {
|
|
23330
23492
|
try {
|
|
23331
23493
|
const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
|
|
23332
|
-
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess',
|
|
23494
|
+
if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _257 => _257.filePath])) {
|
|
23333
23495
|
try {
|
|
23334
23496
|
const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
|
|
23335
23497
|
if (pages.some((p) => p && p.trim().length > 0)) {
|
|
@@ -23343,20 +23505,20 @@ async function parseHwp(buffer, options) {
|
|
|
23343
23505
|
warnings: com.warnings
|
|
23344
23506
|
};
|
|
23345
23507
|
}
|
|
23346
|
-
} catch (
|
|
23508
|
+
} catch (e36) {
|
|
23347
23509
|
}
|
|
23348
23510
|
}
|
|
23349
|
-
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
23511
|
+
return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _258 => _258.length]) ? images : void 0 };
|
|
23350
23512
|
} catch (err) {
|
|
23351
|
-
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23513
|
+
return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkRWSGBXSAcjs.classifyError.call(void 0, err) };
|
|
23352
23514
|
}
|
|
23353
23515
|
}
|
|
23354
23516
|
async function parsePdf(buffer, options) {
|
|
23355
23517
|
let parsePdfDocument;
|
|
23356
23518
|
try {
|
|
23357
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-
|
|
23519
|
+
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-ZLFOUVR4.cjs")));
|
|
23358
23520
|
parsePdfDocument = mod.parsePdfDocument;
|
|
23359
|
-
} catch (
|
|
23521
|
+
} catch (e37) {
|
|
23360
23522
|
return {
|
|
23361
23523
|
success: false,
|
|
23362
23524
|
fileType: "pdf",
|
|
@@ -23369,7 +23531,7 @@ async function parsePdf(buffer, options) {
|
|
|
23369
23531
|
return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
|
|
23370
23532
|
} catch (err) {
|
|
23371
23533
|
const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
|
|
23372
|
-
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23534
|
+
return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkRWSGBXSAcjs.classifyError.call(void 0, err), isImageBased };
|
|
23373
23535
|
}
|
|
23374
23536
|
}
|
|
23375
23537
|
async function parseXlsx(buffer, options) {
|
|
@@ -23377,7 +23539,7 @@ async function parseXlsx(buffer, options) {
|
|
|
23377
23539
|
const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
|
|
23378
23540
|
return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
|
|
23379
23541
|
} catch (err) {
|
|
23380
|
-
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23542
|
+
return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkRWSGBXSAcjs.classifyError.call(void 0, err) };
|
|
23381
23543
|
}
|
|
23382
23544
|
}
|
|
23383
23545
|
async function parseXls(buffer, options) {
|
|
@@ -23385,15 +23547,15 @@ async function parseXls(buffer, options) {
|
|
|
23385
23547
|
const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
|
|
23386
23548
|
return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
|
|
23387
23549
|
} catch (err) {
|
|
23388
|
-
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23550
|
+
return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkRWSGBXSAcjs.classifyError.call(void 0, err) };
|
|
23389
23551
|
}
|
|
23390
23552
|
}
|
|
23391
23553
|
async function parseDocx(buffer, options) {
|
|
23392
23554
|
try {
|
|
23393
23555
|
const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
|
|
23394
|
-
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess',
|
|
23556
|
+
return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _259 => _259.length]) ? images : void 0 };
|
|
23395
23557
|
} catch (err) {
|
|
23396
|
-
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23558
|
+
return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkRWSGBXSAcjs.classifyError.call(void 0, err) };
|
|
23397
23559
|
}
|
|
23398
23560
|
}
|
|
23399
23561
|
async function parseHwpml(buffer, options) {
|
|
@@ -23401,16 +23563,16 @@ async function parseHwpml(buffer, options) {
|
|
|
23401
23563
|
const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
|
|
23402
23564
|
return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
|
|
23403
23565
|
} catch (err) {
|
|
23404
|
-
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code:
|
|
23566
|
+
return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkRWSGBXSAcjs.classifyError.call(void 0, err) };
|
|
23405
23567
|
}
|
|
23406
23568
|
}
|
|
23407
23569
|
async function fillForm(input, values, outputFormat = "markdown") {
|
|
23408
23570
|
let buffer;
|
|
23409
23571
|
if (typeof input === "string") {
|
|
23410
23572
|
const buf = await _promises.readFile.call(void 0, input);
|
|
23411
|
-
buffer =
|
|
23573
|
+
buffer = _chunkRWSGBXSAcjs.toArrayBuffer.call(void 0, buf);
|
|
23412
23574
|
} else if (Buffer.isBuffer(input)) {
|
|
23413
|
-
buffer =
|
|
23575
|
+
buffer = _chunkRWSGBXSAcjs.toArrayBuffer.call(void 0, input);
|
|
23414
23576
|
} else {
|
|
23415
23577
|
buffer = input;
|
|
23416
23578
|
}
|
|
@@ -23436,7 +23598,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
23436
23598
|
throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
|
|
23437
23599
|
}
|
|
23438
23600
|
const fill = fillFormFields(parsed.blocks, values);
|
|
23439
|
-
const markdown =
|
|
23601
|
+
const markdown = _chunkRWSGBXSAcjs.blocksToMarkdown.call(void 0, fill.blocks);
|
|
23440
23602
|
if (outputFormat === "hwpx") {
|
|
23441
23603
|
const hwpxBuffer = await markdownToHwpx(markdown);
|
|
23442
23604
|
return { output: hwpxBuffer, format: "hwpx", fill };
|
|
@@ -23484,5 +23646,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
|
|
|
23484
23646
|
|
|
23485
23647
|
|
|
23486
23648
|
|
|
23487
|
-
|
|
23649
|
+
|
|
23650
|
+
|
|
23651
|
+
exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.VERSION = _chunkRWSGBXSAcjs.VERSION; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkRWSGBXSAcjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.renderHtml = renderHtml; exports.scanSectionXml = scanSectionXml;
|
|
23488
23652
|
//# sourceMappingURL=index.cjs.map
|