webforai 1.2.0 → 1.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.
Files changed (3) hide show
  1. package/README.md +74 -74
  2. package/package.json +118 -118
  3. package/LICENSE +0 -21
package/README.md CHANGED
@@ -1,74 +1,74 @@
1
- # Web for AI
2
-
3
- ![LOGO](https://github.com/inaridiy/webforai/blob/main/images/logo.webp)
4
-
5
- A library that provides a web interface for AI
6
-
7
- ## Features
8
-
9
- - Ultra-precise HTML2Markdown conversion
10
- - Ultra-precise Markdown segmentation based on AST
11
- - Ultra-precise HTML retrieval functions using headless browsers
12
- - The core functionality is edge-native (runs on Cloudflare Workers!!!)
13
-
14
- ## Demo
15
-
16
- There is a demo API for Html2Markdown deployed on CloudflareWorker. Please access the following link
17
-
18
- - [https://webforai.inaridiy.workers.dev/?url=https://www.npmjs.com/package/webforai](https://webforai.inaridiy.workers.dev/?url=https://www.npmjs.com/package/webforai)
19
- - [https://webforai.inaridiy.workers.dev/?html=%3Ch1%3EHello%20World%3C/h1%3E](https://webforai.inaridiy.workers.dev/?html=%3Ch1%3EHello%20World%3C/h1%3E)
20
-
21
- ## Quick Start
22
-
23
- Just install and execute scripts
24
-
25
- ```bash
26
- pnpm i webforai playwright
27
- ```
28
-
29
- ```js
30
- import { promises as fs } from "fs";
31
- import { htmlToMarkdown, htmlToMdast } from "webforai";
32
- import { loadHtml } from "webforai/loaders/playwright";
33
-
34
- const url = "https://www.npmjs.com/package/webforai";
35
- const html = await loadHtml(url);
36
-
37
- const markdown = htmlToMarkdown(html, { solveLinks: url });
38
-
39
- await fs.writeFile("output.md", markdown);
40
- ```
41
-
42
- other examples are in [examples](./examples/simple/src/index.ts)
43
-
44
- ## Usage
45
-
46
- ### Main Functions
47
-
48
- **`htmlToMarkdown(html: string, options?: HtmlToMarkdownOptions): string`**
49
- Convert HTML to Markdown. By default, unnecessary HTML is excluded and processed.
50
- If `solveLinks` is specified, the relative links in the Mdast will be resolved.
51
- This function just calls htmlToMdast and mdastToMarkdown in that order internally.
52
-
53
- **`htmlToMdast(html: string, options?: HtmlToMdastOptions): Mdast`**
54
- This project uses Hast and Mdast as defined by syntax-tree internally.
55
- This function converts HTML to Mdast, an intermediate representation, which is required when using `mdastSplitter`, etc.
56
-
57
- **`mdastToMarkdown(mdast: Mdast | RootContent[], options?: { solveLinks?: string }): string`**
58
- Convert Mdast to Markdown. If `solveLinks` is specified, the relative links in the Mdast will be resolved.
59
-
60
- ### Loader Functions
61
-
62
- **`loadHtml(url: string, options?: LoadHtmlOptions): Promise<string>`**
63
- Load HTML from the specified URL. This function uses Playwright internally.
64
-
65
- ## Early Users
66
-
67
- ### Voice Genius - Explanatory video generation by AI
68
-
69
- <img src="https://github.com/inaridiy/webforai/blob/main/images/voice-genius.png" width="300px">
70
-
71
- by [@moons14](https://twitter.com/moons_dev)
72
-
73
- AI can be used to automatically generate highly accurate commentary videos.
74
- Supports conversations and presentations using synthesized voice, embedding of images in videos, etc.
1
+ # Web for AI
2
+
3
+ ![LOGO](https://github.com/inaridiy/webforai/blob/main/images/logo.webp)
4
+
5
+ A library that provides a web interface for AI
6
+
7
+ ## Features
8
+
9
+ - Ultra-precise HTML2Markdown conversion
10
+ - Ultra-precise Markdown segmentation based on AST
11
+ - Ultra-precise HTML retrieval functions using headless browsers
12
+ - The core functionality is edge-native (runs on Cloudflare Workers!!!)
13
+
14
+ ## Demo
15
+
16
+ There is a demo API for Html2Markdown deployed on CloudflareWorker. Please access the following link
17
+
18
+ - [https://webforai.inaridiy.workers.dev/?url=https://www.npmjs.com/package/webforai](https://webforai.inaridiy.workers.dev/?url=https://www.npmjs.com/package/webforai)
19
+ - [https://webforai.inaridiy.workers.dev/?html=%3Ch1%3EHello%20World%3C/h1%3E](https://webforai.inaridiy.workers.dev/?html=%3Ch1%3EHello%20World%3C/h1%3E)
20
+
21
+ ## Quick Start
22
+
23
+ Just install and execute scripts
24
+
25
+ ```bash
26
+ pnpm i webforai playwright
27
+ ```
28
+
29
+ ```js
30
+ import { promises as fs } from "fs";
31
+ import { htmlToMarkdown, htmlToMdast } from "webforai";
32
+ import { loadHtml } from "webforai/loaders/playwright";
33
+
34
+ const url = "https://www.npmjs.com/package/webforai";
35
+ const html = await loadHtml(url);
36
+
37
+ const markdown = htmlToMarkdown(html, { solveLinks: url });
38
+
39
+ await fs.writeFile("output.md", markdown);
40
+ ```
41
+
42
+ other examples are in [examples](./examples/simple/src/index.ts)
43
+
44
+ ## Usage
45
+
46
+ ### Main Functions
47
+
48
+ **`htmlToMarkdown(html: string, options?: HtmlToMarkdownOptions): string`**
49
+ Convert HTML to Markdown. By default, unnecessary HTML is excluded and processed.
50
+ If `solveLinks` is specified, the relative links in the Mdast will be resolved.
51
+ This function just calls htmlToMdast and mdastToMarkdown in that order internally.
52
+
53
+ **`htmlToMdast(html: string, options?: HtmlToMdastOptions): Mdast`**
54
+ This project uses Hast and Mdast as defined by syntax-tree internally.
55
+ This function converts HTML to Mdast, an intermediate representation, which is required when using `mdastSplitter`, etc.
56
+
57
+ **`mdastToMarkdown(mdast: Mdast | RootContent[], options?: { solveLinks?: string }): string`**
58
+ Convert Mdast to Markdown. If `solveLinks` is specified, the relative links in the Mdast will be resolved.
59
+
60
+ ### Loader Functions
61
+
62
+ **`loadHtml(url: string, options?: LoadHtmlOptions): Promise<string>`**
63
+ Load HTML from the specified URL. This function uses Playwright internally.
64
+
65
+ ## Early Users
66
+
67
+ ### Voice Genius - Explanatory video generation by AI
68
+
69
+ <img src="https://github.com/inaridiy/webforai/blob/main/images/voice-genius.png" width="300px">
70
+
71
+ by [@moons14](https://twitter.com/moons_dev)
72
+
73
+ AI can be used to automatically generate highly accurate commentary videos.
74
+ Supports conversations and presentations using synthesized voice, embedding of images in videos, etc.
package/package.json CHANGED
@@ -1,118 +1,118 @@
1
- {
2
- "name": "webforai",
3
- "version": "1.2.0",
4
- "description": "A library that provides a web interface for AI",
5
- "author": "inaridiy",
6
- "license": "MIT",
7
- "keywords": [
8
- "web",
9
- "ai",
10
- "html",
11
- "html2md",
12
- "markdown",
13
- "mdast",
14
- "hast"
15
- ],
16
- "repository": {
17
- "type": "git",
18
- "url": "https://github.com/inaridiy/webforai.git"
19
- },
20
- "homepage": "https://github.com/inaridiy/webforai.git",
21
- "files": [
22
- "dist",
23
- "!dist/types/**/*.js"
24
- ],
25
- "main": "dist/cjs/index.js",
26
- "type": "module",
27
- "module": "dist/index.js",
28
- "types": "dist/types/index.d.ts",
29
- "exports": {
30
- ".": {
31
- "types": "./dist/types/index.d.ts",
32
- "import": "./dist/index.js",
33
- "require": "./dist/cjs/index.js"
34
- },
35
- "./types": {
36
- "types": "./dist/types/index.d.ts",
37
- "import": "./dist/index.js",
38
- "require": "./dist/cjs/index.js"
39
- },
40
- "./loaders/playwright": {
41
- "types": "./dist/types/loaders/playwright.d.ts",
42
- "import": "./dist/loaders/playwright.js",
43
- "require": "./dist/cjs/loaders/playwright.js"
44
- },
45
- "./loaders/cf-puppeteer": {
46
- "types": "./dist/types/loaders/cf-puppeteer.d.ts",
47
- "import": "./dist/loaders/cf-puppeteer.js",
48
- "require": "./dist/cjs/loaders/cf-puppeteer.js"
49
- }
50
- },
51
- "typesVersions": {
52
- "*": {
53
- "types": [
54
- "./dist/types/index.d.ts"
55
- ],
56
- "loaders/playwright": [
57
- "./dist/types/loaders/playwright.d.ts"
58
- ],
59
- "loaders/cf-puppeteer": [
60
- "./dist/types/loaders/cf-puppeteer.d.ts"
61
- ]
62
- }
63
- },
64
- "peerDependencies": {
65
- "@cloudflare/puppeteer": "^0.0.6",
66
- "playwright": "^1.0.0"
67
- },
68
- "peerDependenciesMeta": {
69
- "playwright": {
70
- "optional": true
71
- },
72
- "@cloudflare/puppeteer": {
73
- "optional": true
74
- }
75
- },
76
- "dependencies": {
77
- "hast-util-from-html": "^2.0.1",
78
- "hast-util-select": "^6.0.1",
79
- "hast-util-to-html": "^9.0.0",
80
- "hast-util-to-mdast": "^10.1.0",
81
- "hast-util-to-string": "^3.0.0",
82
- "hast-util-to-text": "^4.0.0",
83
- "mathml-to-latex": "^1.3.0",
84
- "mdast-util-gfm": "^3.0.0",
85
- "mdast-util-math": "^3.0.0",
86
- "mdast-util-to-markdown": "^2.1.0",
87
- "trim-trailing-lines": "^2.1.0",
88
- "unist-util-filter": "^5.0.1",
89
- "unist-util-parents": "^3.0.0",
90
- "unist-util-remove": "^4.0.0",
91
- "unist-util-visit": "^5.0.0",
92
- "unist-util-visit-parents": "^6.0.1"
93
- },
94
- "devDependencies": {
95
- "@cloudflare/puppeteer": "^0.0.6",
96
- "@tsconfig/recommended": "^1.0.3",
97
- "@types/hast": "^3.0.2",
98
- "@types/mdast": "^4.0.2",
99
- "@types/node": "^20.11.0",
100
- "arg": "^5.0.2",
101
- "esbuild": "^0.19.11",
102
- "glob": "^10.3.10",
103
- "ncp": "^2.0.0",
104
- "np": "^9.2.0",
105
- "playwright": "^1.40.1",
106
- "rimraf": "^5.0.5",
107
- "tsx": "^4.7.0",
108
- "typescript": "^5.2.2"
109
- },
110
- "scripts": {
111
- "copy:package.cjs.json": "pnpm ncp ./package.cjs.json ./dist/cjs/package.json && pnpm ncp ./package.cjs.json ./dist/types/package.json ",
112
- "clean": "rimraf dist",
113
- "build": "pnpm clean && tsx ./build.ts && pnpm copy:package.cjs.json",
114
- "test": "echo \"Error: no test specified\"",
115
- "prerelease": "pnpm build",
116
- "release": "np"
117
- }
118
- }
1
+ {
2
+ "name": "webforai",
3
+ "version": "1.2.2",
4
+ "description": "A library that provides a web interface for AI",
5
+ "author": "inaridiy",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "web",
9
+ "ai",
10
+ "html",
11
+ "html2md",
12
+ "markdown",
13
+ "mdast",
14
+ "hast"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/inaridiy/webforai.git"
19
+ },
20
+ "homepage": "https://github.com/inaridiy/webforai.git",
21
+ "scripts": {
22
+ "copy:package.cjs.json": "pnpm ncp ./package.cjs.json ./dist/cjs/package.json && pnpm ncp ./package.cjs.json ./dist/types/package.json ",
23
+ "clean": "rimraf dist",
24
+ "build": "pnpm clean && tsx ./build.ts && pnpm copy:package.cjs.json",
25
+ "test": "echo \"Error: no test specified\"",
26
+ "prerelease": "pnpm build",
27
+ "release": "np"
28
+ },
29
+ "files": [
30
+ "dist",
31
+ "!dist/types/**/*.js"
32
+ ],
33
+ "main": "dist/cjs/index.js",
34
+ "type": "module",
35
+ "module": "dist/index.js",
36
+ "types": "dist/types/index.d.ts",
37
+ "exports": {
38
+ ".": {
39
+ "types": "./dist/types/index.d.ts",
40
+ "import": "./dist/index.js",
41
+ "require": "./dist/cjs/index.js"
42
+ },
43
+ "./types": {
44
+ "types": "./dist/types/index.d.ts",
45
+ "import": "./dist/index.js",
46
+ "require": "./dist/cjs/index.js"
47
+ },
48
+ "./loaders/playwright": {
49
+ "types": "./dist/types/loaders/playwright.d.ts",
50
+ "import": "./dist/loaders/playwright.js",
51
+ "require": "./dist/cjs/loaders/playwright.js"
52
+ },
53
+ "./loaders/cf-puppeteer": {
54
+ "types": "./dist/types/loaders/cf-puppeteer.d.ts",
55
+ "import": "./dist/loaders/cf-puppeteer.js",
56
+ "require": "./dist/cjs/loaders/cf-puppeteer.js"
57
+ }
58
+ },
59
+ "typesVersions": {
60
+ "*": {
61
+ "types": [
62
+ "./dist/types/index.d.ts"
63
+ ],
64
+ "loaders/playwright": [
65
+ "./dist/types/loaders/playwright.d.ts"
66
+ ],
67
+ "loaders/cf-puppeteer": [
68
+ "./dist/types/loaders/cf-puppeteer.d.ts"
69
+ ]
70
+ }
71
+ },
72
+ "peerDependencies": {
73
+ "@cloudflare/puppeteer": "^0.0.6",
74
+ "playwright": "^1.0.0"
75
+ },
76
+ "peerDependenciesMeta": {
77
+ "playwright": {
78
+ "optional": true
79
+ },
80
+ "@cloudflare/puppeteer": {
81
+ "optional": true
82
+ }
83
+ },
84
+ "dependencies": {
85
+ "hast-util-from-html": "^2.0.1",
86
+ "hast-util-select": "^6.0.1",
87
+ "hast-util-to-html": "^9.0.0",
88
+ "hast-util-to-mdast": "^10.1.0",
89
+ "hast-util-to-string": "^3.0.0",
90
+ "hast-util-to-text": "^4.0.0",
91
+ "mathml-to-latex": "^1.3.0",
92
+ "mdast-util-gfm": "^3.0.0",
93
+ "mdast-util-math": "^3.0.0",
94
+ "mdast-util-to-markdown": "^2.1.0",
95
+ "trim-trailing-lines": "^2.1.0",
96
+ "unist-util-filter": "^5.0.1",
97
+ "unist-util-parents": "^3.0.0",
98
+ "unist-util-remove": "^4.0.0",
99
+ "unist-util-visit": "^5.0.0",
100
+ "unist-util-visit-parents": "^6.0.1"
101
+ },
102
+ "devDependencies": {
103
+ "@cloudflare/puppeteer": "^0.0.6",
104
+ "@tsconfig/recommended": "^1.0.3",
105
+ "@types/hast": "^3.0.2",
106
+ "@types/mdast": "^4.0.2",
107
+ "@types/node": "^20.11.0",
108
+ "arg": "^5.0.2",
109
+ "esbuild": "^0.19.11",
110
+ "glob": "^10.3.10",
111
+ "ncp": "^2.0.0",
112
+ "np": "^9.2.0",
113
+ "playwright": "^1.40.1",
114
+ "rimraf": "^5.0.5",
115
+ "tsx": "^4.7.0",
116
+ "typescript": "^5.2.2"
117
+ }
118
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 inaridiy
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.