officeparser 6.1.1 → 7.0.0
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/README.md +219 -26
- package/dist/OfficeConverter.d.ts +46 -0
- package/dist/OfficeConverter.js +72 -0
- package/dist/OfficeGenerator.d.ts +19 -0
- package/dist/OfficeGenerator.js +48 -0
- package/dist/OfficeParser.d.ts +6 -0
- package/dist/OfficeParser.js +55 -29
- package/dist/cli.d.ts +3 -1
- package/dist/cli.js +106 -22
- package/dist/defaults.d.ts +41 -0
- package/dist/defaults.js +172 -0
- package/dist/generators/BaseGenerator.d.ts +58 -0
- package/dist/generators/BaseGenerator.js +107 -0
- package/dist/generators/ChunkingGenerator.d.ts +81 -0
- package/dist/generators/ChunkingGenerator.js +683 -0
- package/dist/generators/CsvGenerator.d.ts +30 -0
- package/dist/generators/CsvGenerator.js +233 -0
- package/dist/generators/HtmlGenerator.d.ts +37 -0
- package/dist/generators/HtmlGenerator.js +1013 -0
- package/dist/generators/MarkdownGenerator.d.ts +59 -0
- package/dist/generators/MarkdownGenerator.js +481 -0
- package/dist/generators/PdfGenerator.d.ts +22 -0
- package/dist/generators/PdfGenerator.js +118 -0
- package/dist/generators/RtfGenerator.d.ts +15 -0
- package/dist/generators/RtfGenerator.js +208 -0
- package/dist/generators/TextGenerator.d.ts +13 -0
- package/dist/generators/TextGenerator.js +108 -0
- package/dist/index.d.ts +11 -3
- package/dist/index.js +17 -2
- package/dist/index.mjs +2 -2
- package/dist/officeparser.browser.d.ts +826 -5
- package/dist/officeparser.browser.iife.js +703 -52
- package/dist/officeparser.browser.mjs +703 -52
- package/dist/parsers/CsvParser.d.ts +9 -0
- package/dist/parsers/CsvParser.js +110 -0
- package/dist/parsers/ExcelParser.d.ts +2 -2
- package/dist/parsers/ExcelParser.js +145 -114
- package/dist/parsers/HtmlParser.d.ts +2 -0
- package/dist/parsers/HtmlParser.js +539 -0
- package/dist/parsers/MarkdownParser.d.ts +2 -0
- package/dist/parsers/MarkdownParser.js +360 -0
- package/dist/parsers/OpenOfficeParser.d.ts +2 -2
- package/dist/parsers/OpenOfficeParser.js +140 -79
- package/dist/parsers/PdfParser.d.ts +2 -2
- package/dist/parsers/PdfParser.js +52 -49
- package/dist/parsers/PowerPointParser.d.ts +2 -2
- package/dist/parsers/PowerPointParser.js +20 -23
- package/dist/parsers/RtfParser.d.ts +2 -2
- package/dist/parsers/RtfParser.js +1291 -1240
- package/dist/parsers/WordParser.d.ts +2 -2
- package/dist/parsers/WordParser.js +232 -97
- package/dist/sbom.cdx.json +99 -99
- package/dist/types.d.ts +781 -5
- package/dist/types.js +71 -0
- package/dist/utils/astUtils.d.ts +16 -0
- package/dist/utils/astUtils.js +32 -0
- package/dist/utils/configUtils.d.ts +26 -0
- package/dist/utils/configUtils.js +140 -0
- package/dist/utils/envUtils.js +56 -2
- package/dist/utils/errorUtils.d.ts +17 -29
- package/dist/utils/errorUtils.js +109 -52
- package/dist/utils/moduleLoader.js +15 -9
- package/dist/utils/ocrUtils.js +2 -1
- package/dist/utils/sheetUtils.d.ts +7 -0
- package/dist/utils/sheetUtils.js +35 -0
- package/dist/utils/styleMapper.d.ts +36 -0
- package/dist/utils/styleMapper.js +224 -0
- package/dist/utils/xmlUtils.d.ts +0 -8
- package/dist/utils/xmlUtils.js +2 -1
- package/package.json +27 -8
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
*/
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.parsePowerPoint = void 0;
|
|
27
|
+
const types_js_1 = require("../types.js");
|
|
28
|
+
const astUtils_js_1 = require("../utils/astUtils.js");
|
|
27
29
|
const chartUtils_js_1 = require("../utils/chartUtils.js");
|
|
28
30
|
const errorUtils_js_1 = require("../utils/errorUtils.js");
|
|
29
31
|
const imageUtils_js_1 = require("../utils/imageUtils.js");
|
|
@@ -704,10 +706,10 @@ const parsePowerPoint = async (buffer, config) => {
|
|
|
704
706
|
if (config.ocr) {
|
|
705
707
|
if (attachment.mimeType.startsWith('image/')) {
|
|
706
708
|
try {
|
|
707
|
-
attachment.ocrText = (await (0, ocrUtils_js_1.performOcr)(media.content, {
|
|
709
|
+
attachment.ocrText = (await (0, ocrUtils_js_1.performOcr)(media.content, { ...config.ocrConfig })).trim();
|
|
708
710
|
}
|
|
709
711
|
catch (e) {
|
|
710
|
-
(0, errorUtils_js_1.logWarning)(
|
|
712
|
+
(0, errorUtils_js_1.logWarning)(types_js_1.OfficeWarningType.OCR_FAILED, config, attachment.name, e);
|
|
711
713
|
}
|
|
712
714
|
}
|
|
713
715
|
}
|
|
@@ -729,7 +731,7 @@ const parsePowerPoint = async (buffer, config) => {
|
|
|
729
731
|
attachment.chartData = chartData;
|
|
730
732
|
}
|
|
731
733
|
catch (e) {
|
|
732
|
-
(0, errorUtils_js_1.logWarning)(
|
|
734
|
+
(0, errorUtils_js_1.logWarning)(types_js_1.OfficeWarningType.CHART_DATA_EXTRACTION_FAILED, config, chart.path, e);
|
|
733
735
|
}
|
|
734
736
|
}
|
|
735
737
|
// Loop through nodes to find images and charts and link their text and chartData
|
|
@@ -745,7 +747,7 @@ const parsePowerPoint = async (buffer, config) => {
|
|
|
745
747
|
node.text = attachment.ocrText;
|
|
746
748
|
}
|
|
747
749
|
if (node.type === 'chart') {
|
|
748
|
-
node.text = attachment.chartData?.rawTexts.join(config.newlineDelimiter
|
|
750
|
+
node.text = attachment.chartData?.rawTexts.join(config.newlineDelimiter);
|
|
749
751
|
}
|
|
750
752
|
}
|
|
751
753
|
}
|
|
@@ -764,24 +766,19 @@ const parsePowerPoint = async (buffer, config) => {
|
|
|
764
766
|
return aIsNote - bIsNote;
|
|
765
767
|
});
|
|
766
768
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
return t;
|
|
782
|
-
};
|
|
783
|
-
return getText(c);
|
|
784
|
-
}).filter(t => t != '').join(config.newlineDelimiter ?? '\n')
|
|
785
|
-
};
|
|
769
|
+
const toTextSync = () => content.map(c => {
|
|
770
|
+
// Recursive text extraction
|
|
771
|
+
const getText = (node) => {
|
|
772
|
+
let t = '';
|
|
773
|
+
if (node.children) {
|
|
774
|
+
t += node.children.map(getText).filter(t => t != '').join(!node.children[0]?.children ? '' : config.newlineDelimiter);
|
|
775
|
+
}
|
|
776
|
+
else
|
|
777
|
+
t += node.text || '';
|
|
778
|
+
return t;
|
|
779
|
+
};
|
|
780
|
+
return getText(c);
|
|
781
|
+
}).filter(t => t != '').join(config.newlineDelimiter);
|
|
782
|
+
return (0, astUtils_js_1.createAST)('pptx', metadata, content, attachments, config, toTextSync);
|
|
786
783
|
};
|
|
787
784
|
exports.parsePowerPoint = parsePowerPoint;
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
* @see https://www.biblioscape.com/rtf15_spec.htm RTF 1.5 Specification
|
|
40
40
|
* @see https://latex2rtf.sourceforge.net/RTF-Spec-1.2.pdf RTF 1.2 Specification
|
|
41
41
|
*/
|
|
42
|
-
import {
|
|
42
|
+
import { FullOfficeParserConfig, OfficeParserAST } from '../types.js';
|
|
43
43
|
/**
|
|
44
44
|
* Represents an RTF group (content enclosed in braces).
|
|
45
45
|
* Groups create formatting scopes and can contain other groups, control words, or text.
|
|
@@ -184,4 +184,4 @@ export declare class SimpleRtfParser {
|
|
|
184
184
|
* @param config The parser configuration.
|
|
185
185
|
* @returns The parsed AST.
|
|
186
186
|
*/
|
|
187
|
-
export declare const parseRtf: (buffer: Buffer, config:
|
|
187
|
+
export declare const parseRtf: (buffer: Buffer, config: FullOfficeParserConfig) => Promise<OfficeParserAST>;
|