From 9ea403fda7fc3cf1ca5b6e34b34a8fc2032066d6 Mon Sep 17 00:00:00 2001 From: likang Date: Wed, 10 Jan 2024 11:20:54 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[Issues:=20#I8UZTP]=20=E6=B7=BB=E5=8A=A0par?= =?UTF-8?q?se5=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1224/parse5.md | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 1224/parse5.md diff --git a/1224/parse5.md b/1224/parse5.md new file mode 100644 index 00000000..26495d85 --- /dev/null +++ b/1224/parse5.md @@ -0,0 +1,93 @@ +> 模板版本:v0.1.2 + +

+

parse5

+

+

+ + License + +

+ +>[!tip] [Github 地址](https://github.com/inikulin/parse5) + + +## 安装与使用 + +进入到工程目录并输入以下命令: + +#### **yarn** + +```bash +yarn add parse5@7.1.2 +``` + + +#### **npm** + +```bash +npm install parse5@7.1.2 +``` + + + +下面的代码展示了这个库的基本使用场景: + +```js +const parse5 = require('parse5'); + +// parse +const document = parse5.parse('Hi there!'); +console.log(document.childNodes[1].tagName); //> 'html' + +// parseFragment +const documentFragment = parse5.parseFragment('
'); +console.log(documentFragment.childNodes[0].tagName); //> 'table' +const trFragment = parse5.parseFragment(documentFragment.childNodes[0], 'Shake it, baby'); +console.log(trFragment.childNodes[0].childNodes[0].tagName); //> 'td' + +// serialize +const document = parse5.parse('Hi there!'); +// Serializes a document. +const html = parse5.serialize(document); +// Serializes the element content. +const str = parse5.serialize(document.childNodes[1]); +console.log(str); //> 'Hi there!' + +// serializeOuter +const document = parse5.parseFragment('
Hello, world!
'); +// Serializes the
element. +const str = parse5.serializeOuter(document.childNodes[0]); +console.log(str); //> '
Hello, world!
' +``` + +## 约束与限制 + +### 兼容性 + + 在下述版本验证通过: + + 1. IDE:DevEco Studio 4.1.3.313;SDK:OpenHarmony(api11) 4.1.0.52;测试设备:Mate40 Pro(NOH-AN00);ROM:204.1.0.52(C00E52R1P17log);RNOH:0.72.11 + +## API + +> [!tip] "Platform"列表示该属性在原三方库上支持的平台。 + +> [!tip] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。 + +详情见 [parse5文档地址](https://parse5.js.org/index.html) + +| Name | Description | Type | Required | Platform | HarmonyOS Support | +| ---------------------------------------------- | ----------------------------------------------------------------------------- | -------- | -------- | -------- | ----------------- | +| parse(html, options?) | Parses an HTML string. | function | no | / | yes | +| parseFragment(fragmentContext, html, options?) | Parses an HTML fragment. | function | no | / | yes | +| serialize(node, options?) | Serializes an AST node to an HTML string. | function | no | / | yes | +| serializeOuter(node, options?) | Serializes an AST element node to an HTML string, including the element node. | function | no | / | yes | + +## 遗留问题 + +## 其他 + +## 开源协议 + +本项目基于 [The MIT License (MIT)](https://github.com/inikulin/parse5/blob/master/LICENSE) ,请自由地享受和参与开源。 -- Gitee From 582a0e077f36414e0f7a091bd945fe684cfdf334 Mon Sep 17 00:00:00 2001 From: likang Date: Wed, 10 Jan 2024 14:36:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[Issues:=20#I8UZTP]=20=E6=9B=B4=E6=96=B0par?= =?UTF-8?q?se5=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 1224/parse5.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/1224/parse5.md b/1224/parse5.md index 26495d85..ee7d0438 100644 --- a/1224/parse5.md +++ b/1224/parse5.md @@ -77,12 +77,12 @@ console.log(str); //> '
Hello, world!
' 详情见 [parse5文档地址](https://parse5.js.org/index.html) -| Name | Description | Type | Required | Platform | HarmonyOS Support | -| ---------------------------------------------- | ----------------------------------------------------------------------------- | -------- | -------- | -------- | ----------------- | -| parse(html, options?) | Parses an HTML string. | function | no | / | yes | -| parseFragment(fragmentContext, html, options?) | Parses an HTML fragment. | function | no | / | yes | -| serialize(node, options?) | Serializes an AST node to an HTML string. | function | no | / | yes | -| serializeOuter(node, options?) | Serializes an AST element node to an HTML string, including the element node. | function | no | / | yes | +| Name | Description | Type | Required | HarmonyOS Support | +| ---------------------------------------------- | ----------------------------------------------------------------------------- | -------- | -------- | ----------------- | +| parse(html, options?) | Parses an HTML string. | function | no | yes | +| parseFragment(fragmentContext, html, options?) | Parses an HTML fragment. | function | no | yes | +| serialize(node, options?) | Serializes an AST node to an HTML string. | function | no | yes | +| serializeOuter(node, options?) | Serializes an AST element node to an HTML string, including the element node. | function | no | yes | ## 遗留问题 -- Gitee