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
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ConversionResult, GeneratorConfig, OfficeContentNode, OfficeParserAST } from '../types.js';
|
|
2
|
+
import { BaseGenerator } from './BaseGenerator.js';
|
|
3
|
+
/**
|
|
4
|
+
* Generates high-fidelity RTF (Rich Text Format) from an AST.
|
|
5
|
+
*/
|
|
6
|
+
export declare class RtfGenerator extends BaseGenerator<'rtf'> {
|
|
7
|
+
private colorTable;
|
|
8
|
+
private inTable;
|
|
9
|
+
constructor(ast: OfficeParserAST, config?: GeneratorConfig<'rtf'>);
|
|
10
|
+
generate(): Promise<ConversionResult>;
|
|
11
|
+
protected processNodeRecursive(node: OfficeContentNode, processor: (node: OfficeContentNode, childrenOutput: string) => Promise<string>): Promise<string>;
|
|
12
|
+
private renderBody;
|
|
13
|
+
private getColorIndex;
|
|
14
|
+
private escapeRtf;
|
|
15
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RtfGenerator = void 0;
|
|
4
|
+
const BaseGenerator_js_1 = require("./BaseGenerator.js");
|
|
5
|
+
/**
|
|
6
|
+
* Generates high-fidelity RTF (Rich Text Format) from an AST.
|
|
7
|
+
*/
|
|
8
|
+
class RtfGenerator extends BaseGenerator_js_1.BaseGenerator {
|
|
9
|
+
colorTable = [];
|
|
10
|
+
inTable = false;
|
|
11
|
+
constructor(ast, config) {
|
|
12
|
+
super('rtf', ast, config);
|
|
13
|
+
}
|
|
14
|
+
async generate() {
|
|
15
|
+
this.colorTable = [];
|
|
16
|
+
// We first process all nodes to collect colors
|
|
17
|
+
const bodyContent = await this.renderBody(this.ast);
|
|
18
|
+
let output = '{\\rtf1\\ansi\\deff0\n';
|
|
19
|
+
// 1. Info Group (Metadata)
|
|
20
|
+
if (this.config.renderMetadata && this.ast.metadata) {
|
|
21
|
+
output += '{\\info';
|
|
22
|
+
if (this.ast.metadata.title)
|
|
23
|
+
output += `{\\title ${this.escapeRtf(this.ast.metadata.title)}}`;
|
|
24
|
+
if (this.ast.metadata.author)
|
|
25
|
+
output += `{\\author ${this.escapeRtf(this.ast.metadata.author)}}`;
|
|
26
|
+
if (this.ast.metadata.description)
|
|
27
|
+
output += `{\\comm ${this.escapeRtf(this.ast.metadata.description)}}`;
|
|
28
|
+
output += '}\n';
|
|
29
|
+
}
|
|
30
|
+
// 2. Font Table
|
|
31
|
+
output += '{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}{\\f1\\fnil\\fcharset0 Times New Roman;}}\n';
|
|
32
|
+
// 3. Color Table
|
|
33
|
+
if (this.colorTable.length > 0) {
|
|
34
|
+
output += '{\\colortbl;';
|
|
35
|
+
for (const hex of this.colorTable) {
|
|
36
|
+
const r = parseInt(hex.substring(1, 3), 16);
|
|
37
|
+
const g = parseInt(hex.substring(3, 5), 16);
|
|
38
|
+
const b = parseInt(hex.substring(5, 7), 16);
|
|
39
|
+
output += `\\red${r}\\green${g}\\blue${b};`;
|
|
40
|
+
}
|
|
41
|
+
output += '}\n';
|
|
42
|
+
}
|
|
43
|
+
// 4. Body
|
|
44
|
+
output += '\\f0\\fs24\n';
|
|
45
|
+
output += bodyContent;
|
|
46
|
+
output += '}';
|
|
47
|
+
return {
|
|
48
|
+
value: output,
|
|
49
|
+
messages: this.messages
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
async processNodeRecursive(node, processor) {
|
|
53
|
+
const wasInTable = this.inTable;
|
|
54
|
+
if (node.type === 'table')
|
|
55
|
+
this.inTable = true;
|
|
56
|
+
const result = await super.processNodeRecursive(node, processor);
|
|
57
|
+
this.inTable = wasInTable;
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
async renderBody(ast) {
|
|
61
|
+
let body = '';
|
|
62
|
+
this.inTable = false;
|
|
63
|
+
const processor = async (node, childrenOutput) => {
|
|
64
|
+
// Handle Semantic Style Mapping for RTF using the semantic mapping helper
|
|
65
|
+
const mapping = this.getSemanticMapping(node);
|
|
66
|
+
if (mapping) {
|
|
67
|
+
if (mapping.tag === 'blockquote') {
|
|
68
|
+
const pPr = this.inTable ? '\\pard\\intbl' : '\\pard';
|
|
69
|
+
return `${pPr}\\li720\\ri720\\sa120 ${childrenOutput}\\par\n`;
|
|
70
|
+
}
|
|
71
|
+
const hMatch = mapping.tag.match(/^h([1-6])$/);
|
|
72
|
+
if (hMatch) {
|
|
73
|
+
const level = parseInt(hMatch[1]);
|
|
74
|
+
const fontSize = 24 + (6 - level) * 4;
|
|
75
|
+
const pPr = this.inTable ? '\\pard\\intbl' : '\\pard';
|
|
76
|
+
return `${pPr}\\s${level}\\sb240\\sa120{\\b\\fs${fontSize} ${childrenOutput}}\\par\n`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
switch (node.type) {
|
|
80
|
+
case 'text': {
|
|
81
|
+
let text = this.escapeRtf(node.text || '');
|
|
82
|
+
const f = node.formatting;
|
|
83
|
+
const meta = node.metadata;
|
|
84
|
+
if (this.config.includeFormatting && f) {
|
|
85
|
+
let prefix = '';
|
|
86
|
+
let suffix = '';
|
|
87
|
+
if (f.bold) {
|
|
88
|
+
prefix += '\\b ';
|
|
89
|
+
suffix = '\\b0 ' + suffix;
|
|
90
|
+
}
|
|
91
|
+
if (f.italic) {
|
|
92
|
+
prefix += '\\i ';
|
|
93
|
+
suffix = '\\i0 ' + suffix;
|
|
94
|
+
}
|
|
95
|
+
if (f.underline) {
|
|
96
|
+
prefix += '\\ul ';
|
|
97
|
+
suffix = '\\ul0 ' + suffix;
|
|
98
|
+
}
|
|
99
|
+
if (f.strikethrough) {
|
|
100
|
+
prefix += '\\strike ';
|
|
101
|
+
suffix = '\\strike0 ' + suffix;
|
|
102
|
+
}
|
|
103
|
+
if (f.color) {
|
|
104
|
+
const idx = this.getColorIndex(f.color);
|
|
105
|
+
prefix += `\\cf${idx + 1} `;
|
|
106
|
+
}
|
|
107
|
+
if (f.backgroundColor) {
|
|
108
|
+
const idx = this.getColorIndex(f.backgroundColor);
|
|
109
|
+
prefix += `\\highlight${idx + 1} `;
|
|
110
|
+
}
|
|
111
|
+
if (f.size) {
|
|
112
|
+
const pt = parseInt(f.size);
|
|
113
|
+
prefix += `\\fs${pt * 2} `;
|
|
114
|
+
}
|
|
115
|
+
text = `{\\rtlch\\f1 ${prefix}${text}${suffix}}`;
|
|
116
|
+
}
|
|
117
|
+
if (meta?.link) {
|
|
118
|
+
const isInternal = meta.linkType !== 'external';
|
|
119
|
+
if (!this.config.ignoreInternalLinks || !isInternal) {
|
|
120
|
+
return `{\\field{\\*\\fldinst{HYPERLINK "${meta.link}"}}{\\fldrslt ${text}}}`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return text;
|
|
124
|
+
}
|
|
125
|
+
case 'heading': {
|
|
126
|
+
const meta = node.metadata;
|
|
127
|
+
const level = meta?.level || 1;
|
|
128
|
+
const fontSize = 24 + (6 - level) * 4;
|
|
129
|
+
const pPr = this.inTable ? '\\pard\\intbl' : '\\pard';
|
|
130
|
+
return `${pPr}\\s${level}\\sb240\\sa120{\\b\\fs${fontSize} ${childrenOutput}}\\par\n`;
|
|
131
|
+
}
|
|
132
|
+
case 'paragraph': {
|
|
133
|
+
let pPr = this.inTable ? '\\pard\\intbl' : '\\pard';
|
|
134
|
+
pPr += '\\sa120';
|
|
135
|
+
if (this.config.includeFormatting && node.metadata) {
|
|
136
|
+
const meta = node.metadata;
|
|
137
|
+
if (meta.alignment) {
|
|
138
|
+
if (meta.alignment === 'center')
|
|
139
|
+
pPr += '\\qc';
|
|
140
|
+
else if (meta.alignment === 'right')
|
|
141
|
+
pPr += '\\qr';
|
|
142
|
+
else if (meta.alignment === 'justify')
|
|
143
|
+
pPr += '\\qj';
|
|
144
|
+
}
|
|
145
|
+
if (meta.paragraphIndentation) {
|
|
146
|
+
const ind = meta.paragraphIndentation;
|
|
147
|
+
if (ind.left)
|
|
148
|
+
pPr += `\\li${ind.left}`;
|
|
149
|
+
if (ind.right)
|
|
150
|
+
pPr += `\\ri${ind.right}`;
|
|
151
|
+
if (ind.firstLine)
|
|
152
|
+
pPr += `\\fi${ind.firstLine}`;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return `${pPr} ${childrenOutput}\\par\n`;
|
|
156
|
+
}
|
|
157
|
+
case 'list': {
|
|
158
|
+
const meta = node.metadata;
|
|
159
|
+
const indent = ((meta?.indentation || 0) + 1) * 360;
|
|
160
|
+
const isOrdered = meta?.listType === 'ordered';
|
|
161
|
+
const marker = isOrdered ? `${(meta.itemIndex ?? 0) + 1}. ` : '\\bullet ';
|
|
162
|
+
const listControl = isOrdered ? '\\pndec' : '\\pnbullet';
|
|
163
|
+
const level = meta?.indentation || 0;
|
|
164
|
+
const pPr = this.inTable ? '\\pard\\intbl' : '\\pard';
|
|
165
|
+
return `${pPr}\\li${indent}\\fi-360\\ilvl${level}${listControl} ${marker}${childrenOutput}\\par\n`;
|
|
166
|
+
}
|
|
167
|
+
case 'table': {
|
|
168
|
+
return `\\pard\\sa0\n${childrenOutput}`;
|
|
169
|
+
}
|
|
170
|
+
case 'row': {
|
|
171
|
+
return `\\trowd\\trgaph108\\trleft-108\n${childrenOutput}\\row\n`;
|
|
172
|
+
}
|
|
173
|
+
case 'cell': {
|
|
174
|
+
const pPr = this.inTable ? '\\pard\\intbl' : '\\pard';
|
|
175
|
+
return `${pPr}\\intbl\\sb60\\sa60 ${childrenOutput}\\cell\n`;
|
|
176
|
+
}
|
|
177
|
+
case 'break': {
|
|
178
|
+
return node.metadata?.breakType === 'page' ? '\\page\n' : '\\line\n';
|
|
179
|
+
}
|
|
180
|
+
default:
|
|
181
|
+
return childrenOutput;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
for (const node of ast.content) {
|
|
185
|
+
body += await this.processNodeRecursive(node, processor);
|
|
186
|
+
}
|
|
187
|
+
return body;
|
|
188
|
+
}
|
|
189
|
+
getColorIndex(hex) {
|
|
190
|
+
const h = hex.toUpperCase();
|
|
191
|
+
let idx = this.colorTable.indexOf(h);
|
|
192
|
+
if (idx === -1) {
|
|
193
|
+
idx = this.colorTable.length;
|
|
194
|
+
this.colorTable.push(h);
|
|
195
|
+
}
|
|
196
|
+
return idx;
|
|
197
|
+
}
|
|
198
|
+
escapeRtf(text) {
|
|
199
|
+
return text
|
|
200
|
+
.replace(/\\/g, '\\\\')
|
|
201
|
+
.replace(/{/g, '\\{')
|
|
202
|
+
.replace(/}/g, '\\}')
|
|
203
|
+
.replace(/[^\x00-\x7F]/g, (match) => {
|
|
204
|
+
return `\\u${match.charCodeAt(0)}?`;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
exports.RtfGenerator = RtfGenerator;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ConversionResult, GeneratorConfig, OfficeParserAST } from '../types.js';
|
|
2
|
+
import { BaseGenerator } from './BaseGenerator.js';
|
|
3
|
+
/**
|
|
4
|
+
* Generates plain text from an AST.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TextGenerator extends BaseGenerator<'text'> {
|
|
7
|
+
constructor(ast: OfficeParserAST, config?: GeneratorConfig<'text'>);
|
|
8
|
+
/**
|
|
9
|
+
* Generates plain text by concatenating text content from nodes.
|
|
10
|
+
*/
|
|
11
|
+
generate(): Promise<ConversionResult>;
|
|
12
|
+
private renderTable;
|
|
13
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextGenerator = void 0;
|
|
4
|
+
const BaseGenerator_js_1 = require("./BaseGenerator.js");
|
|
5
|
+
/**
|
|
6
|
+
* Generates plain text from an AST.
|
|
7
|
+
*/
|
|
8
|
+
class TextGenerator extends BaseGenerator_js_1.BaseGenerator {
|
|
9
|
+
constructor(ast, config) {
|
|
10
|
+
super('text', ast, config);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Generates plain text by concatenating text content from nodes.
|
|
14
|
+
*/
|
|
15
|
+
async generate() {
|
|
16
|
+
let output = '';
|
|
17
|
+
const newline = this.config.textConfig.newlineDelimiter;
|
|
18
|
+
// Add Metadata Header
|
|
19
|
+
if (this.config.renderMetadata && this.ast.metadata) {
|
|
20
|
+
if (this.ast.metadata.title)
|
|
21
|
+
output += `Title: ${this.ast.metadata.title}${newline}`;
|
|
22
|
+
if (this.ast.metadata.author)
|
|
23
|
+
output += `Author: ${this.ast.metadata.author}${newline}`;
|
|
24
|
+
if (this.ast.metadata.created)
|
|
25
|
+
output += `Created: ${new Date(this.ast.metadata.created).toLocaleString()}${newline}`;
|
|
26
|
+
output += `-------------------${newline}${newline}`;
|
|
27
|
+
}
|
|
28
|
+
const processor = async (node, childrenOutput) => {
|
|
29
|
+
// Return raw text for text nodes
|
|
30
|
+
if (node.type === 'text' || node.type === 'code') {
|
|
31
|
+
return node.text || '';
|
|
32
|
+
}
|
|
33
|
+
// Handle explicit breaks
|
|
34
|
+
if (node.type === 'break') {
|
|
35
|
+
return newline;
|
|
36
|
+
}
|
|
37
|
+
if (node.type === 'image') {
|
|
38
|
+
if (!this.config.includeImages)
|
|
39
|
+
return '';
|
|
40
|
+
const meta = node.metadata;
|
|
41
|
+
return `[Image: ${meta?.altText || meta?.attachmentName || 'Untitled'}]${newline}`;
|
|
42
|
+
}
|
|
43
|
+
if (node.type === 'table' && this.config.textConfig.preserveLayout) {
|
|
44
|
+
return await this.renderTable(node, processor, newline);
|
|
45
|
+
}
|
|
46
|
+
if (node.type === 'list' && this.config.textConfig.preserveLayout) {
|
|
47
|
+
const meta = node.metadata;
|
|
48
|
+
const indentSpaces = ' '.repeat(4);
|
|
49
|
+
const indent = indentSpaces.repeat(meta?.indentation || 0);
|
|
50
|
+
const marker = meta?.listType === 'ordered' ? `${(meta.itemIndex ?? 0) + 1}. ` : '- ';
|
|
51
|
+
return `${indent}${marker}${childrenOutput.trimStart()}` + (childrenOutput.endsWith(newline) ? '' : newline);
|
|
52
|
+
}
|
|
53
|
+
// Append newline for block-level elements to maintain structure
|
|
54
|
+
const blockTypes = ['paragraph', 'heading', 'row', 'sheet', 'slide', 'note', 'list', 'table', 'code'];
|
|
55
|
+
if (blockTypes.includes(node.type)) {
|
|
56
|
+
if (childrenOutput.trim() === '')
|
|
57
|
+
return '';
|
|
58
|
+
return childrenOutput + (childrenOutput.endsWith(newline) ? '' : newline);
|
|
59
|
+
}
|
|
60
|
+
return childrenOutput;
|
|
61
|
+
};
|
|
62
|
+
for (const node of this.ast.content) {
|
|
63
|
+
output += await this.processNodeRecursive(node, processor);
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
value: output.trim(),
|
|
67
|
+
messages: this.messages
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
async renderTable(node, processor, newline) {
|
|
71
|
+
if (!node.children || node.children.length === 0)
|
|
72
|
+
return '';
|
|
73
|
+
const rows = [];
|
|
74
|
+
const colWidths = [];
|
|
75
|
+
for (const rowNode of node.children) {
|
|
76
|
+
// Manual check for onNode in table rows since we are bypassing processNodeRecursive for rows here
|
|
77
|
+
const override = await this.handleOnNode(rowNode);
|
|
78
|
+
if (override === false)
|
|
79
|
+
continue;
|
|
80
|
+
if (typeof override === 'string') {
|
|
81
|
+
rows.push([override]);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const row = [];
|
|
85
|
+
if (rowNode.children) {
|
|
86
|
+
for (let i = 0; i < rowNode.children.length; i++) {
|
|
87
|
+
const cellNode = rowNode.children[i];
|
|
88
|
+
const cellText = (await this.processNodeRecursive(cellNode, processor))
|
|
89
|
+
.trim()
|
|
90
|
+
.replace(/\r?\n/g, ' ');
|
|
91
|
+
row.push(cellText);
|
|
92
|
+
colWidths[i] = Math.max(colWidths[i] || 0, cellText.length);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
rows.push(row);
|
|
96
|
+
}
|
|
97
|
+
let tableOutput = newline;
|
|
98
|
+
for (const row of rows) {
|
|
99
|
+
tableOutput += '| ';
|
|
100
|
+
for (let i = 0; i < row.length; i++) {
|
|
101
|
+
tableOutput += (row[i] || '').padEnd(colWidths[i] || 0) + ' | ';
|
|
102
|
+
}
|
|
103
|
+
tableOutput += newline;
|
|
104
|
+
}
|
|
105
|
+
return tableOutput + newline;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.TextGenerator = TextGenerator;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
* **Supported Formats:**
|
|
8
8
|
* - Microsoft Office: DOCX, XLSX, PPTX (Office Open XML)
|
|
9
9
|
* - OpenDocument: ODT, ODP, ODS (ODF)
|
|
10
|
-
* - Legacy: RTF (Rich Text Format)
|
|
11
10
|
* - Portable: PDF
|
|
11
|
+
* - Legacy: RTF (Rich Text Format)
|
|
12
|
+
* - Web/Plain: CSV, MD, HTML
|
|
12
13
|
*
|
|
13
14
|
* **Key Features:**
|
|
14
15
|
* - Unified AST output across all formats
|
|
@@ -35,17 +36,24 @@
|
|
|
35
36
|
*
|
|
36
37
|
* **Main Exports:**
|
|
37
38
|
* - `OfficeParser` - Main parser class
|
|
39
|
+
* - `OfficeGenerator` - Main generator class for document conversion
|
|
38
40
|
* - `OfficeParserConfig` - Configuration interface
|
|
41
|
+
* - `GeneratorConfig` - Generator configuration interface
|
|
39
42
|
* - `OfficeParserAST` - AST result interface
|
|
40
43
|
* - `OfficeContentNode` - Content tree node interface
|
|
41
44
|
* - All type definitions
|
|
45
|
+
|
|
42
46
|
*
|
|
43
47
|
* @packageDocumentation
|
|
44
48
|
* @module officeparser
|
|
45
49
|
*/
|
|
46
50
|
import { OfficeParser } from './OfficeParser.js';
|
|
47
|
-
import {
|
|
51
|
+
import { OfficeGenerator } from './OfficeGenerator.js';
|
|
52
|
+
import { OfficeConverter } from './OfficeConverter.js';
|
|
53
|
+
import { OfficeParserConfig, OfficeParserAST, OfficeContentNode, OfficeAttachment, OfficeMetadata, TextFormatting, SupportedFileType, OfficeContentNodeType, OfficeMimeType, SlideMetadata, SheetMetadata, HeadingMetadata, ListMetadata, CellMetadata, ImageMetadata, PageMetadata, ContentMetadata, BreakMetadata, GeneratorConfig, SupportedDestination, UniversalGeneratorFormat, ChunkingConfig, ChunkingStrategy, FixedSizeChunkingConfig, DocumentStructureChunkingConfig, SemanticChunkingConfig, OfficeChunk, OfficeConverterConfig, OfficeErrorType, OfficeWarningType, ConversionResult } from './types.js';
|
|
48
54
|
declare const parseOffice: typeof OfficeParser.parseOffice;
|
|
49
55
|
declare const terminateOcr: typeof OfficeParser.terminateOcr;
|
|
50
|
-
|
|
56
|
+
declare const convert: typeof OfficeConverter.convert;
|
|
57
|
+
declare const generate: typeof OfficeGenerator.generate;
|
|
58
|
+
export { OfficeParser, parseOffice, terminateOcr, OfficeParserConfig, OfficeParserAST, OfficeContentNode, OfficeAttachment, OfficeMetadata, TextFormatting, SupportedFileType, OfficeContentNodeType, OfficeMimeType, SlideMetadata, SheetMetadata, HeadingMetadata, ListMetadata, CellMetadata, ImageMetadata, PageMetadata, ContentMetadata, BreakMetadata, OfficeGenerator, GeneratorConfig, SupportedDestination, UniversalGeneratorFormat, ChunkingConfig, ChunkingStrategy, FixedSizeChunkingConfig, DocumentStructureChunkingConfig, SemanticChunkingConfig, OfficeChunk, OfficeConverter, OfficeConverterConfig, convert, generate, OfficeErrorType, OfficeWarningType, ConversionResult, };
|
|
51
59
|
export default OfficeParser;
|
package/dist/index.js
CHANGED
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
* **Supported Formats:**
|
|
9
9
|
* - Microsoft Office: DOCX, XLSX, PPTX (Office Open XML)
|
|
10
10
|
* - OpenDocument: ODT, ODP, ODS (ODF)
|
|
11
|
-
* - Legacy: RTF (Rich Text Format)
|
|
12
11
|
* - Portable: PDF
|
|
12
|
+
* - Legacy: RTF (Rich Text Format)
|
|
13
|
+
* - Web/Plain: CSV, MD, HTML
|
|
13
14
|
*
|
|
14
15
|
* **Key Features:**
|
|
15
16
|
* - Unified AST output across all formats
|
|
@@ -36,21 +37,35 @@
|
|
|
36
37
|
*
|
|
37
38
|
* **Main Exports:**
|
|
38
39
|
* - `OfficeParser` - Main parser class
|
|
40
|
+
* - `OfficeGenerator` - Main generator class for document conversion
|
|
39
41
|
* - `OfficeParserConfig` - Configuration interface
|
|
42
|
+
* - `GeneratorConfig` - Generator configuration interface
|
|
40
43
|
* - `OfficeParserAST` - AST result interface
|
|
41
44
|
* - `OfficeContentNode` - Content tree node interface
|
|
42
45
|
* - All type definitions
|
|
46
|
+
|
|
43
47
|
*
|
|
44
48
|
* @packageDocumentation
|
|
45
49
|
* @module officeparser
|
|
46
50
|
*/
|
|
47
51
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.terminateOcr = exports.parseOffice = exports.OfficeParser = void 0;
|
|
52
|
+
exports.OfficeWarningType = exports.OfficeErrorType = exports.generate = exports.convert = exports.OfficeConverter = exports.OfficeGenerator = exports.terminateOcr = exports.parseOffice = exports.OfficeParser = void 0;
|
|
49
53
|
const OfficeParser_js_1 = require("./OfficeParser.js");
|
|
50
54
|
Object.defineProperty(exports, "OfficeParser", { enumerable: true, get: function () { return OfficeParser_js_1.OfficeParser; } });
|
|
55
|
+
const OfficeGenerator_js_1 = require("./OfficeGenerator.js");
|
|
56
|
+
Object.defineProperty(exports, "OfficeGenerator", { enumerable: true, get: function () { return OfficeGenerator_js_1.OfficeGenerator; } });
|
|
57
|
+
const OfficeConverter_js_1 = require("./OfficeConverter.js");
|
|
58
|
+
Object.defineProperty(exports, "OfficeConverter", { enumerable: true, get: function () { return OfficeConverter_js_1.OfficeConverter; } });
|
|
59
|
+
const types_js_1 = require("./types.js");
|
|
60
|
+
Object.defineProperty(exports, "OfficeErrorType", { enumerable: true, get: function () { return types_js_1.OfficeErrorType; } });
|
|
61
|
+
Object.defineProperty(exports, "OfficeWarningType", { enumerable: true, get: function () { return types_js_1.OfficeWarningType; } });
|
|
51
62
|
const parseOffice = OfficeParser_js_1.OfficeParser.parseOffice;
|
|
52
63
|
exports.parseOffice = parseOffice;
|
|
53
64
|
const terminateOcr = OfficeParser_js_1.OfficeParser.terminateOcr;
|
|
54
65
|
exports.terminateOcr = terminateOcr;
|
|
66
|
+
const convert = OfficeConverter_js_1.OfficeConverter.convert;
|
|
67
|
+
exports.convert = convert;
|
|
68
|
+
const generate = OfficeGenerator_js_1.OfficeGenerator.generate;
|
|
69
|
+
exports.generate = generate;
|
|
55
70
|
// Default export for backward compatibility
|
|
56
71
|
exports.default = OfficeParser_js_1.OfficeParser;
|
package/dist/index.mjs
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
import _module from './index.js';
|
|
12
12
|
|
|
13
13
|
// Named exports
|
|
14
|
-
const { OfficeParser, parseOffice, terminateOcr } = _module;
|
|
15
|
-
export { OfficeParser, parseOffice, terminateOcr };
|
|
14
|
+
const { OfficeParser, parseOffice, terminateOcr, OfficeGenerator, OfficeConverter, convert, generate, OfficeErrorType, OfficeWarningType } = _module;
|
|
15
|
+
export { OfficeParser, parseOffice, terminateOcr, OfficeGenerator, OfficeConverter, convert, generate, OfficeErrorType, OfficeWarningType };
|
|
16
16
|
|
|
17
17
|
// Default export
|
|
18
18
|
export default _module.default ?? _module;
|