@veryfront/ext-document-kreuzberg 0.1.1278 → 0.1.1279-rc.24504
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-extraction.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-document-kreuzberg/src/native-extraction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EACV,+BAA+B,EAC/B,kBAAkB,EACnB,MAAM,yCAAyC,CAAC;AAIjD,0DAA0D;AAC1D,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE7D,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,YAAY,EAAE,CAAC,KAAK,EAAE,+BAA+B,KAAK,IAAI,CAAC;IAC/D,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAChD;
|
|
1
|
+
{"version":3,"file":"native-extraction.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-document-kreuzberg/src/native-extraction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EACV,+BAA+B,EAC/B,kBAAkB,EACnB,MAAM,yCAAyC,CAAC;AAIjD,0DAA0D;AAC1D,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG,UAAU,CAAC;AAE7D,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,YAAY,EAAE,CAAC,KAAK,EAAE,+BAA+B,KAAK,IAAI,CAAC;IAC/D,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAChD;AAkXD;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,MAAM,CAAC,CAYjB"}
|
|
@@ -11,11 +11,26 @@ function isPdfMimeType(mimeType) {
|
|
|
11
11
|
function isPptxMimeType(mimeType) {
|
|
12
12
|
return normalizeMimeType(mimeType) === "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
13
13
|
}
|
|
14
|
+
const capturedTextReplace = String.prototype.replace;
|
|
15
|
+
const applyTextReplace = Reflect.apply;
|
|
16
|
+
function decodeNamedEntities(value) {
|
|
17
|
+
let decoded = value;
|
|
18
|
+
decoded = applyTextReplace(capturedTextReplace, decoded, [/"/g, '"']);
|
|
19
|
+
decoded = applyTextReplace(capturedTextReplace, decoded, [/'/g, "'"]);
|
|
20
|
+
decoded = applyTextReplace(capturedTextReplace, decoded, [/>/g, ">"]);
|
|
21
|
+
decoded = applyTextReplace(capturedTextReplace, decoded, [/</g, "<"]);
|
|
22
|
+
decoded = applyTextReplace(capturedTextReplace, decoded, [/&/g, "&"]);
|
|
23
|
+
return decoded;
|
|
24
|
+
}
|
|
14
25
|
function decodeXmlText(value) {
|
|
15
|
-
|
|
26
|
+
const decoded = value.replace(
|
|
16
27
|
/&#x([0-9a-f]+);/gi,
|
|
17
28
|
(_, hex) => String.fromCodePoint(Number.parseInt(hex, 16))
|
|
18
|
-
).replace(
|
|
29
|
+
).replace(
|
|
30
|
+
/&#(\d+);/g,
|
|
31
|
+
(_, decimal) => String.fromCodePoint(Number.parseInt(decimal, 10))
|
|
32
|
+
);
|
|
33
|
+
return decodeNamedEntities(decoded);
|
|
19
34
|
}
|
|
20
35
|
function extractPptxSlideText(xml) {
|
|
21
36
|
return Array.from(xml.matchAll(/<a:t(?:\s[^>]*)?>([\s\S]*?)<\/a:t>/g)).map((match) => decodeXmlText(match[1] ?? "").trim()).filter(Boolean).join(" ").trim();
|
|
@@ -24,7 +39,7 @@ function normalizePptxText(value) {
|
|
|
24
39
|
return value.replace(/\s+/g, " ").trim();
|
|
25
40
|
}
|
|
26
41
|
function cleanExtractedMarkdown(value) {
|
|
27
|
-
return value.replace(/!\[[^\]\n]*\]\(\s*\)/g, "").replace(/[ \t]+\n/g, "\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
42
|
+
return value.replace(/!\[[^\]\n]*\]\(\s*\)/g, "").replace(/(?<![ \t])[ \t]+\n/g, "\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
28
43
|
}
|
|
29
44
|
function slideNumber(path) {
|
|
30
45
|
return Number(path.match(/\/slide(\d+)\.xml$/)?.[1] ?? 0);
|
|
@@ -76,7 +91,7 @@ function normalizePptxMarkdownHeadings(markdown, xml) {
|
|
|
76
91
|
if (roles.size === 0) return markdown;
|
|
77
92
|
return cleanExtractedMarkdown(
|
|
78
93
|
markdown.split("\n").map((line) => {
|
|
79
|
-
const heading = line.match(/^#{1,6}\s+(
|
|
94
|
+
const heading = line.trimEnd().match(/^#{1,6}\s+(\S.*)$/);
|
|
80
95
|
if (!heading) return line;
|
|
81
96
|
const text = heading[1] ?? "";
|
|
82
97
|
const queue = roles.get(normalizePptxText(text));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veryfront/ext-document-kreuzberg",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1279-rc.24504",
|
|
4
4
|
"description": "Veryfront first-party extension package for ext-document-kreuzberg",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"veryfront",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"pdf-lib": "1.17.1"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"veryfront": "^0.1.
|
|
72
|
+
"veryfront": "^0.1.1279-rc.24504"
|
|
73
73
|
},
|
|
74
74
|
"type": "module",
|
|
75
75
|
"types": "./esm/extensions/ext-document-kreuzberg/src/index.d.ts",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"NOTICE",
|
|
80
80
|
"README.md"
|
|
81
81
|
],
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "1b06e0208046774cd83290c8a3ab9306c2f73b7b"
|
|
83
83
|
}
|