mdream 0.2.1 → 0.2.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/dist/cli.mjs +4 -4
- package/dist/index.mjs +3 -3
- package/dist/plugins.d.mts +7 -2
- package/dist/plugins.d.ts +7 -2
- package/dist/plugins.mjs +46 -4
- package/dist/preset/minimal.mjs +3 -3
- package/dist/shared/{mdream.cpEmpxyh.mjs → mdream.C6Z2rfeq.mjs} +1 -1
- package/dist/shared/{mdream.-hdaPj9a.mjs → mdream.Ch6B8TEB.mjs} +1 -1
- package/dist/shared/{mdream.DEM9pag4.mjs → mdream.D5zBVbP9.mjs} +3 -3
- package/dist/shared/{mdream.C8ruysN5.mjs → mdream.DMUbnRbh.mjs} +2 -2
- package/dist/shared/{mdream.DUeWbUFG.mjs → mdream.N3Qlh-YP.mjs} +1 -1
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
2
|
import { cac } from 'cac';
|
|
3
|
-
import { f as frontmatterPlugin } from './shared/mdream.
|
|
4
|
-
import { r as readabilityPlugin } from './shared/mdream.
|
|
5
|
-
import { s as streamHtmlToMarkdown } from './shared/mdream.
|
|
6
|
-
import './shared/mdream
|
|
3
|
+
import { f as frontmatterPlugin } from './shared/mdream.C6Z2rfeq.mjs';
|
|
4
|
+
import { r as readabilityPlugin } from './shared/mdream.DMUbnRbh.mjs';
|
|
5
|
+
import { s as streamHtmlToMarkdown } from './shared/mdream.N3Qlh-YP.mjs';
|
|
6
|
+
import './shared/mdream.Ch6B8TEB.mjs';
|
|
7
7
|
|
|
8
8
|
async function streamingConvert(options = {}) {
|
|
9
9
|
const outputStream = process.stdout;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { p as processPartialHTMLToMarkdown } from './shared/mdream.
|
|
2
|
-
export { s as streamHtmlToMarkdown } from './shared/mdream.
|
|
3
|
-
import './shared/mdream
|
|
1
|
+
import { p as processPartialHTMLToMarkdown } from './shared/mdream.N3Qlh-YP.mjs';
|
|
2
|
+
export { s as streamHtmlToMarkdown } from './shared/mdream.N3Qlh-YP.mjs';
|
|
3
|
+
import './shared/mdream.Ch6B8TEB.mjs';
|
|
4
4
|
|
|
5
5
|
function htmlToMarkdown(html, options = {}) {
|
|
6
6
|
const state = {
|
package/dist/plugins.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as Plugin } from './shared/mdream.a2AvjJLp.mjs';
|
|
1
|
+
import { P as Plugin, b as ElementNode } from './shared/mdream.a2AvjJLp.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Create a plugin that implements the Plugin interface with improved type inference
|
|
@@ -7,6 +7,11 @@ import { P as Plugin } from './shared/mdream.a2AvjJLp.mjs';
|
|
|
7
7
|
*/
|
|
8
8
|
declare function createPlugin<T extends Partial<Plugin>>(plugin: T): Plugin;
|
|
9
9
|
|
|
10
|
+
interface ExtractedElement extends ElementNode {
|
|
11
|
+
textContent: string;
|
|
12
|
+
}
|
|
13
|
+
declare function extractionPlugin(selectors: Record<string, (element: ExtractedElement) => void>): Plugin;
|
|
14
|
+
|
|
10
15
|
/**
|
|
11
16
|
* Plugin that filters nodes based on CSS selectors.
|
|
12
17
|
* Allows including or excluding nodes based on selectors.
|
|
@@ -85,4 +90,4 @@ declare function readabilityPlugin(): Plugin;
|
|
|
85
90
|
*/
|
|
86
91
|
declare function tailwindPlugin(): Plugin;
|
|
87
92
|
|
|
88
|
-
export { createPlugin, filterPlugin, frontmatterPlugin, isolateMainPlugin, readabilityPlugin, tailwindPlugin };
|
|
93
|
+
export { createPlugin, extractionPlugin, filterPlugin, frontmatterPlugin, isolateMainPlugin, readabilityPlugin, tailwindPlugin };
|
package/dist/plugins.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as Plugin } from './shared/mdream.a2AvjJLp.js';
|
|
1
|
+
import { P as Plugin, b as ElementNode } from './shared/mdream.a2AvjJLp.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Create a plugin that implements the Plugin interface with improved type inference
|
|
@@ -7,6 +7,11 @@ import { P as Plugin } from './shared/mdream.a2AvjJLp.js';
|
|
|
7
7
|
*/
|
|
8
8
|
declare function createPlugin<T extends Partial<Plugin>>(plugin: T): Plugin;
|
|
9
9
|
|
|
10
|
+
interface ExtractedElement extends ElementNode {
|
|
11
|
+
textContent: string;
|
|
12
|
+
}
|
|
13
|
+
declare function extractionPlugin(selectors: Record<string, (element: ExtractedElement) => void>): Plugin;
|
|
14
|
+
|
|
10
15
|
/**
|
|
11
16
|
* Plugin that filters nodes based on CSS selectors.
|
|
12
17
|
* Allows including or excluding nodes based on selectors.
|
|
@@ -85,4 +90,4 @@ declare function readabilityPlugin(): Plugin;
|
|
|
85
90
|
*/
|
|
86
91
|
declare function tailwindPlugin(): Plugin;
|
|
87
92
|
|
|
88
|
-
export { createPlugin, filterPlugin, frontmatterPlugin, isolateMainPlugin, readabilityPlugin, tailwindPlugin };
|
|
93
|
+
export { createPlugin, extractionPlugin, filterPlugin, frontmatterPlugin, isolateMainPlugin, readabilityPlugin, tailwindPlugin };
|
package/dist/plugins.mjs
CHANGED
|
@@ -1,4 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
export { f as
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { c as createPlugin } from './shared/mdream.C6Z2rfeq.mjs';
|
|
2
|
+
export { f as frontmatterPlugin } from './shared/mdream.C6Z2rfeq.mjs';
|
|
3
|
+
import { p as parseSelector } from './shared/mdream.D5zBVbP9.mjs';
|
|
4
|
+
export { f as filterPlugin, i as isolateMainPlugin, t as tailwindPlugin } from './shared/mdream.D5zBVbP9.mjs';
|
|
5
|
+
export { r as readabilityPlugin } from './shared/mdream.DMUbnRbh.mjs';
|
|
6
|
+
import './shared/mdream.Ch6B8TEB.mjs';
|
|
7
|
+
|
|
8
|
+
function extractionPlugin(selectors) {
|
|
9
|
+
const matcherCallbacks = Object.entries(selectors).map(([selector, callback]) => ({
|
|
10
|
+
matcher: parseSelector(selector),
|
|
11
|
+
callback
|
|
12
|
+
}));
|
|
13
|
+
const trackedElements = /* @__PURE__ */ new Map();
|
|
14
|
+
return createPlugin({
|
|
15
|
+
onNodeEnter(element) {
|
|
16
|
+
matcherCallbacks.forEach(({ matcher, callback }) => {
|
|
17
|
+
if (matcher.matches(element)) {
|
|
18
|
+
trackedElements.set(element, { textContent: "", callback });
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
processTextNode(textNode) {
|
|
23
|
+
let currentParent = textNode.parent;
|
|
24
|
+
while (currentParent) {
|
|
25
|
+
const tracked = trackedElements.get(currentParent);
|
|
26
|
+
if (tracked) {
|
|
27
|
+
tracked.textContent += textNode.value;
|
|
28
|
+
}
|
|
29
|
+
currentParent = currentParent.parent;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
onNodeExit(element) {
|
|
33
|
+
const tracked = trackedElements.get(element);
|
|
34
|
+
if (tracked) {
|
|
35
|
+
const extractedElement = {
|
|
36
|
+
...element,
|
|
37
|
+
textContent: tracked.textContent.trim()
|
|
38
|
+
};
|
|
39
|
+
tracked.callback(extractedElement);
|
|
40
|
+
trackedElements.delete(element);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { createPlugin, extractionPlugin };
|
package/dist/preset/minimal.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as isolateMainPlugin, t as tailwindPlugin, f as filterPlugin } from '../shared/mdream.
|
|
3
|
-
import { f as frontmatterPlugin } from '../shared/mdream.
|
|
1
|
+
import { a9 as TAG_FORM, V as TAG_FIELDSET, b2 as TAG_OBJECT, a4 as TAG_EMBED, b6 as TAG_FIGURE, aa as TAG_FOOTER, u as TAG_ASIDE, P as TAG_IFRAME, a3 as TAG_INPUT, X as TAG_TEXTAREA, Y as TAG_SELECT, ah as TAG_BUTTON, aj as TAG_NAV } from '../shared/mdream.Ch6B8TEB.mjs';
|
|
2
|
+
import { i as isolateMainPlugin, t as tailwindPlugin, f as filterPlugin } from '../shared/mdream.D5zBVbP9.mjs';
|
|
3
|
+
import { f as frontmatterPlugin } from '../shared/mdream.C6Z2rfeq.mjs';
|
|
4
4
|
|
|
5
5
|
function withMinimalPreset(options = {}) {
|
|
6
6
|
const plugins = [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as ELEMENT_NODE, aU as TAG_HEAD, c as collectNodeContent, aR as TAG_TITLE, aO as TAG_META } from './mdream.Ch6B8TEB.mjs';
|
|
2
2
|
|
|
3
3
|
function createPlugin(plugin) {
|
|
4
4
|
return plugin;
|
|
@@ -277,4 +277,4 @@ const BLOCKQUOTE_SPACING = [1, 1];
|
|
|
277
277
|
const LIST_ITEM_SPACING = [1, 0];
|
|
278
278
|
const TABLE_ROW_SPACING = [0, 1];
|
|
279
279
|
|
|
280
|
-
export {
|
|
280
|
+
export { TAG_TRACK as $, TAG_SAMP as A, BLOCKQUOTE_SPACING as B, TAG_Q as C, DEFAULT_BLOCK_SPACING as D, ELEMENT_NODE as E, TAG_MARK as F, TAG_ABBR as G, TAG_TEMPLATE as H, TAG_PROGRESS as I, TAG_METER as J, TAG_DIALOG as K, LIST_ITEM_SPACING as L, MARKDOWN_STRIKETHROUGH as M, NodeEventEnter as N, TAG_MAP as O, TAG_IFRAME as P, TAG_CANVAS as Q, TAG_VIDEO as R, TAG_AUDIO as S, TEXT_NODE as T, TAG_LEGEND as U, TAG_FIELDSET as V, TAG_OPTION as W, TAG_TEXTAREA as X, TAG_SELECT as Y, TAG_SVG as Z, TAG_WBR as _, TAG_PRE as a, NodeEventExit as a$, TAG_SOURCE as a0, TAG_PARAM as a1, TAG_KEYGEN as a2, TAG_INPUT as a3, TAG_EMBED as a4, TAG_COL as a5, TAG_BASE as a6, TAG_AREA as a7, TAG_LINK as a8, TAG_FORM as a9, TAG_SUB as aA, TAG_DEL as aB, TAG_I as aC, TAG_EM as aD, TAG_B as aE, TAG_STRONG as aF, TAG_HR as aG, TAG_H6 as aH, TAG_H5 as aI, TAG_H4 as aJ, TAG_H3 as aK, TAG_H2 as aL, TAG_H1 as aM, TAG_BR as aN, TAG_META as aO, TAG_STYLE as aP, TAG_SCRIPT as aQ, TAG_TITLE as aR, TAG_SUMMARY as aS, TAG_DETAILS as aT, TAG_HEAD as aU, MARKDOWN_EMPHASIS as aV, MARKDOWN_STRONG as aW, HTML_ENTITIES as aX, MAX_TAG_ID as aY, assembleBufferedContent as aZ, TagIdMap as a_, TAG_FOOTER as aa, TAG_KBD as ab, TAG_TFOOT as ac, TAG_TBODY as ad, TAG_CENTER as ae, TAG_TABLE as af, TAG_BODY as ag, TAG_BUTTON as ah, TAG_LABEL as ai, TAG_NAV as aj, TAG_SPAN as ak, TAG_DIV as al, TAG_P as am, TAG_TD as an, TAG_TH as ao, TAG_TR as ap, TAG_THEAD as aq, TAG_IMG as ar, TAG_A as as, TAG_UL as at, TAG_OL as au, TAG_CODE as av, MARKDOWN_CODE_BLOCK as aw, MARKDOWN_INLINE_CODE as ax, TAG_INS as ay, TAG_SUP as az, TAG_LI as b, TAG_HTML as b0, createBufferRegion as b1, TAG_OBJECT as b2, TAG_HEADER as b3, TAG_CAPTION as b4, TAG_FIGCAPTION as b5, TAG_FIGURE as b6, TAG_MAIN as b7, TAG_SECTION as b8, TAG_ARTICLE as b9, collectNodeContent as c, TAG_BLOCKQUOTE as d, NO_SPACING as e, TABLE_ROW_SPACING as f, MARKDOWN_HORIZONTAL_RULE as g, TAG_DD as h, TAG_DT as i, TAG_DL as j, TAG_ADDRESS as k, TAG_RP as l, TAG_RT as m, TAG_RUBY as n, TAG_BDO as o, TAG_TIME as p, TAG_VAR as q, TAG_DFN as r, TAG_CITE as s, TAG_U as t, TAG_ASIDE as u, TAG_PLAINTEXT as v, TAG_XMP as w, TAG_NOFRAMES as x, TAG_NOSCRIPT as y, TAG_SMALL as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as createPlugin } from './mdream.
|
|
1
|
+
import { T as TEXT_NODE, E as ELEMENT_NODE, b7 as TAG_MAIN, b3 as TAG_HEADER, aa as TAG_FOOTER, aM as TAG_H1, aL as TAG_H2, aK as TAG_H3, aJ as TAG_H4, aI as TAG_H5, aH as TAG_H6 } from './mdream.Ch6B8TEB.mjs';
|
|
2
|
+
import { c as createPlugin } from './mdream.C6Z2rfeq.mjs';
|
|
3
3
|
|
|
4
4
|
class TagSelector {
|
|
5
5
|
constructor(tagName) {
|
|
@@ -498,4 +498,4 @@ function tailwindPlugin() {
|
|
|
498
498
|
});
|
|
499
499
|
}
|
|
500
500
|
|
|
501
|
-
export { filterPlugin as f, isolateMainPlugin as i, tailwindPlugin as t };
|
|
501
|
+
export { filterPlugin as f, isolateMainPlugin as i, parseSelector as p, tailwindPlugin as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as createPlugin } from './mdream.
|
|
1
|
+
import { ag as TAG_BODY, b0 as TAG_HTML, aU as TAG_HEAD, b1 as createBufferRegion, as as TAG_A, k as TAG_ADDRESS, aS as TAG_SUMMARY, aT as TAG_DETAILS, aP as TAG_STYLE, aQ as TAG_SCRIPT, ak as TAG_SPAN, aN as TAG_BR, aG as TAG_HR, aC as TAG_I, aD as TAG_EM, aE as TAG_B, aF as TAG_STRONG, b2 as TAG_OBJECT, a4 as TAG_EMBED, P as TAG_IFRAME, V as TAG_FIELDSET, Y as TAG_SELECT, X as TAG_TEXTAREA, a3 as TAG_INPUT, ah as TAG_BUTTON, a9 as TAG_FORM, u as TAG_ASIDE, aj as TAG_NAV, aa as TAG_FOOTER, b3 as TAG_HEADER, aH as TAG_H6, aI as TAG_H5, aJ as TAG_H4, aK as TAG_H3, aL as TAG_H2, aM as TAG_H1, h as TAG_DD, i as TAG_DT, j as TAG_DL, b as TAG_LI, au as TAG_OL, at as TAG_UL, an as TAG_TD, ao as TAG_TH, ap as TAG_TR, ac as TAG_TFOOT, ad as TAG_TBODY, aq as TAG_THEAD, b4 as TAG_CAPTION, af as TAG_TABLE, Z as TAG_SVG, S as TAG_AUDIO, R as TAG_VIDEO, b5 as TAG_FIGCAPTION, b6 as TAG_FIGURE, ar as TAG_IMG, av as TAG_CODE, a as TAG_PRE, d as TAG_BLOCKQUOTE, al as TAG_DIV, am as TAG_P, b7 as TAG_MAIN, b8 as TAG_SECTION, b9 as TAG_ARTICLE } from './mdream.Ch6B8TEB.mjs';
|
|
2
|
+
import { c as createPlugin } from './mdream.C6Z2rfeq.mjs';
|
|
3
3
|
|
|
4
4
|
const REGEXPS = {
|
|
5
5
|
// Positive patterns that suggest high-quality content
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { T as TEXT_NODE, N as NodeEventEnter, c as collectNodeContent, E as ELEMENT_NODE, a as TAG_PRE, b as TAG_LI, d as TAG_BLOCKQUOTE, e as NO_SPACING, D as DEFAULT_BLOCK_SPACING, f as TABLE_ROW_SPACING, L as LIST_ITEM_SPACING, B as BLOCKQUOTE_SPACING, M as MARKDOWN_STRIKETHROUGH, g as MARKDOWN_HORIZONTAL_RULE, h as TAG_DD, i as TAG_DT, j as TAG_DL, k as TAG_ADDRESS, l as TAG_RP, m as TAG_RT, n as TAG_RUBY, o as TAG_BDO, p as TAG_TIME, q as TAG_VAR, r as TAG_DFN, s as TAG_CITE, t as TAG_U, u as TAG_ASIDE, v as TAG_PLAINTEXT, w as TAG_XMP, x as TAG_NOFRAMES, y as TAG_NOSCRIPT, z as TAG_SMALL, A as TAG_SAMP, C as TAG_Q, F as TAG_MARK, G as TAG_ABBR, H as TAG_TEMPLATE, I as TAG_PROGRESS, J as TAG_METER, K as TAG_DIALOG, O as TAG_MAP, P as TAG_IFRAME, Q as TAG_CANVAS, R as TAG_VIDEO, S as TAG_AUDIO, U as TAG_LEGEND, V as TAG_FIELDSET, W as TAG_OPTION, X as TAG_TEXTAREA, Y as TAG_SELECT, Z as TAG_SVG, _ as TAG_WBR, $ as TAG_TRACK, a0 as TAG_SOURCE, a1 as TAG_PARAM, a2 as TAG_KEYGEN, a3 as TAG_INPUT, a4 as TAG_EMBED, a5 as TAG_COL, a6 as TAG_BASE, a7 as TAG_AREA, a8 as TAG_LINK, a9 as TAG_FORM, aa as TAG_FOOTER, ab as TAG_KBD, ac as TAG_TFOOT, ad as TAG_TBODY, ae as TAG_CENTER, af as TAG_TABLE, ag as TAG_BODY, ah as TAG_BUTTON, ai as TAG_LABEL, aj as TAG_NAV, ak as TAG_SPAN, al as TAG_DIV, am as TAG_P, an as TAG_TD, ao as TAG_TH, ap as TAG_TR, aq as TAG_THEAD, ar as TAG_IMG, as as TAG_A, at as TAG_UL, au as TAG_OL, av as TAG_CODE, aw as MARKDOWN_CODE_BLOCK, ax as MARKDOWN_INLINE_CODE, ay as TAG_INS, az as TAG_SUP, aA as TAG_SUB, aB as TAG_DEL, aC as TAG_I, aD as TAG_EM, aE as TAG_B, aF as TAG_STRONG, aG as TAG_HR, aH as TAG_H6, aI as TAG_H5, aJ as TAG_H4, aK as TAG_H3, aL as TAG_H2, aM as TAG_H1, aN as TAG_BR, aO as TAG_META, aP as TAG_STYLE, aQ as TAG_SCRIPT, aR as TAG_TITLE, aS as TAG_SUMMARY, aT as TAG_DETAILS, aU as TAG_HEAD, aV as MARKDOWN_EMPHASIS, aW as MARKDOWN_STRONG, aX as HTML_ENTITIES, aY as MAX_TAG_ID, aZ as assembleBufferedContent, a_ as TagIdMap, a$ as NodeEventExit } from './mdream.Ch6B8TEB.mjs';
|
|
2
2
|
|
|
3
3
|
function needsSpacing(lastChar, firstChar) {
|
|
4
4
|
const noSpaceLastChars = /* @__PURE__ */ new Set(["\n", " ", "[", ">", "_", "*", "`", "|", "#", "<", "("]);
|