officeparser 7.6.2 → 7.8.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 +9 -4
- package/dist/defaults.js +2 -0
- package/dist/generators/HtmlGenerator.js +72 -17
- package/dist/generators/MarkdownGenerator.d.ts +1 -0
- package/dist/generators/MarkdownGenerator.js +169 -54
- package/dist/officeparser.browser.d.ts +151 -20
- package/dist/officeparser.browser.iife.js +194 -181
- package/dist/officeparser.browser.mjs +194 -181
- package/dist/officeparser.browser.slim.d.ts +151 -20
- package/dist/officeparser.browser.slim.iife.js +194 -181
- package/dist/officeparser.browser.slim.mjs +194 -181
- package/dist/parsers/HtmlParser.js +73 -5
- package/dist/parsers/MarkdownParser.js +186 -11
- package/dist/sbom.cdx.json +161 -93
- package/dist/types.d.ts +151 -20
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -413,6 +413,18 @@ export interface HtmlParserConfig {
|
|
|
413
413
|
* Defaults to false.
|
|
414
414
|
*/
|
|
415
415
|
preserveIframes?: boolean | string[];
|
|
416
|
+
/**
|
|
417
|
+
* Import ambiguous "folk" embed forms in Markdown as embeds: a standalone Obsidian-style image
|
|
418
|
+
* whose URL is a YouTube link (``), and the clickable
|
|
419
|
+
* thumbnail-link (`[](watch-url)`). Both become a
|
|
420
|
+
* `embedType: 'youtube'` embed (rendered from the validated id, so it is safe). Off by default:
|
|
421
|
+
* auto-upgrading an image/link to an embed is a heuristic that could mangle a genuinely-intended
|
|
422
|
+
* image link, so a consumer opts in. The unambiguous forms (`<div data-youtube-video>`, a bare
|
|
423
|
+
* YouTube `<iframe>`, the `::youtube` directive) are always recognized, independent of this flag.
|
|
424
|
+
*
|
|
425
|
+
* Defaults to false.
|
|
426
|
+
*/
|
|
427
|
+
embedFolkForms?: boolean;
|
|
416
428
|
}
|
|
417
429
|
/**
|
|
418
430
|
* Maps an input format string to its corresponding format-specific parser configuration, mirroring
|
|
@@ -909,6 +921,15 @@ export interface HtmlGeneratorConfig {
|
|
|
909
921
|
* `HtmlParser` reads every shape this emits, so output stays self-round-trippable.
|
|
910
922
|
*/
|
|
911
923
|
sourceAttributes?: boolean;
|
|
924
|
+
/**
|
|
925
|
+
* Emit a generic (non-YouTube) iframe embed as a gated placeholder,
|
|
926
|
+
* `<div data-embed-gated data-embed-src="…" …>`, instead of a live `<iframe>`. The gated shape
|
|
927
|
+
* never auto-loads its src: an editor renders a click-to-load placeholder from it, and
|
|
928
|
+
* `HtmlParser` reads it back to the same `embed` node. The src is scheme-checked (`sanitizeUrl`)
|
|
929
|
+
* on emit. Off by default; the default output (a live `<iframe>`) is unchanged. YouTube embeds
|
|
930
|
+
* are unaffected (they already render from a validated id).
|
|
931
|
+
*/
|
|
932
|
+
gatedEmbeds?: boolean;
|
|
912
933
|
}
|
|
913
934
|
/**
|
|
914
935
|
* Configuration options for PDF generation.
|
|
@@ -1065,6 +1086,49 @@ export interface CsvGeneratorConfig {
|
|
|
1065
1086
|
* historical output exactly (every feature on, GitHub-style admonitions).
|
|
1066
1087
|
*/
|
|
1067
1088
|
export type MarkdownDialectPreset = 'extended' | 'github' | 'gitlab' | 'obsidian' | 'pandoc' | 'commonmark';
|
|
1089
|
+
/** Admonition syntax: `'blockquote'` = GitHub `> [!NOTE]`, `'fence'` = GitLab `:::note`,
|
|
1090
|
+
* `'fence-attribute'` = Pandoc `::: {.note}`, `'none'` = plain bold-labeled blockquote. */
|
|
1091
|
+
export type AdmonitionSyntax = 'blockquote' | 'fence' | 'fence-attribute' | 'none';
|
|
1092
|
+
/** `==text==` highlight (`'equals'`), or `'none'` to disable. */
|
|
1093
|
+
export type HighlightSyntax = 'equals' | 'none';
|
|
1094
|
+
/** GFM `~~text~~` strikethrough (`'tilde'`), or `'none'`. */
|
|
1095
|
+
export type StrikethroughSyntax = 'tilde' | 'none';
|
|
1096
|
+
/** `Term`/`: Description` definition lists (`'colon'`), or `'none'`. */
|
|
1097
|
+
export type DefinitionListSyntax = 'colon' | 'none';
|
|
1098
|
+
/** `[^id]` footnotes (`'caret'`), or `'none'`. */
|
|
1099
|
+
export type FootnoteSyntax = 'caret' | 'none';
|
|
1100
|
+
/** `[@citekey]` citations (`'at'`), or `'none'`. */
|
|
1101
|
+
export type CitationSyntax = 'at' | 'none';
|
|
1102
|
+
/** `[[Page]]` wikilinks (`'double-bracket'`), or `'none'`. */
|
|
1103
|
+
export type WikilinkSyntax = 'double-bracket' | 'none';
|
|
1104
|
+
/** `{width=50%}` attribute lists (`'brace'`), or `'none'`. */
|
|
1105
|
+
export type AttributeListSyntax = 'brace' | 'none';
|
|
1106
|
+
/**
|
|
1107
|
+
* How an `embed` node is written to Markdown:
|
|
1108
|
+
* - `'html'` (default): the single-line `<div data-youtube-video="ID">` / `<iframe src=...>` block
|
|
1109
|
+
* this library has always emitted. Round-trips through officeParser, but renders as an invisible
|
|
1110
|
+
* empty box on GitHub.
|
|
1111
|
+
* - `'directive'`: a remark-directive leaf, `::youtube[Label]{id=... width=... align=...}` /
|
|
1112
|
+
* `::embed[Label]{src=... width=... height=... align=...}`. Round-trips within an editor that
|
|
1113
|
+
* understands it; renders verbatim (not just the label) on GitHub, so it is an editor format, not
|
|
1114
|
+
* a GitHub-interop one.
|
|
1115
|
+
* - `'link'`: a plain `[YouTube](url)` / `[Embed](url)`.
|
|
1116
|
+
* - `'thumbnail'`: a YouTube-only clickable thumbnail `[](watch)`,
|
|
1117
|
+
* the best GitHub degrade; a non-YouTube embed falls back to `'link'`.
|
|
1118
|
+
*/
|
|
1119
|
+
export type EmbedSyntax = 'html' | 'directive' | 'link' | 'thumbnail';
|
|
1120
|
+
/**
|
|
1121
|
+
* @deprecated Legacy flavor names for `MarkdownDialectConfig.admonitions`. Use the syntax names
|
|
1122
|
+
* instead: `'github'` -> `'blockquote'`, `'gitlab'` -> `'fence'`, `'pandoc'` -> `'fence-attribute'`.
|
|
1123
|
+
* These aliases still resolve to the same output and will be removed in the next major version.
|
|
1124
|
+
*/
|
|
1125
|
+
export type DeprecatedAdmonitionFlavor = 'github' | 'gitlab' | 'pandoc';
|
|
1126
|
+
/**
|
|
1127
|
+
* @deprecated Boolean toggles for dialect capability fields are deprecated in favor of the
|
|
1128
|
+
* syntax-name unions: `true` maps to that field's on-value (e.g. `'tilde'`), `false` maps to
|
|
1129
|
+
* `'none'`. Booleans keep working via coercion and will be removed in the next major version.
|
|
1130
|
+
*/
|
|
1131
|
+
export type DeprecatedDialectToggle = boolean;
|
|
1068
1132
|
/**
|
|
1069
1133
|
* Granular control over which native Markdown syntax the generator emits for constructs that
|
|
1070
1134
|
* differ across real-world dialects (e.g. GitHub's `> [!NOTE]` vs GitLab's `:::note` vs Pandoc's
|
|
@@ -1076,25 +1140,60 @@ export type MarkdownDialectPreset = 'extended' | 'github' | 'gitlab' | 'obsidian
|
|
|
1076
1140
|
export interface MarkdownDialectConfig {
|
|
1077
1141
|
/** Base preset any omitted field inherits from. Defaults to 'extended'. */
|
|
1078
1142
|
extends?: MarkdownDialectPreset;
|
|
1079
|
-
/**
|
|
1080
|
-
*
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
/**
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
*
|
|
1091
|
-
|
|
1092
|
-
|
|
1143
|
+
/**
|
|
1144
|
+
* Admonition syntax: `'blockquote'` = GitHub `> [!NOTE]`, `'fence'` = GitLab `:::note`,
|
|
1145
|
+
* `'fence-attribute'` = Pandoc `::: {.note}`, `'none'` = a plain bold-labeled blockquote with no
|
|
1146
|
+
* special marker. Omit to inherit from the `extends` preset. The legacy flavor names
|
|
1147
|
+
* `'github'`/`'gitlab'`/`'pandoc'` are accepted as deprecated aliases (see
|
|
1148
|
+
* `DeprecatedAdmonitionFlavor`) and will be removed in the next major version.
|
|
1149
|
+
*/
|
|
1150
|
+
admonitions?: AdmonitionSyntax | DeprecatedAdmonitionFlavor;
|
|
1151
|
+
/**
|
|
1152
|
+
* Markdown Extra/Pandoc-style `Term`/`: Description` definition lists (`'colon'`), or `'none'`
|
|
1153
|
+
* to render terms and descriptions as plain paragraphs. Omit to inherit from `extends`. Passing
|
|
1154
|
+
* a boolean is deprecated: `true` = `'colon'`, `false` = `'none'` (removed next major).
|
|
1155
|
+
*/
|
|
1156
|
+
definitionLists?: DefinitionListSyntax | DeprecatedDialectToggle;
|
|
1157
|
+
/**
|
|
1158
|
+
* `[^id]` footnote references/definitions (`'caret'`), or `'none'` to inline note content as a
|
|
1159
|
+
* parenthetical right at the reference point. Omit to inherit from `extends`. Passing a boolean
|
|
1160
|
+
* is deprecated: `true` = `'caret'`, `false` = `'none'` (removed next major).
|
|
1161
|
+
*/
|
|
1162
|
+
footnotes?: FootnoteSyntax | DeprecatedDialectToggle;
|
|
1163
|
+
/**
|
|
1164
|
+
* Pandoc-style `[@citekey]` citations (`'at'`), or `'none'` to emit `[citekey]` (brackets, no
|
|
1165
|
+
* `@`). Omit to inherit from `extends`. Passing a boolean is deprecated: `true` = `'at'`,
|
|
1166
|
+
* `false` = `'none'` (removed next major).
|
|
1167
|
+
*/
|
|
1168
|
+
citations?: CitationSyntax | DeprecatedDialectToggle;
|
|
1169
|
+
/**
|
|
1170
|
+
* Obsidian-style `[[Page]]`/`[[Page|Alias]]` wikilinks (`'double-bracket'`), or `'none'` to fall
|
|
1171
|
+
* back to a plain `[text](url)` link using the same target. Omit to inherit from `extends`.
|
|
1172
|
+
* Passing a boolean is deprecated: `true` = `'double-bracket'`, `false` = `'none'` (removed next major).
|
|
1173
|
+
*/
|
|
1174
|
+
wikilinks?: WikilinkSyntax | DeprecatedDialectToggle;
|
|
1175
|
+
/** Inline `$...$`/block `$$...$$` math delimiters (`'dollar'`), or `'none'` for bare LaTeX text. */
|
|
1093
1176
|
math?: 'dollar' | 'none';
|
|
1094
|
-
/**
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1177
|
+
/**
|
|
1178
|
+
* Pandoc-style `{width=50% .centered}` attribute lists after images/tables (`'brace'`), or
|
|
1179
|
+
* `'none'`. Omit to inherit from `extends`. Passing a boolean is deprecated: `true` = `'brace'`,
|
|
1180
|
+
* `false` = `'none'` (removed next major).
|
|
1181
|
+
*/
|
|
1182
|
+
attributeLists?: AttributeListSyntax | DeprecatedDialectToggle;
|
|
1183
|
+
/**
|
|
1184
|
+
* GFM `~~text~~` strikethrough (`'tilde'`; not part of base CommonMark), or `'none'`. Omit to
|
|
1185
|
+
* inherit from `extends`. Passing a boolean is deprecated: `true` = `'tilde'`, `false` = `'none'`
|
|
1186
|
+
* (removed next major).
|
|
1187
|
+
*/
|
|
1188
|
+
strikethrough?: StrikethroughSyntax | DeprecatedDialectToggle;
|
|
1189
|
+
/**
|
|
1190
|
+
* `==text==` highlight (`'equals'`; Obsidian/extended flavors, NOT GFM or CommonMark where `==`
|
|
1191
|
+
* is literal text), or `'none'`. When `'equals'`, a highlighted run round-trips as `==text==`
|
|
1192
|
+
* and `==text==` is read back as a highlight; when `'none'`, a highlight falls back to an HTML
|
|
1193
|
+
* `<mark>`/`<span>` per `fallbackToHtml.inlineFormatting`, and `==text==` stays literal on parse.
|
|
1194
|
+
* Omit to inherit from `extends`.
|
|
1195
|
+
*/
|
|
1196
|
+
highlight?: HighlightSyntax;
|
|
1098
1197
|
/** Unordered list bullet character. */
|
|
1099
1198
|
bulletListMarker?: '-' | '*' | '+';
|
|
1100
1199
|
/** Ordered list marker punctuation. */
|
|
@@ -1104,6 +1203,13 @@ export interface MarkdownDialectConfig {
|
|
|
1104
1203
|
/** Table syntax: native GFM pipe tables, or forced HTML `<table>` (required for strict
|
|
1105
1204
|
* CommonMark, which has no table syntax of its own). */
|
|
1106
1205
|
tables?: 'native' | 'html';
|
|
1206
|
+
/**
|
|
1207
|
+
* How an `embed` node is written to Markdown (`'html'` | `'directive'` | `'link'` |
|
|
1208
|
+
* `'thumbnail'`; see `EmbedSyntax`). This is the authority for embed form. When omitted, the
|
|
1209
|
+
* deprecated `fallbackToHtml.embeds` boolean is honored (`true`/unset maps to `'html'`, `false`
|
|
1210
|
+
* to `'link'`), then the default `'html'`.
|
|
1211
|
+
*/
|
|
1212
|
+
embeds?: EmbedSyntax;
|
|
1107
1213
|
}
|
|
1108
1214
|
/**
|
|
1109
1215
|
* Granular control over when the Markdown generator falls back to raw HTML tags for features
|
|
@@ -1120,10 +1226,22 @@ export interface FallbackToHtmlConfig {
|
|
|
1120
1226
|
anchors?: boolean;
|
|
1121
1227
|
/** Nested-table and merged-cell (colspan/rowspan) HTML `<table>` fallback. */
|
|
1122
1228
|
tables?: boolean;
|
|
1123
|
-
/**
|
|
1229
|
+
/**
|
|
1230
|
+
* YouTube embed `<div data-youtube-video>` vs. a plain link.
|
|
1231
|
+
* @deprecated Use `mdConfig.dialect.embeds` (`EmbedSyntax`) instead, which also selects the
|
|
1232
|
+
* `'directive'` and `'thumbnail'` forms. When `dialect.embeds` is unset this boolean is still
|
|
1233
|
+
* honored (`true` maps to `'html'`, `false` to `'link'`); it will be removed in the next major.
|
|
1234
|
+
*/
|
|
1124
1235
|
embeds?: boolean;
|
|
1125
1236
|
/** Multi-line table cell content joined with `<br>` instead of a space. */
|
|
1126
1237
|
cellLineBreaks?: boolean;
|
|
1238
|
+
/**
|
|
1239
|
+
* Multi-paragraph list-item content (an HTML `<li>` with several `<p>` children) joined with
|
|
1240
|
+
* `<br>` instead of a space, so it stays on the item's single Markdown line. Block children of
|
|
1241
|
+
* an item (a code fence or table inside `<li>`) degrade under this join, the same way they do
|
|
1242
|
+
* inside a table cell under `cellLineBreaks`.
|
|
1243
|
+
*/
|
|
1244
|
+
itemLineBreaks?: boolean;
|
|
1127
1245
|
/**
|
|
1128
1246
|
* Inline text color, highlight, and font size via a `<span style="color:...;background-color:...;
|
|
1129
1247
|
* font-size:...">` run, which the Markdown parser reads back. These have no Markdown syntax and
|
|
@@ -1630,6 +1748,12 @@ export interface CellMetadata {
|
|
|
1630
1748
|
* @example 0 for column A, 1 for column B, etc.
|
|
1631
1749
|
*/
|
|
1632
1750
|
col: number;
|
|
1751
|
+
/**
|
|
1752
|
+
* Text alignment for this cell's column, from the GFM pipe-table separator row
|
|
1753
|
+
* (`:---` left, `:---:` center, `---:` right). All cells in a column carry the same value;
|
|
1754
|
+
* the Markdown generator reads it from the header row to emit the separator.
|
|
1755
|
+
*/
|
|
1756
|
+
align?: 'left' | 'center' | 'right';
|
|
1633
1757
|
/**
|
|
1634
1758
|
* The number of rows this cell spans (merges).
|
|
1635
1759
|
* @example 2 if the cell is merged with the one below it.
|
|
@@ -1708,6 +1832,8 @@ export interface ImageMetadata {
|
|
|
1708
1832
|
* @example 'center'
|
|
1709
1833
|
*/
|
|
1710
1834
|
align?: 'left' | 'center' | 'right';
|
|
1835
|
+
/** Advisory image title (Markdown ``, HTML `<img title>`), if any. */
|
|
1836
|
+
title?: string;
|
|
1711
1837
|
}
|
|
1712
1838
|
/**
|
|
1713
1839
|
* Metadata for an embedded external media node (e.g. a YouTube video).
|
|
@@ -1725,10 +1851,13 @@ export interface EmbedMetadata {
|
|
|
1725
1851
|
url?: string;
|
|
1726
1852
|
/** Display width, as a CSS length or percentage. */
|
|
1727
1853
|
width?: string;
|
|
1728
|
-
/** Display height, as a CSS length or percentage
|
|
1854
|
+
/** Display height, as a CSS length or percentage. */
|
|
1729
1855
|
height?: string;
|
|
1730
1856
|
/** Layout alignment of the embed. */
|
|
1731
1857
|
align?: 'left' | 'center' | 'right';
|
|
1858
|
+
/** Human-readable label for the embed (e.g. the `[Label]` of a `::youtube[Label]{...}` leaf
|
|
1859
|
+
* directive, or a gated embed's caption). Purely descriptive; never a trust or render input. */
|
|
1860
|
+
label?: string;
|
|
1732
1861
|
}
|
|
1733
1862
|
/**
|
|
1734
1863
|
* Metadata for an admonition/alert node (e.g. GitHub's `> [!NOTE]` or GLFM's `:::note`).
|
|
@@ -1791,6 +1920,8 @@ export interface TextMetadata {
|
|
|
1791
1920
|
* officeParser always parses/generates the syntax.
|
|
1792
1921
|
*/
|
|
1793
1922
|
wikilink?: boolean;
|
|
1923
|
+
/** Advisory link title (Markdown `[text](url "title")`, HTML `<a title>`), if any. */
|
|
1924
|
+
title?: string;
|
|
1794
1925
|
}
|
|
1795
1926
|
/**
|
|
1796
1927
|
* Metadata for note nodes (footnotes/endnotes).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "officeparser",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.8.0",
|
|
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",
|