parse_html_to_node 0.0.1 → 0.0.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/README.md +11 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# parse_html
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/parse_html_to_node)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](https://www.typescriptlang.org/)
|
|
6
6
|
|
|
@@ -19,25 +19,25 @@
|
|
|
19
19
|
## 安装
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
npm install
|
|
22
|
+
npm install parse_html_to_node
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
或
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
yarn add
|
|
28
|
+
yarn add parse_html_to_node
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
或
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
|
-
pnpm add
|
|
34
|
+
pnpm add parse_html_to_node
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
## 快速开始
|
|
38
38
|
|
|
39
39
|
```javascript
|
|
40
|
-
import Node from '
|
|
40
|
+
import Node from 'parse_html_to_node';
|
|
41
41
|
|
|
42
42
|
// 解析单根HTML
|
|
43
43
|
const html = `
|
|
@@ -183,7 +183,7 @@ const htmlString = node.getHtml();
|
|
|
183
183
|
### 1. 多根节点解析
|
|
184
184
|
|
|
185
185
|
```javascript
|
|
186
|
-
import Node from '
|
|
186
|
+
import Node from 'parse_html_to_node';
|
|
187
187
|
|
|
188
188
|
const multiRootHtml = `
|
|
189
189
|
<p>第一段文本</p>
|
|
@@ -200,7 +200,7 @@ console.log(fragmentNode.getHtml()); // 输出拼接后的完整HTML
|
|
|
200
200
|
### 2. DOM操作
|
|
201
201
|
|
|
202
202
|
```javascript
|
|
203
|
-
import Node from '
|
|
203
|
+
import Node from 'parse_html_to_node';
|
|
204
204
|
|
|
205
205
|
const parent = new Node('<div id="parent"></div>');
|
|
206
206
|
|
|
@@ -219,7 +219,7 @@ console.log(parent.getHtml());
|
|
|
219
219
|
### 3. 属性和样式操作
|
|
220
220
|
|
|
221
221
|
```javascript
|
|
222
|
-
import Node from '
|
|
222
|
+
import Node from 'parse_html_to_node';
|
|
223
223
|
|
|
224
224
|
const node = new Node('<div>Test</div>');
|
|
225
225
|
|
|
@@ -247,7 +247,7 @@ console.log(node.getStyle('color')); // "green"
|
|
|
247
247
|
### 4. 文本节点处理
|
|
248
248
|
|
|
249
249
|
```javascript
|
|
250
|
-
import Node from '
|
|
250
|
+
import Node from 'parse_html_to_node';
|
|
251
251
|
|
|
252
252
|
const html = 'Hello <strong>World</strong>!';
|
|
253
253
|
const node = new Node(html);
|
|
@@ -283,7 +283,7 @@ pnpm run build
|
|
|
283
283
|
### 项目结构
|
|
284
284
|
|
|
285
285
|
```
|
|
286
|
-
|
|
286
|
+
parse_html_to_node/
|
|
287
287
|
├── lib/
|
|
288
288
|
│ └── index.ts # 源代码
|
|
289
289
|
├── dist/ # 构建输出
|
|
@@ -309,5 +309,5 @@ parse_html/
|
|
|
309
309
|
## 相关链接
|
|
310
310
|
|
|
311
311
|
- [GitHub仓库](https://github.com/Easy-Martin/parse_html)
|
|
312
|
-
- [npm包](https://www.npmjs.com/package/
|
|
312
|
+
- [npm包](https://www.npmjs.com/package/parse_html_to_node)
|
|
313
313
|
- [问题反馈](https://github.com/Easy-Martin/parse_html/issues)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "parse_html_to_node",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "This is an HTML string parsed into an object, which does not depend on a browser environment and can be used in any JavaScript runtime.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|