officeparser 7.5.1 → 7.6.2
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 +19 -6
- package/dist/OfficeConverter.d.ts +2 -2
- package/dist/OfficeParser.d.ts +2 -2
- package/dist/OfficeParser.js +10 -0
- package/dist/cli.js +3 -0
- package/dist/defaults.js +3 -1
- package/dist/generators/ChunkingGenerator.d.ts +2 -1
- package/dist/generators/ChunkingGenerator.js +73 -6
- package/dist/generators/EpubGenerator.js +4 -1
- package/dist/generators/HtmlGenerator.js +117 -29
- package/dist/generators/MarkdownGenerator.js +120 -29
- package/dist/generators/PdfGenerator.js +4 -1
- package/dist/index.d.ts +2 -2
- package/dist/officeparser.browser.d.ts +70 -12
- package/dist/officeparser.browser.iife.js +211 -202
- package/dist/officeparser.browser.mjs +211 -202
- package/dist/officeparser.browser.slim.d.ts +70 -12
- package/dist/officeparser.browser.slim.iife.js +213 -204
- package/dist/officeparser.browser.slim.mjs +213 -204
- package/dist/parsers/HtmlParser.js +206 -38
- package/dist/parsers/MarkdownParser.js +135 -18
- package/dist/parsers/WordParser.js +7 -17
- package/dist/sbom.cdx.json +95 -95
- package/dist/types.d.ts +68 -10
- package/dist/utils/configUtils.js +3 -1
- package/dist/utils/sanitize.d.ts +9 -0
- package/dist/utils/sanitize.js +26 -0
- package/package.json +5 -5
|
@@ -207,7 +207,7 @@ function resolveGeneratorConfig(destination, astConfig, userConfig) {
|
|
|
207
207
|
// 2. Merge common properties and sub-configs
|
|
208
208
|
if (userConfig) {
|
|
209
209
|
// Extract sub-configs to avoid shallow-overwriting the whole sub-config objects
|
|
210
|
-
const { htmlConfig, mdConfig, pdfConfig, csvConfig, textConfig, chunksConfig, ...commonProps } = userConfig;
|
|
210
|
+
const { htmlConfig, mdConfig, pdfConfig, csvConfig, textConfig, rtfConfig, chunksConfig, ...commonProps } = userConfig;
|
|
211
211
|
Object.assign(config, withoutPrototypeKeys(commonProps));
|
|
212
212
|
// Merge sub-configs individually, ignoring undefined properties to preserve defaults
|
|
213
213
|
const mergeSubConfig = (target, source) => {
|
|
@@ -254,6 +254,8 @@ function resolveGeneratorConfig(destination, astConfig, userConfig) {
|
|
|
254
254
|
mergeSubConfig(config.csvConfig, csvConfig);
|
|
255
255
|
if (textConfig)
|
|
256
256
|
mergeSubConfig(config.textConfig, textConfig);
|
|
257
|
+
if (rtfConfig)
|
|
258
|
+
mergeSubConfig(config.rtfConfig, rtfConfig);
|
|
257
259
|
if (chunksConfig)
|
|
258
260
|
mergeSubConfig(config.chunksConfig, chunksConfig);
|
|
259
261
|
}
|
package/dist/utils/sanitize.d.ts
CHANGED
|
@@ -62,6 +62,15 @@ export declare function sanitizeCssValue(value: string): string;
|
|
|
62
62
|
* URLs are passed through.
|
|
63
63
|
*/
|
|
64
64
|
export declare function sanitizeUrl(url: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* Decide whether a non-provider `<iframe>` should be preserved, per
|
|
67
|
+
* `HtmlParserConfig.preserveIframes`. `true` allows any src; an array is a hostname allowlist,
|
|
68
|
+
* where an entry matches the src's host exactly or as a `.`-suffix (so `"vimeo.com"` also matches
|
|
69
|
+
* `player.vimeo.com`). A relative or unparseable src is allowed only under `true`. This is a
|
|
70
|
+
* preservation gate, not a sanitizer - the src is still scheme-checked with `sanitizeUrl` on
|
|
71
|
+
* generation.
|
|
72
|
+
*/
|
|
73
|
+
export declare function iframeAllowed(src: string, preserve: boolean | string[] | undefined): boolean;
|
|
65
74
|
/**
|
|
66
75
|
* Like sanitizeUrl but for an <img>/<source> src: additionally permits
|
|
67
76
|
* `data:image/*` URIs (embedded document images) while still rejecting
|
package/dist/utils/sanitize.js
CHANGED
|
@@ -15,6 +15,7 @@ exports.escapeHtml = escapeHtml;
|
|
|
15
15
|
exports.escapeXml = escapeXml;
|
|
16
16
|
exports.sanitizeCssValue = sanitizeCssValue;
|
|
17
17
|
exports.sanitizeUrl = sanitizeUrl;
|
|
18
|
+
exports.iframeAllowed = iframeAllowed;
|
|
18
19
|
exports.sanitizeImageUrl = sanitizeImageUrl;
|
|
19
20
|
exports.serializeForInlineScript = serializeForInlineScript;
|
|
20
21
|
exports.csvSafeCell = csvSafeCell;
|
|
@@ -149,6 +150,31 @@ function sanitizeUrl(url) {
|
|
|
149
150
|
// Emit the same normalized string that was validated.
|
|
150
151
|
return escapeHtml(stripped);
|
|
151
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Decide whether a non-provider `<iframe>` should be preserved, per
|
|
155
|
+
* `HtmlParserConfig.preserveIframes`. `true` allows any src; an array is a hostname allowlist,
|
|
156
|
+
* where an entry matches the src's host exactly or as a `.`-suffix (so `"vimeo.com"` also matches
|
|
157
|
+
* `player.vimeo.com`). A relative or unparseable src is allowed only under `true`. This is a
|
|
158
|
+
* preservation gate, not a sanitizer - the src is still scheme-checked with `sanitizeUrl` on
|
|
159
|
+
* generation.
|
|
160
|
+
*/
|
|
161
|
+
function iframeAllowed(src, preserve) {
|
|
162
|
+
if (preserve === true)
|
|
163
|
+
return true;
|
|
164
|
+
if (!Array.isArray(preserve) || preserve.length === 0)
|
|
165
|
+
return false;
|
|
166
|
+
let host;
|
|
167
|
+
try {
|
|
168
|
+
host = new URL(src).hostname.toLowerCase();
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
return preserve.some(entry => {
|
|
174
|
+
const e = String(entry).toLowerCase().trim();
|
|
175
|
+
return e.length > 0 && (host === e || host.endsWith('.' + e));
|
|
176
|
+
});
|
|
177
|
+
}
|
|
152
178
|
/**
|
|
153
179
|
* Like sanitizeUrl but for an <img>/<source> src: additionally permits
|
|
154
180
|
* `data:image/*` URIs (embedded document images) while still rejecting
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "officeparser",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.2",
|
|
4
4
|
"description": "A robust, strictly-typed Node.js and Browser library for parsing office files (.docx, .pptx, .xlsx, .odt, .odp, .ods, .pdf, .rtf, .csv, .md, .html, .epub) and generating high-fidelity outputs in Markdown, HTML, CSV, RTF, PDF, EPUB, and RAG-focused chunks.",
|
|
5
5
|
"funding": "https://github.com/sponsors/harshankur",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"build": "npm run sync:versions && npm run build:node && npm run build:esm-wrapper && npm run build:browser:types && npm run build:browser",
|
|
32
32
|
"build:node": "tsc",
|
|
33
33
|
"build:esm-wrapper": "node scripts/generate-esm-wrapper.js",
|
|
34
|
-
"build:browser:types": "dts-bundle-generator --no-check -o dist/officeparser.browser.d.ts src/index.ts &&
|
|
34
|
+
"build:browser:types": "dts-bundle-generator --no-check -o dist/officeparser.browser.d.ts src/index.ts && node -e \"require('fs').copyFileSync('dist/officeparser.browser.d.ts','dist/officeparser.browser.slim.d.ts')\"",
|
|
35
35
|
"build:browser": "node build_browser.js && npm run sync:docs",
|
|
36
36
|
"sync:versions": "node scripts/sync-pdfjs-versions.js",
|
|
37
|
-
"sync:docs": "
|
|
37
|
+
"sync:docs": "node -e \"const fs=require('fs');fs.mkdirSync('docs/dist',{recursive:true});for(const f of ['officeparser.browser.iife.js','officeparser.browser.mjs','officeparser.browser.slim.iife.js','officeparser.browser.slim.mjs'])fs.copyFileSync('dist/'+f,'docs/dist/'+f);fs.mkdirSync('docs/test/files',{recursive:true});fs.cpSync('test/files','docs/test/files',{recursive:true})\"",
|
|
38
38
|
"lint": "eslint src",
|
|
39
39
|
"test": "npm run lint && npm run test:clean && npm run build && npm run test:license && npm run test:artifacts && npm run test:parser && npm run test:exhaustive && npm run test:generator && npm run test:security && npm run test:cli",
|
|
40
40
|
"test:fast": "npm run lint && npm run test:parser:fast && npm run test:exhaustive && npm run test:generator:fast && npm run test:security && npm run test:cli:fast",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"test:visualizer": "node test/testVisualizer.js",
|
|
54
54
|
"test:integration": "node test/testIntegration.js",
|
|
55
55
|
"test:license": "npm run sbom && node scripts/validate-licenses.js",
|
|
56
|
-
"test:clean": "
|
|
57
|
-
"clean": "
|
|
56
|
+
"test:clean": "node -e \"for(const d of ['test/results','test/generator/results','test/generator/output','test/parser/results','test/parser/output','test/cli/results'])require('fs').rmSync(d,{recursive:true,force:true})\"",
|
|
57
|
+
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && npm run test:clean",
|
|
58
58
|
"sbom": "npx --yes @cyclonedx/cyclonedx-npm --output-format json --output-file dist/sbom.cdx.json --omit dev",
|
|
59
59
|
"prepublishOnly": "npm run build",
|
|
60
60
|
"prepare": "husky"
|