officeparser 7.7.0 → 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 +3 -2
- package/dist/defaults.js +2 -0
- package/dist/generators/HtmlGenerator.js +19 -3
- package/dist/generators/MarkdownGenerator.d.ts +1 -0
- package/dist/generators/MarkdownGenerator.js +58 -14
- package/dist/officeparser.browser.d.ts +52 -2
- package/dist/officeparser.browser.iife.js +167 -161
- package/dist/officeparser.browser.mjs +167 -161
- package/dist/officeparser.browser.slim.d.ts +52 -2
- package/dist/officeparser.browser.slim.iife.js +158 -152
- package/dist/officeparser.browser.slim.mjs +158 -152
- package/dist/parsers/HtmlParser.js +37 -2
- package/dist/parsers/MarkdownParser.js +113 -3
- package/dist/sbom.cdx.json +92 -92
- package/dist/types.d.ts +52 -2
- package/package.json +1 -1
|
@@ -415,6 +415,18 @@ export interface HtmlParserConfig {
|
|
|
415
415
|
* Defaults to false.
|
|
416
416
|
*/
|
|
417
417
|
preserveIframes?: boolean | string[];
|
|
418
|
+
/**
|
|
419
|
+
* Import ambiguous "folk" embed forms in Markdown as embeds: a standalone Obsidian-style image
|
|
420
|
+
* whose URL is a YouTube link (``), and the clickable
|
|
421
|
+
* thumbnail-link (`[](watch-url)`). Both become a
|
|
422
|
+
* `embedType: 'youtube'` embed (rendered from the validated id, so it is safe). Off by default:
|
|
423
|
+
* auto-upgrading an image/link to an embed is a heuristic that could mangle a genuinely-intended
|
|
424
|
+
* image link, so a consumer opts in. The unambiguous forms (`<div data-youtube-video>`, a bare
|
|
425
|
+
* YouTube `<iframe>`, the `::youtube` directive) are always recognized, independent of this flag.
|
|
426
|
+
*
|
|
427
|
+
* Defaults to false.
|
|
428
|
+
*/
|
|
429
|
+
embedFolkForms?: boolean;
|
|
418
430
|
}
|
|
419
431
|
/**
|
|
420
432
|
* Maps an input format string to its corresponding format-specific parser configuration, mirroring
|
|
@@ -883,6 +895,15 @@ export interface HtmlGeneratorConfig {
|
|
|
883
895
|
* `HtmlParser` reads every shape this emits, so output stays self-round-trippable.
|
|
884
896
|
*/
|
|
885
897
|
sourceAttributes?: boolean;
|
|
898
|
+
/**
|
|
899
|
+
* Emit a generic (non-YouTube) iframe embed as a gated placeholder,
|
|
900
|
+
* `<div data-embed-gated data-embed-src="…" …>`, instead of a live `<iframe>`. The gated shape
|
|
901
|
+
* never auto-loads its src: an editor renders a click-to-load placeholder from it, and
|
|
902
|
+
* `HtmlParser` reads it back to the same `embed` node. The src is scheme-checked (`sanitizeUrl`)
|
|
903
|
+
* on emit. Off by default; the default output (a live `<iframe>`) is unchanged. YouTube embeds
|
|
904
|
+
* are unaffected (they already render from a validated id).
|
|
905
|
+
*/
|
|
906
|
+
gatedEmbeds?: boolean;
|
|
886
907
|
}
|
|
887
908
|
/**
|
|
888
909
|
* Configuration options for PDF generation.
|
|
@@ -1056,6 +1077,20 @@ export type CitationSyntax = "at" | "none";
|
|
|
1056
1077
|
export type WikilinkSyntax = "double-bracket" | "none";
|
|
1057
1078
|
/** `{width=50%}` attribute lists (`'brace'`), or `'none'`. */
|
|
1058
1079
|
export type AttributeListSyntax = "brace" | "none";
|
|
1080
|
+
/**
|
|
1081
|
+
* How an `embed` node is written to Markdown:
|
|
1082
|
+
* - `'html'` (default): the single-line `<div data-youtube-video="ID">` / `<iframe src=...>` block
|
|
1083
|
+
* this library has always emitted. Round-trips through officeParser, but renders as an invisible
|
|
1084
|
+
* empty box on GitHub.
|
|
1085
|
+
* - `'directive'`: a remark-directive leaf, `::youtube[Label]{id=... width=... align=...}` /
|
|
1086
|
+
* `::embed[Label]{src=... width=... height=... align=...}`. Round-trips within an editor that
|
|
1087
|
+
* understands it; renders verbatim (not just the label) on GitHub, so it is an editor format, not
|
|
1088
|
+
* a GitHub-interop one.
|
|
1089
|
+
* - `'link'`: a plain `[YouTube](url)` / `[Embed](url)`.
|
|
1090
|
+
* - `'thumbnail'`: a YouTube-only clickable thumbnail `[](watch)`,
|
|
1091
|
+
* the best GitHub degrade; a non-YouTube embed falls back to `'link'`.
|
|
1092
|
+
*/
|
|
1093
|
+
export type EmbedSyntax = "html" | "directive" | "link" | "thumbnail";
|
|
1059
1094
|
/**
|
|
1060
1095
|
* @deprecated Legacy flavor names for `MarkdownDialectConfig.admonitions`. Use the syntax names
|
|
1061
1096
|
* instead: `'github'` -> `'blockquote'`, `'gitlab'` -> `'fence'`, `'pandoc'` -> `'fence-attribute'`.
|
|
@@ -1142,6 +1177,13 @@ export interface MarkdownDialectConfig {
|
|
|
1142
1177
|
/** Table syntax: native GFM pipe tables, or forced HTML `<table>` (required for strict
|
|
1143
1178
|
* CommonMark, which has no table syntax of its own). */
|
|
1144
1179
|
tables?: "native" | "html";
|
|
1180
|
+
/**
|
|
1181
|
+
* How an `embed` node is written to Markdown (`'html'` | `'directive'` | `'link'` |
|
|
1182
|
+
* `'thumbnail'`; see `EmbedSyntax`). This is the authority for embed form. When omitted, the
|
|
1183
|
+
* deprecated `fallbackToHtml.embeds` boolean is honored (`true`/unset maps to `'html'`, `false`
|
|
1184
|
+
* to `'link'`), then the default `'html'`.
|
|
1185
|
+
*/
|
|
1186
|
+
embeds?: EmbedSyntax;
|
|
1145
1187
|
}
|
|
1146
1188
|
/**
|
|
1147
1189
|
* Granular control over when the Markdown generator falls back to raw HTML tags for features
|
|
@@ -1158,7 +1200,12 @@ export interface FallbackToHtmlConfig {
|
|
|
1158
1200
|
anchors?: boolean;
|
|
1159
1201
|
/** Nested-table and merged-cell (colspan/rowspan) HTML `<table>` fallback. */
|
|
1160
1202
|
tables?: boolean;
|
|
1161
|
-
/**
|
|
1203
|
+
/**
|
|
1204
|
+
* YouTube embed `<div data-youtube-video>` vs. a plain link.
|
|
1205
|
+
* @deprecated Use `mdConfig.dialect.embeds` (`EmbedSyntax`) instead, which also selects the
|
|
1206
|
+
* `'directive'` and `'thumbnail'` forms. When `dialect.embeds` is unset this boolean is still
|
|
1207
|
+
* honored (`true` maps to `'html'`, `false` to `'link'`); it will be removed in the next major.
|
|
1208
|
+
*/
|
|
1162
1209
|
embeds?: boolean;
|
|
1163
1210
|
/** Multi-line table cell content joined with `<br>` instead of a space. */
|
|
1164
1211
|
cellLineBreaks?: boolean;
|
|
@@ -1778,10 +1825,13 @@ export interface EmbedMetadata {
|
|
|
1778
1825
|
url?: string;
|
|
1779
1826
|
/** Display width, as a CSS length or percentage. */
|
|
1780
1827
|
width?: string;
|
|
1781
|
-
/** Display height, as a CSS length or percentage
|
|
1828
|
+
/** Display height, as a CSS length or percentage. */
|
|
1782
1829
|
height?: string;
|
|
1783
1830
|
/** Layout alignment of the embed. */
|
|
1784
1831
|
align?: "left" | "center" | "right";
|
|
1832
|
+
/** Human-readable label for the embed (e.g. the `[Label]` of a `::youtube[Label]{...}` leaf
|
|
1833
|
+
* directive, or a gated embed's caption). Purely descriptive; never a trust or render input. */
|
|
1834
|
+
label?: string;
|
|
1785
1835
|
}
|
|
1786
1836
|
/**
|
|
1787
1837
|
* Metadata for an admonition/alert node (e.g. GitHub's `> [!NOTE]` or GLFM's `:::note`).
|