extract-webpage 1.2.360 → 1.2.362
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "extract-webpage",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.362",
|
|
4
4
|
"module": "./dist/extract-webpage.es.js",
|
|
5
5
|
"description": "Search, extract, cite, and outline the web for a topic with AI Research Agent.",
|
|
6
6
|
"author": "vtempest <grokthiscontact@gmail.com>",
|
|
@@ -74,11 +74,11 @@
|
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@huggingface/transformers": "^4.2.0",
|
|
76
76
|
"ai": "^7.0.94",
|
|
77
|
-
"chat-agent-toolkit": "^1.2.
|
|
77
|
+
"chat-agent-toolkit": "^1.2.368",
|
|
78
78
|
"chrono-node": "^2.10.1",
|
|
79
79
|
"drizzle-orm": "^0.45.2",
|
|
80
|
-
"extract-pdf": "^0.1.
|
|
81
|
-
"extract-youtube": "^1.0.
|
|
80
|
+
"extract-pdf": "^0.1.352",
|
|
81
|
+
"extract-youtube": "^1.0.356",
|
|
82
82
|
"html-entities": "^2.6.0",
|
|
83
83
|
"js-yaml": "^5.4.1",
|
|
84
84
|
"jsdom": "^30.0.1",
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module research/extractor/html-to-content/html-utils
|
|
3
|
+
* @description Research library module.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Converts URL-safe escaped HTML codes like &"'`’ & to standard HTML or in reverse.
|
|
7
|
+
* @param {string} str - The string to process.
|
|
8
|
+
* @param {boolean} toStandardHTML default=true - If true, converts url-safe codes
|
|
9
|
+
* to standard HTML. If false, converts standard HTML to url-safe codes.
|
|
10
|
+
* @return {string} The processed string.
|
|
11
|
+
* @category HTML Utilities
|
|
12
|
+
* @example
|
|
13
|
+
* var normalHTML = convertURLSafeHTMLToHTML('<p>This & that © 2023 '+
|
|
14
|
+
* '"Quotes"'Apostrophes' €100 ☺</p>', true)
|
|
15
|
+
* console.log(normalHTML) // "<p>This & that \u00a9 2023 "Quotes" 'Apostrophes' \u20ac100 \u263a</p>"
|
|
16
|
+
*/
|
|
17
|
+
export declare function convertURLSafeHTMLToHTML(str: any, toStandardHTML?: boolean): any;
|
|
18
|
+
/**
|
|
19
|
+
* Convert relative URL to absolute URL using base URL.
|
|
20
|
+
* @param {string} base base url of the domain
|
|
21
|
+
* @param {string} relative partial urls like ../images/image.jpg #hash
|
|
22
|
+
* @returns {string} absolute URL
|
|
23
|
+
* @example
|
|
24
|
+
* var absoluteURL = convertURLToAbsoluteURL('https://example.com', 'images/image.jpg')
|
|
25
|
+
* console.log(absoluteURL) // Returns: "https://example.com/images/image.jpg"
|
|
26
|
+
* var absoluteURL = convertURLToAbsoluteURL('https://example.com', '//images/image.jpg')
|
|
27
|
+
* console.log(absoluteURL) // Returns: "https:images/image.jpg"
|
|
28
|
+
* @category HTML Utilities
|
|
29
|
+
* @author [vtempest (2025)](https://github.com/vtempest)
|
|
30
|
+
*/
|
|
31
|
+
export declare function convertURLToAbsoluteURL(base: any, relative: any): any;
|
|
32
|
+
/**
|
|
33
|
+
* Converts Markdown text to HTML. It handles the following Markdown elements:
|
|
34
|
+
* - Headers (h1 to h6)
|
|
35
|
+
* - Bold text
|
|
36
|
+
* - Italic text
|
|
37
|
+
* - Unordered lists
|
|
38
|
+
* - Ordered lists
|
|
39
|
+
* - Paragraphs
|
|
40
|
+
* - Images
|
|
41
|
+
* - Links
|
|
42
|
+
* - Code blocks
|
|
43
|
+
* @param {string} content - The Markdown or HTML content to be converted.
|
|
44
|
+
* @param {boolean} toHtml - default=true - If true, converts Markdown to HTML.
|
|
45
|
+
* If false, converts HTML to Markdown.
|
|
46
|
+
* @returns {string} The resulting HTML string.
|
|
47
|
+
* @category HTML Utilities
|
|
48
|
+
* @example
|
|
49
|
+
* const markdown = "# Header\n\nThis is **bold** and *italic* text.\n\n* List item 1\n* List item 2";
|
|
50
|
+
* const html = convertMarkdownToHTML(markdown);
|
|
51
|
+
* console.log(html);
|
|
52
|
+
* // Output:
|
|
53
|
+
* // <h1>Header</h1>
|
|
54
|
+
* // <p>This is <strong>bold</strong> and <em>italic</em> text.</p>
|
|
55
|
+
* // <ul><li>List item 1</li><li>List item 2</li></ul>
|
|
56
|
+
*/
|
|
57
|
+
export declare function convertMarkdownToHTML(content: any, toHtml?: boolean): any;
|
|
58
|
+
/**
|
|
59
|
+
* Detect whether a string is Markdown (rather than HTML or plain text) using
|
|
60
|
+
* regexp checks. Content that is dominated by HTML tags is never treated as
|
|
61
|
+
* Markdown, so real scraped pages pass through untouched; text needs at least
|
|
62
|
+
* two distinct Markdown syntax signals (or several links/images in Markdown
|
|
63
|
+
* form) to qualify. Used to catch scraper responses (e.g. the JINA reader or
|
|
64
|
+
* proxies wrapping it) that return Markdown in place of HTML, so it can be
|
|
65
|
+
* converted before main-content extraction — otherwise the article panel
|
|
66
|
+
* renders raw `[text](url)` syntax.
|
|
67
|
+
*
|
|
68
|
+
* @param {string} text - The content to test.
|
|
69
|
+
* @returns {boolean} True when the content should be parsed as Markdown.
|
|
70
|
+
* @category HTML Utilities
|
|
71
|
+
* @example
|
|
72
|
+
* detectMarkdown("# Title\n\nSome **bold** text.") // true
|
|
73
|
+
* detectMarkdown("<html><body><p>Hi</p></body></html>") // false
|
|
74
|
+
*/
|
|
75
|
+
export declare function detectMarkdown(text: any): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Remove extra non-article content from a Markdown extraction using regexp
|
|
78
|
+
* checks: JINA reader metadata lines, cookie/consent and navigation phrases,
|
|
79
|
+
* and runs of consecutive link-only lines (menus, breadcrumbs, "related"
|
|
80
|
+
* link farms) whose targets are mostly relative site navigation. Standalone
|
|
81
|
+
* links inside prose are kept.
|
|
82
|
+
*
|
|
83
|
+
* @param {string} markdown - The Markdown content to clean.
|
|
84
|
+
* @returns {string} The cleaned Markdown.
|
|
85
|
+
* @category HTML Utilities
|
|
86
|
+
* @example
|
|
87
|
+
* removeMarkdownNavigation("Title: Page\n[Skip to content](#main)\nReal text")
|
|
88
|
+
* // => "Real text"
|
|
89
|
+
*/
|
|
90
|
+
export declare function removeMarkdownNavigation(markdown: any): string;
|
|
91
|
+
/**
|
|
92
|
+
* Convert a Markdown document to formatted HTML using regular expressions to
|
|
93
|
+
* detect Markdown syntax. Unlike {@link convertMarkdownToHTML} (which relies on
|
|
94
|
+
* the `marked` library), this is a dependency-free, self-contained converter
|
|
95
|
+
* intended for post-processing content returned as Markdown (e.g. from the
|
|
96
|
+
* JINA reader fallback in the scraper).
|
|
97
|
+
*
|
|
98
|
+
* Supported block elements: ATX headers (`#`..`######`), setext headers
|
|
99
|
+
* (`===`/`---` underlines), fenced code blocks (```lang), blockquotes (`>`),
|
|
100
|
+
* unordered lists (`-`, `*`, `+`), ordered lists (`1.`, `1)`), pipe tables,
|
|
101
|
+
* horizontal rules (`---`, `***`, `___`) and paragraphs.
|
|
102
|
+
* Supported inline elements: bold, italic, strikethrough, inline code, images,
|
|
103
|
+
* links, linked images (`[](href)`) and autolinks (`<https://…>`).
|
|
104
|
+
*
|
|
105
|
+
* @param {string} markdown - The Markdown content to convert.
|
|
106
|
+
* @returns {string} The resulting formatted HTML string.
|
|
107
|
+
* @category HTML Utilities
|
|
108
|
+
* @example
|
|
109
|
+
* convertMarkdownToFormattedHTML("# Title\n\nSome **bold** text.");
|
|
110
|
+
* // => "<h1>Title</h1>\n<p>Some <strong>bold</strong> text.</p>"
|
|
111
|
+
*/
|
|
112
|
+
export declare function convertMarkdownToFormattedHTML(markdown: any): string;
|
|
113
|
+
export declare function convertHTMLToMarkdown(html: any): any;
|
|
114
|
+
/**
|
|
115
|
+
* Copy HTML to clipboard. When pasting into rich text field,
|
|
116
|
+
* pastes rich text. When pasting into plain text field, pastes:
|
|
117
|
+
* plain text, html, or markdown.
|
|
118
|
+
*
|
|
119
|
+
* @param {string} html - The HTML content to be copied.
|
|
120
|
+
* @param {object} options - The options object.
|
|
121
|
+
* @param {number} options.pastePlainFormat -
|
|
122
|
+
* default=0
|
|
123
|
+
* 0 - plain text
|
|
124
|
+
* 1 - markdown
|
|
125
|
+
* 2 - html
|
|
126
|
+
* @returns {Promise<void>} - A promise that resolves when
|
|
127
|
+
* the HTML is copied to the clipboard.
|
|
128
|
+
* @category HTML Utilities
|
|
129
|
+
* @author [vtempest (2025)](https://github.com/vtempest)
|
|
130
|
+
*/
|
|
131
|
+
export declare function copyHTMLToClipboard(html: any, options?: {}): Promise<void>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module html-to-content/prism-global
|
|
3
|
+
* @description Owns the Prism instance: publishes it on `globalThis`, then
|
|
4
|
+
* registers the language grammars that prismjs' own entry point leaves out —
|
|
5
|
+
* without ever depending on module evaluation order.
|
|
6
|
+
*
|
|
7
|
+
* The `prismjs/components/*` files are plain browser scripts, not modules:
|
|
8
|
+
* `prism-markup.js` literally opens with `Prism.languages.markup = {...}`,
|
|
9
|
+
* resolving `Prism` as a free variable off the global object. Someone has to
|
|
10
|
+
* put it there first. prismjs' own entry point does that for `window`
|
|
11
|
+
* (browser) and `global` (Node); on Cloudflare Workers / edge runtimes it sees
|
|
12
|
+
* neither, which is what the assignment below is for.
|
|
13
|
+
*
|
|
14
|
+
* Publishing it is only half the job, though: it has to happen *before* the
|
|
15
|
+
* grammar scripts run, and a static `import "prismjs/components/..."` cannot
|
|
16
|
+
* promise that once a bundler is in the loop. Those files declare no
|
|
17
|
+
* dependency on Prism — reading a global is invisible to the module graph — so
|
|
18
|
+
* nothing pins them after whoever publishes it, and a bundler is free to hoist
|
|
19
|
+
* them, split them into another chunk, or drop the publishing statement as a
|
|
20
|
+
* dead `globalThis` write. When that happens the chunk dies on load with
|
|
21
|
+
* `ReferenceError: Prism is not defined`, which takes down the whole route
|
|
22
|
+
* that lazily imported it rather than just the syntax highlighting.
|
|
23
|
+
*
|
|
24
|
+
* So the grammars are loaded with `import()` from inside `loadPrismGrammars()`
|
|
25
|
+
* instead. The global is published by a statement earlier in that same
|
|
26
|
+
* function body, which makes the ordering a runtime fact rather than a promise
|
|
27
|
+
* the bundler has to keep.
|
|
28
|
+
*/
|
|
29
|
+
import Prism from "prismjs";
|
|
30
|
+
/**
|
|
31
|
+
* Registers the grammars above, once per runtime. Cheap to call repeatedly —
|
|
32
|
+
* callers are meant to invoke it wherever they are about to highlight, so that
|
|
33
|
+
* the work does not hinge on a module-level statement surviving tree-shaking.
|
|
34
|
+
*
|
|
35
|
+
* Never rejects: a grammar that fails to load just leaves its language out of
|
|
36
|
+
* `Prism.languages`, which every caller already treats as "render this block
|
|
37
|
+
* unhighlighted".
|
|
38
|
+
*/
|
|
39
|
+
export declare function loadPrismGrammars(): Promise<void>;
|
|
40
|
+
export default Prism;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provides search query autocomplete/suggestions from various search engines.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Autocomplete function type
|
|
6
|
+
*/
|
|
7
|
+
type AutocompleteFunction = (query: string, locale?: string) => Promise<string[]>;
|
|
8
|
+
/**
|
|
9
|
+
* Baidu autocomplete
|
|
10
|
+
*/
|
|
11
|
+
export declare function baidu(query: string, _locale?: string): Promise<string[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Brave autocomplete
|
|
14
|
+
*/
|
|
15
|
+
export declare function brave(query: string, _locale?: string): Promise<string[]>;
|
|
16
|
+
/**
|
|
17
|
+
* DuckDuckGo autocomplete
|
|
18
|
+
*/
|
|
19
|
+
export declare function duckduckgo(query: string, locale?: string): Promise<string[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Google autocomplete
|
|
22
|
+
*/
|
|
23
|
+
export declare function google(query: string, locale?: string): Promise<string[]>;
|
|
24
|
+
/**
|
|
25
|
+
* Qwant autocomplete
|
|
26
|
+
*/
|
|
27
|
+
export declare function qwant(query: string, locale?: string): Promise<string[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Startpage autocomplete
|
|
30
|
+
*/
|
|
31
|
+
export declare function startpage(query: string, locale?: string): Promise<string[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Wikipedia autocomplete
|
|
34
|
+
*/
|
|
35
|
+
export declare function wikipedia(query: string, locale?: string): Promise<string[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Yandex autocomplete
|
|
38
|
+
*/
|
|
39
|
+
export declare function yandex(query: string, _locale?: string): Promise<string[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Available autocomplete backends
|
|
42
|
+
*/
|
|
43
|
+
export declare const backends: {
|
|
44
|
+
[key: string]: AutocompleteFunction;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Get autocomplete suggestions from a specific backend
|
|
48
|
+
*
|
|
49
|
+
* @param backendName - Name of the autocomplete backend
|
|
50
|
+
* @param query - Search query
|
|
51
|
+
* @param locale - Locale/language code (e.g., 'en-US', 'de-DE')
|
|
52
|
+
* @returns Array of suggestion strings
|
|
53
|
+
*/
|
|
54
|
+
export declare function searchAutocomplete(backendName: string, query: string, locale?: string): Promise<string[]>;
|
|
55
|
+
/**
|
|
56
|
+
* Get autocomplete suggestions from multiple backends and merge them
|
|
57
|
+
*
|
|
58
|
+
* @param backendNames - Array of backend names to query
|
|
59
|
+
* @param query - Search query
|
|
60
|
+
* @param locale - Locale/language code
|
|
61
|
+
* @returns Merged and deduplicated array of suggestions
|
|
62
|
+
*/
|
|
63
|
+
export declare function searchAutocompleteMulti(backendNames: string[], query: string, locale?: string): Promise<string[]>;
|
|
64
|
+
export {};
|