kordoc 4.18.2 → 4.18.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{-I3CP33G4.js → -WOKB25R2.js} +11 -11
- package/dist/{chunk-M4P7YS2N.js → chunk-2I2RTJJ5.js} +66 -36
- package/dist/chunk-2I2RTJJ5.js.map +1 -0
- package/dist/{chunk-QGFZU3JE.cjs → chunk-2ZBLQVAS.cjs} +10 -8
- package/dist/chunk-2ZBLQVAS.cjs.map +1 -0
- package/dist/{chunk-LSOD2A6N.js → chunk-3FZGL3IL.js} +2 -2
- package/dist/{chunk-NZM2SSI4.js → chunk-5X7XWYR2.js} +2 -2
- package/dist/{chunk-GM7XIZF2.js → chunk-6GLTGOP6.js} +2 -2
- package/dist/{chunk-6OKBTY72.js → chunk-AZQWESRH.js} +2 -2
- package/dist/{chunk-O2DI4GHD.js → chunk-BGOR5GCF.js} +2 -2
- package/dist/{chunk-L64QRUMK.js → chunk-BJ6RYYXV.js} +9 -6
- package/dist/chunk-BJ6RYYXV.js.map +1 -0
- package/dist/{chunk-N5DQFA7L.js → chunk-CAN5P6N6.js} +10 -5
- package/dist/chunk-CAN5P6N6.js.map +1 -0
- package/dist/{chunk-YNLW6EGU.cjs → chunk-HZV52V2X.cjs} +3 -3
- package/dist/{chunk-YNLW6EGU.cjs.map → chunk-HZV52V2X.cjs.map} +1 -1
- package/dist/{chunk-BL7KRE6X.js → chunk-IXX3WHIE.js} +3 -3
- package/dist/{chunk-OGAYGUJF.js → chunk-J2A46VCA.js} +8 -5
- package/dist/chunk-J2A46VCA.js.map +1 -0
- package/dist/{chunk-CKUIFTXJ.js → chunk-KSJ7GKNQ.js} +2 -2
- package/dist/{chunk-L5RLJPI3.js → chunk-NES5U4JK.js} +3 -3
- package/dist/{chunk-VSY5PAJ5.js → chunk-OOX2GZZ4.js} +2 -2
- package/dist/{chunk-B2E6C2LH.js → chunk-PSJLB3SZ.js} +6 -4
- package/dist/chunk-PSJLB3SZ.js.map +1 -0
- package/dist/{chunk-4B2EXELH.js → chunk-RDBTOE5X.js} +2 -2
- package/dist/{chunk-QP7IXF7R.js → chunk-RRURZDEK.js} +2 -2
- package/dist/{chunk-LACO375L.js → chunk-RSDUH4XF.js} +4 -3
- package/dist/chunk-RSDUH4XF.js.map +1 -0
- package/dist/{chunk-UZGZRGYM.cjs → chunk-SHRRD2TD.cjs} +10 -5
- package/dist/chunk-SHRRD2TD.cjs.map +1 -0
- package/dist/{chunk-F5HING4Y.js → chunk-UVUKT3IQ.js} +5 -4
- package/dist/chunk-UVUKT3IQ.js.map +1 -0
- package/dist/{chunk-W2YYBPW5.cjs → chunk-V4BKT65D.cjs} +3 -3
- package/dist/{chunk-W2YYBPW5.cjs.map → chunk-V4BKT65D.cjs.map} +1 -1
- package/dist/{chunk-OBILAVWC.js → chunk-VGDTONTB.js} +10 -5
- package/dist/chunk-VGDTONTB.js.map +1 -0
- package/dist/{chunk-IA3UKDHA.js → chunk-W3RADOLO.js} +3 -2
- package/dist/{chunk-IA3UKDHA.js.map → chunk-W3RADOLO.js.map} +1 -1
- package/dist/{chunk-C2CVOC5K.js → chunk-W7P4GPOV.js} +4 -4
- package/dist/{chunk-KDMAYOWH.cjs → chunk-WN5YLP7H.cjs} +26 -23
- package/dist/chunk-WN5YLP7H.cjs.map +1 -0
- package/dist/{chunk-OI5ZSSIC.cjs → chunk-ZD5WNQNC.cjs} +12 -12
- package/dist/{chunk-OI5ZSSIC.cjs.map → chunk-ZD5WNQNC.cjs.map} +1 -1
- package/dist/{chunk-T4MXCSBP.js → chunk-ZN3LHNJG.js} +49 -26
- package/dist/chunk-ZN3LHNJG.js.map +1 -0
- package/dist/chunks-OQDRDICD.js +10 -0
- package/dist/cli.js +55 -34
- package/dist/cli.js.map +1 -1
- package/dist/{formula-VY4ITOMN.cjs → formula-BQ5RW5XD.cjs} +9 -9
- package/dist/{formula-VY4ITOMN.cjs.map → formula-BQ5RW5XD.cjs.map} +1 -1
- package/dist/{formula-AQZODKZF.js → formula-GPCOJJXN.js} +3 -3
- package/dist/{formula-E3N7KDDG.js → formula-QZAOKPBX.js} +4 -4
- package/dist/{image-ocr-IMYXOHHV.js → image-ocr-POCME5I4.js} +6 -6
- package/dist/{image-ocr-LN3GSQPW.js → image-ocr-TWNNVTZS.js} +9 -9
- package/dist/{image-ocr-6LYEBMVR.cjs → image-ocr-VKIUBLBX.cjs} +15 -15
- package/dist/{image-ocr-6LYEBMVR.cjs.map → image-ocr-VKIUBLBX.cjs.map} +1 -1
- package/dist/index.cjs +800 -748
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +104 -52
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +26 -26
- package/dist/mcp.js.map +1 -1
- package/dist/{model-bundle-IHKNDLOT.js → model-bundle-THYUL7GG.js} +5 -5
- package/dist/{models-YXITRAMR.js → models-U22N4RXX.js} +5 -5
- package/dist/{parser-7KECZTTP.cjs → parser-JOMFOZLH.cjs} +211 -198
- package/dist/parser-JOMFOZLH.cjs.map +1 -0
- package/dist/{parser-KB4BYQBZ.js → parser-NKP2NCSV.js} +24 -11
- package/dist/parser-NKP2NCSV.js.map +1 -0
- package/dist/{parser-M3T2EWUN.js → parser-SCXRLOW7.js} +21 -8
- package/dist/parser-SCXRLOW7.js.map +1 -0
- package/dist/pdf-ocr-NF4AY5MI.cjs +16 -0
- package/dist/{pdf-ocr-IGYCZ7G2.cjs.map → pdf-ocr-NF4AY5MI.cjs.map} +1 -1
- package/dist/pdf-ocr-OLII3WAG.js +15 -0
- package/dist/pdf-ocr-VJL7ON2Q.js +19 -0
- package/dist/{profile-io-GQWQR7YQ.js → profile-io-UI3TZBYH.js} +3 -3
- package/dist/{rasterize-Y6TVFQ3M.js → rasterize-XMBV5H2I.js} +3 -3
- package/dist/{redact-doc-TRPZ3HNW.js → redact-doc-7ZZMHDBO.js} +11 -11
- package/dist/{render-GHT5HKBO.js → render-SWRTUDAV.js} +7 -7
- package/dist/seal-UKKJZHKE.js +10 -0
- package/dist/{setup-AGSCEHDB.js → setup-43JJEEU7.js} +3 -3
- package/dist/visual-D2563HCJ.js +20 -0
- package/dist/{watch-ALSEW4GB.js → watch-NRATQ472.js} +13 -13
- package/dist/watch-NRATQ472.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-B2E6C2LH.js.map +0 -1
- package/dist/chunk-F5HING4Y.js.map +0 -1
- package/dist/chunk-KDMAYOWH.cjs.map +0 -1
- package/dist/chunk-L64QRUMK.js.map +0 -1
- package/dist/chunk-LACO375L.js.map +0 -1
- package/dist/chunk-M4P7YS2N.js.map +0 -1
- package/dist/chunk-N5DQFA7L.js.map +0 -1
- package/dist/chunk-OBILAVWC.js.map +0 -1
- package/dist/chunk-OGAYGUJF.js.map +0 -1
- package/dist/chunk-QGFZU3JE.cjs.map +0 -1
- package/dist/chunk-T4MXCSBP.js.map +0 -1
- package/dist/chunk-UZGZRGYM.cjs.map +0 -1
- package/dist/chunks-IFFRC5IQ.js +0 -10
- package/dist/parser-7KECZTTP.cjs.map +0 -1
- package/dist/parser-KB4BYQBZ.js.map +0 -1
- package/dist/parser-M3T2EWUN.js.map +0 -1
- package/dist/pdf-ocr-4S2OAHUX.js +0 -15
- package/dist/pdf-ocr-IGYCZ7G2.cjs +0 -16
- package/dist/pdf-ocr-YEBFWU2K.js +0 -19
- package/dist/seal-3YTXSABW.js +0 -10
- package/dist/visual-R3E35Q2K.js +0 -20
- package/dist/watch-ALSEW4GB.js.map +0 -1
- /package/dist/{-I3CP33G4.js.map → -WOKB25R2.js.map} +0 -0
- /package/dist/{chunk-LSOD2A6N.js.map → chunk-3FZGL3IL.js.map} +0 -0
- /package/dist/{chunk-NZM2SSI4.js.map → chunk-5X7XWYR2.js.map} +0 -0
- /package/dist/{chunk-GM7XIZF2.js.map → chunk-6GLTGOP6.js.map} +0 -0
- /package/dist/{chunk-6OKBTY72.js.map → chunk-AZQWESRH.js.map} +0 -0
- /package/dist/{chunk-O2DI4GHD.js.map → chunk-BGOR5GCF.js.map} +0 -0
- /package/dist/{chunk-BL7KRE6X.js.map → chunk-IXX3WHIE.js.map} +0 -0
- /package/dist/{chunk-CKUIFTXJ.js.map → chunk-KSJ7GKNQ.js.map} +0 -0
- /package/dist/{chunk-L5RLJPI3.js.map → chunk-NES5U4JK.js.map} +0 -0
- /package/dist/{chunk-VSY5PAJ5.js.map → chunk-OOX2GZZ4.js.map} +0 -0
- /package/dist/{chunk-4B2EXELH.js.map → chunk-RDBTOE5X.js.map} +0 -0
- /package/dist/{chunk-QP7IXF7R.js.map → chunk-RRURZDEK.js.map} +0 -0
- /package/dist/{chunk-C2CVOC5K.js.map → chunk-W7P4GPOV.js.map} +0 -0
- /package/dist/{chunks-IFFRC5IQ.js.map → chunks-OQDRDICD.js.map} +0 -0
- /package/dist/{formula-AQZODKZF.js.map → formula-GPCOJJXN.js.map} +0 -0
- /package/dist/{formula-E3N7KDDG.js.map → formula-QZAOKPBX.js.map} +0 -0
- /package/dist/{image-ocr-IMYXOHHV.js.map → image-ocr-POCME5I4.js.map} +0 -0
- /package/dist/{image-ocr-LN3GSQPW.js.map → image-ocr-TWNNVTZS.js.map} +0 -0
- /package/dist/{model-bundle-IHKNDLOT.js.map → model-bundle-THYUL7GG.js.map} +0 -0
- /package/dist/{models-YXITRAMR.js.map → models-U22N4RXX.js.map} +0 -0
- /package/dist/{pdf-ocr-4S2OAHUX.js.map → pdf-ocr-OLII3WAG.js.map} +0 -0
- /package/dist/{pdf-ocr-YEBFWU2K.js.map → pdf-ocr-VJL7ON2Q.js.map} +0 -0
- /package/dist/{profile-io-GQWQR7YQ.js.map → profile-io-UI3TZBYH.js.map} +0 -0
- /package/dist/{rasterize-Y6TVFQ3M.js.map → rasterize-XMBV5H2I.js.map} +0 -0
- /package/dist/{redact-doc-TRPZ3HNW.js.map → redact-doc-7ZZMHDBO.js.map} +0 -0
- /package/dist/{render-GHT5HKBO.js.map → render-SWRTUDAV.js.map} +0 -0
- /package/dist/{seal-3YTXSABW.js.map → seal-UKKJZHKE.js.map} +0 -0
- /package/dist/{setup-AGSCEHDB.js.map → setup-43JJEEU7.js.map} +0 -0
- /package/dist/{visual-R3E35Q2K.js.map → visual-D2563HCJ.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
blocksToPages,
|
|
3
3
|
inlineImagesIntoMarkdown
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BGOR5GCF.js";
|
|
5
5
|
import {
|
|
6
6
|
parsePageRange
|
|
7
7
|
} from "./chunk-V4BH5SRQ.js";
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
tidyScriptTags,
|
|
32
32
|
unframeLayoutTables,
|
|
33
33
|
wrapScript
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-PSJLB3SZ.js";
|
|
35
35
|
import {
|
|
36
36
|
KordocError,
|
|
37
37
|
OPTIONAL_DEP_INSTALL_HINT,
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
escapeHtml,
|
|
42
42
|
isPathTraversal,
|
|
43
43
|
normalizeSectionHref,
|
|
44
|
+
partExtension,
|
|
44
45
|
precheckZipSize,
|
|
45
46
|
sanitizeError,
|
|
46
47
|
sanitizeHref,
|
|
@@ -48,7 +49,7 @@ import {
|
|
|
48
49
|
toArrayBuffer,
|
|
49
50
|
unescapeHtml,
|
|
50
51
|
unzipLimitBytes
|
|
51
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-CAN5P6N6.js";
|
|
52
53
|
|
|
53
54
|
// src/plain-markdown.ts
|
|
54
55
|
function toPlainMarkdown(md2) {
|
|
@@ -585,7 +586,8 @@ function createSectionShared() {
|
|
|
585
586
|
numState: /* @__PURE__ */ new Map(),
|
|
586
587
|
pageText: { headers: [], footers: [] },
|
|
587
588
|
track: { deleteDepth: 0, warned: false, deletedObjects: /* @__PURE__ */ new WeakSet(), deletedImageRefs: /* @__PURE__ */ new Set() },
|
|
588
|
-
pageState: { base: 0, allUsable: true }
|
|
589
|
+
pageState: { base: 0, allUsable: true },
|
|
590
|
+
tocTexts: /* @__PURE__ */ new Set()
|
|
589
591
|
};
|
|
590
592
|
}
|
|
591
593
|
function createXmlParser(warnings) {
|
|
@@ -937,7 +939,7 @@ function parseParaHeadings(doc, map) {
|
|
|
937
939
|
if (map.size > 0) break;
|
|
938
940
|
}
|
|
939
941
|
}
|
|
940
|
-
function detectHwpxHeadings(blocks, styleMap) {
|
|
942
|
+
function detectHwpxHeadings(blocks, styleMap, tocTexts) {
|
|
941
943
|
if (blocks.some((b) => b.type === "heading")) return;
|
|
942
944
|
let baseFontSize = 0;
|
|
943
945
|
const sizeFreq = /* @__PURE__ */ new Map();
|
|
@@ -954,7 +956,7 @@ function detectHwpxHeadings(blocks, styleMap) {
|
|
|
954
956
|
}
|
|
955
957
|
}
|
|
956
958
|
for (const block of blocks) {
|
|
957
|
-
if (block.type !== "paragraph" || !block.text || TOC_ENTRY_BLOCKS.has(block)) continue;
|
|
959
|
+
if (block.type !== "paragraph" || !block.text || TOC_ENTRY_BLOCKS.has(block) || tocTexts?.has(block.text.trim())) continue;
|
|
958
960
|
const text = block.text.trim();
|
|
959
961
|
if (text.length === 0 || text.length > 200 || /^\d+$/.test(text)) continue;
|
|
960
962
|
let level = 0;
|
|
@@ -2121,13 +2123,13 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2121
2123
|
}
|
|
2122
2124
|
if (tableCtx) tableStack.push(tableCtx);
|
|
2123
2125
|
const newTable = { rows: [], currentRow: [], cell: null, sourceId: el.getAttribute("id") ?? void 0 };
|
|
2124
|
-
walkSection(el, blocks, newTable, tableStack, ctx, depth + 1);
|
|
2126
|
+
inIndependentDeletionStory(ctx.shared.track, () => walkSection(el, blocks, newTable, tableStack, ctx, depth + 1));
|
|
2125
2127
|
tableCtx = completeTable(newTable, tableStack, blocks, ctx);
|
|
2126
2128
|
break;
|
|
2127
2129
|
}
|
|
2128
2130
|
// 표/도표 캡션 — IRTable.caption으로 보존 (v3.0, 기존 무음 드롭 수정)
|
|
2129
2131
|
case "caption": {
|
|
2130
|
-
const cap = collectSubListContent(el, ctx);
|
|
2132
|
+
const cap = inIndependentDeletionStory(ctx.shared.track, () => collectSubListContent(el, ctx));
|
|
2131
2133
|
if (cap.text) {
|
|
2132
2134
|
if (tableCtx) {
|
|
2133
2135
|
tableCtx.caption = (tableCtx.caption ? tableCtx.caption + "\n" : "") + cap.text;
|
|
@@ -2187,6 +2189,9 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2187
2189
|
if (text) {
|
|
2188
2190
|
if (ph?.prefix) text = ph.prefix + " " + text;
|
|
2189
2191
|
headingLevel = tocEntry ? void 0 : ph?.headingLevel;
|
|
2192
|
+
if (tocEntry) {
|
|
2193
|
+
for (const line of text.split("\n")) if (line.trim()) ctx.shared.tocTexts.add(line.trim());
|
|
2194
|
+
}
|
|
2190
2195
|
}
|
|
2191
2196
|
if (segments) {
|
|
2192
2197
|
const cell2 = tableCtx?.cell ?? null;
|
|
@@ -2272,6 +2277,15 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
|
|
|
2272
2277
|
if (spanMode !== "foreign" && el.getAttribute("paraPrIDRef") === KORDOC_PARA_QUOTE) block.quote = true;
|
|
2273
2278
|
}
|
|
2274
2279
|
if (!headingLevel && !block.spans && placeholderSpans) block.spans = withPrefixSpan(placeholderSpans, ph?.prefix);
|
|
2280
|
+
if (headingLevel && placeholderSpans) {
|
|
2281
|
+
const shown = withPrefixSpan(placeholderSpans.filter((s) => !s.placeholder), ph?.prefix).map((s) => s.text).join("").trim();
|
|
2282
|
+
if (shown) block.text = shown;
|
|
2283
|
+
else {
|
|
2284
|
+
block.type = "paragraph";
|
|
2285
|
+
delete block.level;
|
|
2286
|
+
block.spans = withPrefixSpan(placeholderSpans, ph?.prefix);
|
|
2287
|
+
}
|
|
2288
|
+
}
|
|
2275
2289
|
blocks.push(block);
|
|
2276
2290
|
} else {
|
|
2277
2291
|
blocks.push({ type: "paragraph", text, pageNumber: ctx.page });
|
|
@@ -2513,10 +2527,10 @@ function walkParagraphChildren(node, blocks, tableCtx, tableStack, ctx, depth =
|
|
|
2513
2527
|
}
|
|
2514
2528
|
if (tableCtx) tableStack.push(tableCtx);
|
|
2515
2529
|
const newTable = { rows: [], currentRow: [], cell: null, inline: isInlineTbl(el), sourceId: el.getAttribute("id") ?? void 0 };
|
|
2516
|
-
walkSection(el, blocks, newTable, tableStack, ctx, d + 1);
|
|
2530
|
+
inIndependentDeletionStory(ctx.shared.track, () => walkSection(el, blocks, newTable, tableStack, ctx, d + 1));
|
|
2517
2531
|
tableCtx = completeTable(newTable, tableStack, blocks, ctx);
|
|
2518
2532
|
} else if (localTag === "caption" && !inShape) {
|
|
2519
|
-
const cap = collectSubListContent(el, ctx);
|
|
2533
|
+
const cap = inIndependentDeletionStory(ctx.shared.track, () => collectSubListContent(el, ctx));
|
|
2520
2534
|
if (cap.text) {
|
|
2521
2535
|
if (tableCtx?.cell) mergeBlocksIntoCell(tableCtx.cell, [{ type: "paragraph", text: cap.text, pageNumber: ctx.page }]);
|
|
2522
2536
|
else if (tableCtx) {
|
|
@@ -2712,7 +2726,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2712
2726
|
// 아니므로 방출하지 않는다
|
|
2713
2727
|
case "header":
|
|
2714
2728
|
case "footer": {
|
|
2715
|
-
if (!ctx) break;
|
|
2729
|
+
if (!ctx || isInDeletedRange(ctx)) break;
|
|
2716
2730
|
const t = collectSubListText(k, ctx);
|
|
2717
2731
|
if (t && hasPageAutoNum(k) && !/\p{L}/u.test(t)) break;
|
|
2718
2732
|
if (t) {
|
|
@@ -2834,9 +2848,10 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2834
2848
|
if (isInlineTbl(child)) text += "";
|
|
2835
2849
|
break;
|
|
2836
2850
|
// 양식 선택 상자·라디오 단추 — 한컴이 그리는 상자 기호와 캡션 글 (종전엔 통째로 빠졌다: form-002 "원천기술형"·서울 결재 "부분공개")
|
|
2851
|
+
// 지운 구간의 양식 단추·수식은 글처럼 내지 않는다 (최종본)
|
|
2837
2852
|
case "checkBtn":
|
|
2838
2853
|
case "radioBtn":
|
|
2839
|
-
text += formButtonText(child, tag === "radioBtn");
|
|
2854
|
+
if (!isInDeletedRange(ctx)) text += formButtonText(child, tag === "radioBtn");
|
|
2840
2855
|
break;
|
|
2841
2856
|
// 하이퍼링크
|
|
2842
2857
|
case "hyperlink": {
|
|
@@ -2906,6 +2921,7 @@ function extractParagraphInfo(para2, styleMap, ctx) {
|
|
|
2906
2921
|
// 스크립트가 담겨 있음. hml-equation-parser 로 LaTeX 변환 후 `$...$`
|
|
2907
2922
|
// 로 래핑. 실패/빈 스크립트면 무시 (대체 텍스트 누출 방지).
|
|
2908
2923
|
case "equation": {
|
|
2924
|
+
if (isInDeletedRange(ctx)) break;
|
|
2909
2925
|
const script = findChildByLocalName(child, "script");
|
|
2910
2926
|
const raw = script ? extractTextFromNode(script) : "";
|
|
2911
2927
|
if (raw.trim()) {
|
|
@@ -3954,7 +3970,7 @@ async function parseHwpxDocument(buffer, options) {
|
|
|
3954
3970
|
applyPageText(blocks, shared);
|
|
3955
3971
|
const images = await extractImagesFromZip(zip, blocks, decompressed, warnings, !options?.pages, shared.track.deletedImageRefs);
|
|
3956
3972
|
const shown = options?.layoutTables === "keep" ? blocks : unframeLayoutTables(blocks, !!options?.keepTrailingEmptyCols);
|
|
3957
|
-
detectHwpxHeadings(shown, styleMap);
|
|
3973
|
+
detectHwpxHeadings(shown, styleMap, shared.tocTexts);
|
|
3958
3974
|
const outline = shown.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
3959
3975
|
const markdown = blocksToMarkdown(shown);
|
|
3960
3976
|
return { markdown, blocks: shown, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
|
|
@@ -5361,6 +5377,7 @@ function createHwp5DocState() {
|
|
|
5361
5377
|
outlineNumberingId: 0,
|
|
5362
5378
|
autoCounters: /* @__PURE__ */ new Map(),
|
|
5363
5379
|
headerTexts: /* @__PURE__ */ new Set(),
|
|
5380
|
+
tocTexts: /* @__PURE__ */ new Set(),
|
|
5364
5381
|
headerBlocks: [],
|
|
5365
5382
|
footerBlocks: []
|
|
5366
5383
|
};
|
|
@@ -5506,6 +5523,12 @@ function parseParagraph(records, start, end, ctx) {
|
|
|
5506
5523
|
if (bullet && bullet.char !== "\uFFFF") headMarker = bullet.char;
|
|
5507
5524
|
}
|
|
5508
5525
|
}
|
|
5526
|
+
if (toc.tocEntry) {
|
|
5527
|
+
for (const line of text.split("\n")) if (line.trim()) {
|
|
5528
|
+
ctx.doc.tocTexts.add(line.trim());
|
|
5529
|
+
if (headMarker) ctx.doc.tocTexts.add(`${headMarker} ${line.trim()}`);
|
|
5530
|
+
}
|
|
5531
|
+
}
|
|
5509
5532
|
return emitParagraphBlocks({
|
|
5510
5533
|
text,
|
|
5511
5534
|
headMarker,
|
|
@@ -6065,7 +6088,7 @@ function parseHwp5Document(buffer, options) {
|
|
|
6065
6088
|
flatBlocks = deduped;
|
|
6066
6089
|
}
|
|
6067
6090
|
if (docInfo) {
|
|
6068
|
-
detectHwp5Headings(flatBlocks, docInfo);
|
|
6091
|
+
detectHwp5Headings(flatBlocks, docInfo, doc.tocTexts);
|
|
6069
6092
|
}
|
|
6070
6093
|
const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
|
|
6071
6094
|
let markdown = blocksToMarkdown(flatBlocks);
|
|
@@ -6098,7 +6121,7 @@ function parseDocInfoFromStream(raw, compressed) {
|
|
|
6098
6121
|
return null;
|
|
6099
6122
|
}
|
|
6100
6123
|
}
|
|
6101
|
-
function detectHwp5Headings(blocks, docInfo) {
|
|
6124
|
+
function detectHwp5Headings(blocks, docInfo, tocTexts) {
|
|
6102
6125
|
let baseFontSize = 0;
|
|
6103
6126
|
const sizeFreq = /* @__PURE__ */ new Map();
|
|
6104
6127
|
for (const b of blocks) {
|
|
@@ -6128,7 +6151,7 @@ function detectHwp5Headings(blocks, docInfo) {
|
|
|
6128
6151
|
if (baseFontSize <= 0) return;
|
|
6129
6152
|
for (const block of blocks) {
|
|
6130
6153
|
if (block.type === "heading") continue;
|
|
6131
|
-
if (block.type !== "paragraph" || !block.text || TOC_ENTRY_BLOCKS.has(block)) continue;
|
|
6154
|
+
if (block.type !== "paragraph" || !block.text || TOC_ENTRY_BLOCKS.has(block) || tocTexts?.has(block.text.trim())) continue;
|
|
6132
6155
|
const text = block.text.trim();
|
|
6133
6156
|
if (text.length === 0 || text.length > 200) continue;
|
|
6134
6157
|
if (/^\d+$/.test(text)) continue;
|
|
@@ -19387,7 +19410,7 @@ function collectRichText(root) {
|
|
|
19387
19410
|
const el = children[i];
|
|
19388
19411
|
const local = el.localName || el.tagName?.replace(/^[^:]+:/, "") || "";
|
|
19389
19412
|
if (local === "rPh") continue;
|
|
19390
|
-
if (local === "t") out += escapeLiteralTags(el.textContent ?? "");
|
|
19413
|
+
if (local === "t") out += escapeLiteralTags(escapeLiteralDollar(el.textContent ?? ""));
|
|
19391
19414
|
else walk(el);
|
|
19392
19415
|
}
|
|
19393
19416
|
};
|
|
@@ -20011,14 +20034,14 @@ function extractSheetCells(records, bofIndex, sst, convertNum) {
|
|
|
20011
20034
|
const h = readCellHeader(rec.data);
|
|
20012
20035
|
if (h && rec.data.length >= 10) {
|
|
20013
20036
|
const isst = rec.data.readUInt32LE(6);
|
|
20014
|
-
cells.push({ row: h.row, col: h.col, value: escapeLiteralTags(sst[isst] ?? "") });
|
|
20037
|
+
cells.push({ row: h.row, col: h.col, value: escapeLiteralTags(escapeLiteralDollar(sst[isst] ?? "")) });
|
|
20015
20038
|
}
|
|
20016
20039
|
break;
|
|
20017
20040
|
}
|
|
20018
20041
|
case OP_LABEL: {
|
|
20019
20042
|
const h = readCellHeader(rec.data);
|
|
20020
20043
|
if (h) {
|
|
20021
|
-
cells.push({ row: h.row, col: h.col, value: escapeLiteralTags(decodeLabelString(rec.data)) });
|
|
20044
|
+
cells.push({ row: h.row, col: h.col, value: escapeLiteralTags(escapeLiteralDollar(decodeLabelString(rec.data))) });
|
|
20022
20045
|
}
|
|
20023
20046
|
break;
|
|
20024
20047
|
}
|
|
@@ -20034,7 +20057,7 @@ function extractSheetCells(records, bofIndex, sst, convertNum) {
|
|
|
20034
20057
|
cells.push({
|
|
20035
20058
|
row: h.row,
|
|
20036
20059
|
col: h.col,
|
|
20037
|
-
value: escapeLiteralTags(decodeFormulaStringRecord(next.data))
|
|
20060
|
+
value: escapeLiteralTags(escapeLiteralDollar(decodeFormulaStringRecord(next.data)))
|
|
20038
20061
|
});
|
|
20039
20062
|
i = j;
|
|
20040
20063
|
} else {
|
|
@@ -20746,6 +20769,7 @@ function isDisplayMath(el) {
|
|
|
20746
20769
|
// src/docx/parser.ts
|
|
20747
20770
|
var MAX_DECOMPRESS_SIZE5 = unzipLimitBytes(100 * 1024 * 1024);
|
|
20748
20771
|
var MEDIA_PART_RE = /^word\/(?:media|embeddings)\//;
|
|
20772
|
+
var NEVER_READ_RE = /^word\/(?:embeddings\/.*|media\/.+\.(?:mp4|m4v|mov|avi|wmv|mpe?g|mkv|webm|mp3|wav|m4a|wma|aac|ogg|flac|mid|bin))$/i;
|
|
20749
20773
|
function matchesLocal(el, localName3) {
|
|
20750
20774
|
return el.localName === localName3 || (el.tagName?.endsWith(`:${localName3}`) ?? false);
|
|
20751
20775
|
}
|
|
@@ -20937,7 +20961,7 @@ function parseFootnotes(xml) {
|
|
|
20937
20961
|
const runs = findElements(p, "r");
|
|
20938
20962
|
for (const r of runs) {
|
|
20939
20963
|
const tElements = getChildElements(r, "t");
|
|
20940
|
-
for (const t of tElements) texts.push(escapeLiteralTags(t.textContent ?? ""));
|
|
20964
|
+
for (const t of tElements) texts.push(escapeLiteralTags(escapeLiteralDollar(t.textContent ?? "")));
|
|
20941
20965
|
}
|
|
20942
20966
|
}
|
|
20943
20967
|
notes.set(id, texts.join("").trim());
|
|
@@ -20968,7 +20992,7 @@ function collectOmmlRoots(p) {
|
|
|
20968
20992
|
function extractRun(r) {
|
|
20969
20993
|
let text = "";
|
|
20970
20994
|
for (const el of effectiveChildElements(r)) {
|
|
20971
|
-
if (matchesLocal(el, "t")) text += escapeLiteralTags(el.textContent ?? "");
|
|
20995
|
+
if (matchesLocal(el, "t")) text += escapeLiteralTags(escapeLiteralDollar(el.textContent ?? ""));
|
|
20972
20996
|
else if (matchesLocal(el, "br") || matchesLocal(el, "cr")) text += "\n";
|
|
20973
20997
|
else if (matchesLocal(el, "tab")) text += " ";
|
|
20974
20998
|
else if (matchesLocal(el, "sym")) text += symbolChar(getAttr(el, "font"), getAttr(el, "char"));
|
|
@@ -21264,7 +21288,7 @@ async function buildImageMap(zip, rels, doc, warnings, readBytes) {
|
|
|
21264
21288
|
let data = null;
|
|
21265
21289
|
if (readBytes) data = await imgFile.async("uint8array");
|
|
21266
21290
|
imgIdx++;
|
|
21267
|
-
const ext = imgPath
|
|
21291
|
+
const ext = partExtension(imgPath);
|
|
21268
21292
|
const mimeMap = {
|
|
21269
21293
|
png: "image/png",
|
|
21270
21294
|
jpg: "image/jpeg",
|
|
@@ -21363,7 +21387,7 @@ async function parseHeaderFooterBlocks(zip, doc, rels, kind, styles, numbering,
|
|
|
21363
21387
|
}
|
|
21364
21388
|
async function parseDocxDocument(buffer, options) {
|
|
21365
21389
|
const readImages = options?.images !== false;
|
|
21366
|
-
precheckZipSize(buffer, MAX_DECOMPRESS_SIZE5, void 0, { re: MEDIA_PART_RE, skip: !readImages });
|
|
21390
|
+
precheckZipSize(buffer, MAX_DECOMPRESS_SIZE5, void 0, { re: MEDIA_PART_RE, skip: !readImages, never: NEVER_READ_RE });
|
|
21367
21391
|
const zip = await JSZip5.loadAsync(buffer);
|
|
21368
21392
|
const warnings = [];
|
|
21369
21393
|
const docFile = zip.file("word/document.xml");
|
|
@@ -21484,6 +21508,7 @@ import JSZip6 from "jszip";
|
|
|
21484
21508
|
import { DOMParser as DOMParser4 } from "@xmldom/xmldom";
|
|
21485
21509
|
var MAX_DECOMPRESS_SIZE6 = unzipLimitBytes(100 * 1024 * 1024);
|
|
21486
21510
|
var MEDIA_PART_RE2 = /^ppt\/(?:media|embeddings)\//;
|
|
21511
|
+
var NEVER_READ_RE2 = /^ppt\/(?:embeddings\/.*|media\/.+\.(?:mp4|m4v|mov|avi|wmv|mpe?g|mkv|webm|mp3|wav|m4a|wma|aac|ogg|flac|mid|bin))$/i;
|
|
21487
21512
|
var MAX_ZIP_ENTRIES2 = 1e4;
|
|
21488
21513
|
var MAX_SLIDES = 2e3;
|
|
21489
21514
|
var SKIP_PLACEHOLDERS = /* @__PURE__ */ new Set(["sldNum", "dt", "ftr", "hdr", "sldImg"]);
|
|
@@ -21580,12 +21605,14 @@ function paragraphText(p) {
|
|
|
21580
21605
|
const name = localName(child);
|
|
21581
21606
|
if (name === "r" || name === "fld") {
|
|
21582
21607
|
const t = findChildByLocalName(child, "t");
|
|
21583
|
-
|
|
21608
|
+
const rPr = findChildByLocalName(child, "rPr");
|
|
21609
|
+
const baseline = Number(rPr ? getAttr2(rPr, "baseline") ?? 0 : 0);
|
|
21610
|
+
if (t) text += wrapScript(escapeLiteralTags(escapeLiteralDollar(rawTextContent(t))), baseline > 0 ? "sup" : baseline < 0 ? "sub" : null);
|
|
21584
21611
|
} else if (name === "br") {
|
|
21585
21612
|
text += " ";
|
|
21586
21613
|
}
|
|
21587
21614
|
}
|
|
21588
|
-
return text.replace(/\s+/g, " ").trim();
|
|
21615
|
+
return tidyScriptTags(text.replace(/\s+/g, " ").trim());
|
|
21589
21616
|
}
|
|
21590
21617
|
function bodyParagraphs(txBody) {
|
|
21591
21618
|
const out = [];
|
|
@@ -21659,7 +21686,7 @@ async function pictureBlock(pic, ctx) {
|
|
|
21659
21686
|
if (!filename) {
|
|
21660
21687
|
const file = ctx.zip.file(rel.target);
|
|
21661
21688
|
if (!file) return null;
|
|
21662
|
-
const ext = rel.target
|
|
21689
|
+
const ext = partExtension(rel.target);
|
|
21663
21690
|
filename = `image_${String(ctx.imageNames.size + 1).padStart(3, "0")}.${ext}`;
|
|
21664
21691
|
try {
|
|
21665
21692
|
if (ctx.options?.images !== false) {
|
|
@@ -21737,7 +21764,7 @@ async function notesText(zip, rels) {
|
|
|
21737
21764
|
return texts.join(" ");
|
|
21738
21765
|
}
|
|
21739
21766
|
async function parsePptxDocument(buffer, options) {
|
|
21740
|
-
precheckZipSize(buffer, MAX_DECOMPRESS_SIZE6, MAX_ZIP_ENTRIES2, { re: MEDIA_PART_RE2, skip: options?.images === false });
|
|
21767
|
+
precheckZipSize(buffer, MAX_DECOMPRESS_SIZE6, MAX_ZIP_ENTRIES2, { re: MEDIA_PART_RE2, skip: options?.images === false, never: NEVER_READ_RE2 });
|
|
21741
21768
|
const zip = await JSZip6.loadAsync(buffer);
|
|
21742
21769
|
if (!zip.file("ppt/presentation.xml")) {
|
|
21743
21770
|
throw new KordocError("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 PPTX \uD30C\uC77C: ppt/presentation.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
|
|
@@ -21747,8 +21774,10 @@ async function parsePptxDocument(buffer, options) {
|
|
|
21747
21774
|
const imageNames = /* @__PURE__ */ new Map();
|
|
21748
21775
|
const images = [];
|
|
21749
21776
|
const slides = await slideParts(zip);
|
|
21777
|
+
const pageFilter = options?.pages ? parsePageRange(options.pages, slides.length) : null;
|
|
21750
21778
|
for (let i = 0; i < slides.length; i++) {
|
|
21751
21779
|
const page = i + 1;
|
|
21780
|
+
if (pageFilter && !pageFilter.has(page)) continue;
|
|
21752
21781
|
const root = parseXml3(await zip.file(slides[i]).async("text")).documentElement;
|
|
21753
21782
|
if (getAttr2(root, "show") === "0") {
|
|
21754
21783
|
warnings.push({ page, code: "HIDDEN_TEXT_FILTERED", message: `PPTX \uC228\uAE34 \uC2AC\uB77C\uC774\uB4DC ${page}\uCABD\uC744 \uAC74\uB108\uB701\uB2C8\uB2E4` });
|
|
@@ -28647,7 +28676,7 @@ function sanitizeText(text) {
|
|
|
28647
28676
|
return result;
|
|
28648
28677
|
}
|
|
28649
28678
|
function normForMatch(text) {
|
|
28650
|
-
return sanitizeText(text.replace(/\\\$/g, "$")).replace(/\s+/g, " ").trim();
|
|
28679
|
+
return sanitizeText(text.replace(/\\\$/g, "$").replace(/\\(?=<\/?(?:u|sup|sub)>)/g, "")).replace(/\s+/g, " ").trim();
|
|
28651
28680
|
}
|
|
28652
28681
|
function unescapeGfm(text) {
|
|
28653
28682
|
return text.replace(/\\([~*_`|#<$\\])/g, "$1");
|
|
@@ -35555,6 +35584,10 @@ async function patchHwpx(original, editedMarkdown, options) {
|
|
|
35555
35584
|
const parsed = await parseHwpxDocument(u8ToArrayBuffer(original), { layoutTables: "keep" });
|
|
35556
35585
|
origBlocks = parsed.blocks;
|
|
35557
35586
|
const visual = await parseHwpxDocument(u8ToArrayBuffer(original));
|
|
35587
|
+
if (parsed.markdown !== visual.markdown && editedMarkdown === visual.markdown) {
|
|
35588
|
+
const verification2 = options?.verify === false ? void 0 : diffUnitLists(splitMarkdownUnits(visual.markdown), splitMarkdownUnits(editedMarkdown));
|
|
35589
|
+
return { success: true, data: new Uint8Array(original), applied: 0, skipped, verification: verification2 };
|
|
35590
|
+
}
|
|
35558
35591
|
if (editedFromVisual(parsed.markdown, visual.markdown, editedMarkdown)) return { success: false, applied: 0, skipped, error: LAYOUT_MODE_MISMATCH };
|
|
35559
35592
|
} catch (err) {
|
|
35560
35593
|
return { success: false, applied: 0, skipped, error: `\uC6D0\uBCF8 HWPX \uD30C\uC2F1 \uC2E4\uD328: ${err instanceof Error ? err.message : String(err)}` };
|
|
@@ -39192,7 +39225,7 @@ var CHAR_CTRL_1SLOT = /* @__PURE__ */ new Set(["lineBreak", "hyphen", "nbSpace",
|
|
|
39192
39225
|
function pushFillers(chars, n, prId) {
|
|
39193
39226
|
for (let i = 0; i < n; i++) chars.push({ ch: "", prId });
|
|
39194
39227
|
}
|
|
39195
|
-
function pushTextSlots(t, chars, prId, depth) {
|
|
39228
|
+
function pushTextSlots(t, chars, prId, depth, del = { deleted: 0 }) {
|
|
39196
39229
|
if (depth > 32) return;
|
|
39197
39230
|
const kids = t.childNodes;
|
|
39198
39231
|
if (!kids) return;
|
|
@@ -39200,19 +39233,24 @@ function pushTextSlots(t, chars, prId, depth) {
|
|
|
39200
39233
|
const c = kids[i];
|
|
39201
39234
|
if (c.nodeType === 3 || c.nodeType === 4) {
|
|
39202
39235
|
for (const cp of c.textContent ?? "") {
|
|
39203
|
-
chars.push({ ch: cp, prId });
|
|
39236
|
+
chars.push({ ch: del.deleted ? "" : cp, prId });
|
|
39204
39237
|
if (cp.length === 2) chars.push({ ch: "", prId });
|
|
39205
39238
|
}
|
|
39206
39239
|
} else if (c.nodeType === 1) {
|
|
39207
39240
|
const el = c;
|
|
39208
39241
|
const tag = ln(el);
|
|
39209
|
-
if (tag === "
|
|
39210
|
-
|
|
39211
|
-
|
|
39242
|
+
if (tag === "deleteBegin" || tag === "deleteEnd") {
|
|
39243
|
+
del.deleted = deletionDelta(el, del.deleted);
|
|
39244
|
+
} else if (tag === "tab") {
|
|
39245
|
+
if (del.deleted) pushFillers(chars, 8, prId);
|
|
39246
|
+
else {
|
|
39247
|
+
chars.push({ ch: "", prId, tab: true, tabW: num2(el, "width") });
|
|
39248
|
+
pushFillers(chars, 7, prId);
|
|
39249
|
+
}
|
|
39212
39250
|
} else if (CHAR_CTRL_1SLOT.has(tag)) {
|
|
39213
|
-
chars.push(tag === "nbSpace" ? { ch: " ", prId, nb: true } : { ch: tag === "fwSpace" ? " " : "", prId });
|
|
39251
|
+
chars.push(del.deleted ? { ch: "", prId } : tag === "nbSpace" ? { ch: " ", prId, nb: true } : { ch: tag === "fwSpace" ? " " : "", prId });
|
|
39214
39252
|
} else {
|
|
39215
|
-
pushTextSlots(el, chars, prId, depth + 1);
|
|
39253
|
+
pushTextSlots(el, chars, prId, depth + 1, del);
|
|
39216
39254
|
}
|
|
39217
39255
|
}
|
|
39218
39256
|
}
|
|
@@ -39237,7 +39275,7 @@ function prepareDeletedRanges(root, depth = 0) {
|
|
|
39237
39275
|
deletedStarts.set(p, deleted);
|
|
39238
39276
|
const scan = (el, xmlDepth) => {
|
|
39239
39277
|
if (xmlDepth > 64) return;
|
|
39240
|
-
if (ln(el) === "ctrl") for (const ch of elements(el)) scan(ch, xmlDepth + 1);
|
|
39278
|
+
if (ln(el) === "ctrl" || ln(el) === "t") for (const ch of elements(el)) scan(ch, xmlDepth + 1);
|
|
39241
39279
|
else {
|
|
39242
39280
|
if (ln(el) === "deleteBegin" || ln(el) === "deleteEnd") deleted = deletionDelta(el, deleted);
|
|
39243
39281
|
deletedControls.set(el, deleted > 0);
|
|
@@ -39269,9 +39307,9 @@ function buildPara(p) {
|
|
|
39269
39307
|
for (const ch of elements(runEl)) {
|
|
39270
39308
|
const cn = ln(ch);
|
|
39271
39309
|
if (cn === "t") {
|
|
39272
|
-
const
|
|
39273
|
-
pushTextSlots(ch, chars, prId, 0);
|
|
39274
|
-
|
|
39310
|
+
const del = { deleted };
|
|
39311
|
+
pushTextSlots(ch, chars, prId, 0, del);
|
|
39312
|
+
deleted = del.deleted;
|
|
39275
39313
|
} else if (OBJ_TAGS.has(cn)) {
|
|
39276
39314
|
const sz = findChildByLocalName(ch, "sz");
|
|
39277
39315
|
const pos = findChildByLocalName(ch, "pos");
|
|
@@ -39793,14 +39831,15 @@ function shapeGeometry(o, boxX, boxY, defs, images, warn, local = false) {
|
|
|
39793
39831
|
const color = esc(line?.getAttribute("color") || "#000000");
|
|
39794
39832
|
const strokeW = style === "NONE" ? 0 : Math.max(0.2, num2(line, "width", 33) / 100 * 2.834645);
|
|
39795
39833
|
const dash = /DASH|DOT/.test(style) ? ` stroke-dasharray="${style.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
|
|
39796
|
-
const
|
|
39834
|
+
const keepWidth = local ? ` vector-effect="non-scaling-stroke"` : "";
|
|
39835
|
+
const stroke = strokeW ? ` stroke="${color}" stroke-width="${strokeW.toFixed(2)}"${dash}${keepWidth}` : "";
|
|
39797
39836
|
const fill = ` fill="${shapeFill(el, defs, images, warn)}"`;
|
|
39798
39837
|
let svg = "";
|
|
39799
39838
|
if (o.tag === "rect") svg = `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}"${fill}${stroke}/>`;
|
|
39800
39839
|
else if (o.tag === "ellipse") svg = `<ellipse cx="${pt(x + w / 2)}" cy="${pt(y + h / 2)}" rx="${pt(w / 2)}" ry="${pt(h / 2)}"${fill}${stroke}/>`;
|
|
39801
39840
|
else if (o.tag === "line") {
|
|
39802
39841
|
const s = findChildByLocalName(el, "startPt"), e = findChildByLocalName(el, "endPt");
|
|
39803
|
-
svg = `<line x1="${pt(x + num2(s, "x") * sx)}" y1="${pt(y + num2(s, "y") * sy)}" x2="${pt(x + num2(e, "x") * sx)}" y2="${pt(y + num2(e, "y") * sy)}" stroke="${color}" stroke-width="${(strokeW || 0.3).toFixed(2)}"${dash}/>`;
|
|
39842
|
+
svg = `<line x1="${pt(x + num2(s, "x") * sx)}" y1="${pt(y + num2(s, "y") * sy)}" x2="${pt(x + num2(e, "x") * sx)}" y2="${pt(y + num2(e, "y") * sy)}" stroke="${color}" stroke-width="${(strokeW || 0.3).toFixed(2)}"${dash}${keepWidth}/>`;
|
|
39804
39843
|
} else if (o.tag === "polygon" || o.tag === "curv") {
|
|
39805
39844
|
const pts = elements(el).filter((c) => ln(c) === "pt").map((c) => `${pt(x + num2(c, "x") * sx)},${pt(y + num2(c, "y") * sy)}`);
|
|
39806
39845
|
if (pts.length >= 2) svg = `<polygon points="${pts.join(" ")}"${fill}${stroke}/>`;
|
|
@@ -40156,15 +40195,15 @@ function drawGroupByMatrix(o, x, y, baseV, areaW, ctx, depth) {
|
|
|
40156
40195
|
emit(ctx, `<g transform="matrix(${m.slice(0, 4).map((v) => Math.round(v * 1e6) / 1e6).join(" ")} ${pt2(m[4])} ${pt2(m[5])})">`);
|
|
40157
40196
|
const sub = { el: leaf, tag, index: 0, inline: true, width: w, height: h, omL: 0, omR: 0 };
|
|
40158
40197
|
if (tag === "pic") drawPicFrame(leaf, 0, 0, w, h, "", ctx);
|
|
40159
|
-
else if (SHAPE_TAGS.has(tag)) drawShape(sub, 0, 0, ctx, depth + 1,
|
|
40198
|
+
else if (SHAPE_TAGS.has(tag)) drawShape(sub, 0, 0, ctx, depth + 1, [Math.hypot(m[0], m[1]) || 1, Math.hypot(m[2], m[3]) || 1]);
|
|
40160
40199
|
else drawObject(sub, 0, 0, baseV, areaW, ctx, depth + 1);
|
|
40161
40200
|
emit(ctx, "</g>");
|
|
40162
40201
|
ctx.regionRotations.pop();
|
|
40163
40202
|
}
|
|
40164
40203
|
return true;
|
|
40165
40204
|
}
|
|
40166
|
-
function drawShape(o, x, y, ctx, depth,
|
|
40167
|
-
const geometry = shapeGeometry(o, x, y, ctx.defs, ctx.images, (key, msg2) => warnOnce(ctx, key, msg2),
|
|
40205
|
+
function drawShape(o, x, y, ctx, depth, groupScale) {
|
|
40206
|
+
const geometry = shapeGeometry(o, x, y, ctx.defs, ctx.images, (key, msg2) => warnOnce(ctx, key, msg2), !!groupScale);
|
|
40168
40207
|
const b = geometry;
|
|
40169
40208
|
if (geometry.rotation) ctx.regionRotations.push(geometry.rotation);
|
|
40170
40209
|
ctx.stats.shapes++;
|
|
@@ -40176,7 +40215,17 @@ function drawShape(o, x, y, ctx, depth, local = false) {
|
|
|
40176
40215
|
const dt = findChildByLocalName(o.el, "drawText");
|
|
40177
40216
|
const sub = dt ? findChildByLocalName(dt, "subList") : null;
|
|
40178
40217
|
if (sub) {
|
|
40179
|
-
|
|
40218
|
+
const [sx, sy] = groupScale ?? [1, 1];
|
|
40219
|
+
const unscale = sx !== 1 || sy !== 1;
|
|
40220
|
+
if (unscale) {
|
|
40221
|
+
emit(ctx, `<g transform="scale(${1 / sx} ${1 / sy})">`);
|
|
40222
|
+
ctx.regionRotations.push([1 / sx, 0, 0, 1 / sy, 0, 0]);
|
|
40223
|
+
}
|
|
40224
|
+
for (const p of elements(sub)) if (ln(p) === "p") drawPara(p, geometry.x * sx, geometry.y * sy, geometry.w * sx, ctx, depth + 1);
|
|
40225
|
+
if (unscale) {
|
|
40226
|
+
ctx.regionRotations.pop();
|
|
40227
|
+
emit(ctx, "</g>");
|
|
40228
|
+
}
|
|
40180
40229
|
}
|
|
40181
40230
|
if (geometry.rotation) ctx.regionRotations.pop();
|
|
40182
40231
|
if (geometry.transform) emit(ctx, "</g>");
|
|
@@ -41458,9 +41507,12 @@ async function parse(input, options) {
|
|
|
41458
41507
|
}
|
|
41459
41508
|
if (result.success && opts?.classifyTables) classifyTableTree(result.blocks);
|
|
41460
41509
|
let out = result;
|
|
41461
|
-
if (result.success &&
|
|
41462
|
-
|
|
41463
|
-
|
|
41510
|
+
if (result.success && opts?.pages && result.pageCount && parsePageRange(opts.pages, result.pageCount).size === 0) {
|
|
41511
|
+
out = { ...result, warnings: [...result.warnings ?? [], { code: "PARTIAL_PARSE", message: `\uC694\uCCAD\uD55C \uCABD \uBC94\uC704(${opts.pages})\uAC00 \uBB38\uC11C \uCABD(1~${result.pageCount})\uACFC \uACB9\uCE58\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4` }] };
|
|
41512
|
+
}
|
|
41513
|
+
if (out.success && !out.pages) {
|
|
41514
|
+
const pages = blocksToPages(out.blocks);
|
|
41515
|
+
if (pages) out = { ...out, pages };
|
|
41464
41516
|
}
|
|
41465
41517
|
if (out.success && opts?.plain) {
|
|
41466
41518
|
out = { ...out, markdown: toPlainMarkdown(out.markdown), ...out.pages ? { pages: out.pages.map((p) => ({ ...p, markdown: toPlainMarkdown(p.markdown) })) } : {} };
|
|
@@ -41512,7 +41564,7 @@ function scriptsOff(r, off) {
|
|
|
41512
41564
|
}
|
|
41513
41565
|
async function parseImage(buffer, options) {
|
|
41514
41566
|
try {
|
|
41515
|
-
const { parseImageDocument } = await import("./image-ocr-
|
|
41567
|
+
const { parseImageDocument } = await import("./image-ocr-POCME5I4.js");
|
|
41516
41568
|
const { blocks, warnings } = await parseImageDocument(buffer, options);
|
|
41517
41569
|
stripScriptTags({ blocks });
|
|
41518
41570
|
return {
|
|
@@ -41572,7 +41624,7 @@ async function parseHwp(buffer, options) {
|
|
|
41572
41624
|
async function parsePdf(buffer, options) {
|
|
41573
41625
|
let parsePdfDocument;
|
|
41574
41626
|
try {
|
|
41575
|
-
const mod = await import("./parser-
|
|
41627
|
+
const mod = await import("./parser-SCXRLOW7.js");
|
|
41576
41628
|
parsePdfDocument = mod.parsePdfDocument;
|
|
41577
41629
|
} catch {
|
|
41578
41630
|
return {
|
|
@@ -41617,7 +41669,7 @@ async function parseDocx(buffer, options) {
|
|
|
41617
41669
|
async function parsePptx(buffer, options) {
|
|
41618
41670
|
try {
|
|
41619
41671
|
const { markdown, blocks, metadata, outline, warnings, images } = await parsePptxDocument(buffer, options);
|
|
41620
|
-
return { success: true, fileType: "pptx", markdown, blocks, metadata, outline, warnings, images: images?.length ? images : void 0, pageCount: metadata?.pageCount };
|
|
41672
|
+
return scriptsOff({ success: true, fileType: "pptx", markdown, blocks, metadata, outline, warnings, images: images?.length ? images : void 0, pageCount: metadata?.pageCount }, options?.scriptTags === false);
|
|
41621
41673
|
} catch (err) {
|
|
41622
41674
|
return { success: false, fileType: "pptx", error: sanitizeError(err), code: classifyError(err) };
|
|
41623
41675
|
}
|