node-html-parser 6.1.8 → 6.1.10

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/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [6.1.10](https://github.com/taoqf/node-fast-html-parser/compare/v6.1.9...v6.1.10) (2023-09-15)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * [#242](https://github.com/taoqf/node-fast-html-parser/issues/242) ([36670f4](https://github.com/taoqf/node-fast-html-parser/commit/36670f4bb15f18b3cdfec0484f67c4cb891f1e79))
11
+ * [#251](https://github.com/taoqf/node-fast-html-parser/issues/251) ([42365de](https://github.com/taoqf/node-fast-html-parser/commit/42365dee6b28da5ab4017508b1ba15be503f001e))
12
+
13
+ ### [6.1.9](https://github.com/taoqf/node-fast-html-parser/compare/v6.1.8...v6.1.9) (2023-09-11)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * [#249](https://github.com/taoqf/node-fast-html-parser/issues/249) ([5a0a795](https://github.com/taoqf/node-fast-html-parser/commit/5a0a79573d51da9eccf6d13647413447eba413b1))
19
+ * test code for issue 249 ([799ee31](https://github.com/taoqf/node-fast-html-parser/commit/799ee31155a0635955b0a85e3d21ec4967223a25))
20
+
5
21
  ### [6.1.8](https://github.com/taoqf/node-fast-html-parser/compare/v6.1.7...v6.1.8) (2023-09-08)
6
22
 
7
23
 
package/README.md CHANGED
@@ -115,7 +115,7 @@ class HTMLElement{
115
115
  Node appendChild(Node node)
116
116
  this insertAdjacentHTML('beforebegin' | 'afterbegin' | 'beforeend' | 'afterend' where, string html)
117
117
  this setAttribute(string key, string value)
118
- this setAttributes(Record~string, string~ attrs)
118
+ this setAttributes(Record string, string attrs)
119
119
  this removeAttribute(string key)
120
120
  string getAttribute(string key)
121
121
  this exchangeChild(Node oldNode, Node newNode)
@@ -143,7 +143,7 @@ class HTMLElement{
143
143
  string innerHTML
144
144
  string outerHTML
145
145
  string textContent
146
- Record~string, string~ attributes
146
+ Record<string, string> attributes
147
147
  [number, number] range
148
148
  }
149
149
  class Node{
package/dist/main.js CHANGED
@@ -591,6 +591,10 @@ define("nodes/html", ["require", "exports", "css-select", "he", "back", "matcher
591
591
  * @return {string} text content
592
592
  */
593
593
  get: function () {
594
+ // https://github.com/taoqf/node-html-parser/issues/249
595
+ if (/br/i.test(this.rawTagName)) {
596
+ return '\n';
597
+ }
594
598
  return this.childNodes.reduce(function (pre, cur) {
595
599
  return (pre += cur.rawText);
596
600
  }, '');
@@ -1351,11 +1355,9 @@ define("nodes/html", ["require", "exports", "css-select", "he", "back", "matcher
1351
1355
  style: true,
1352
1356
  pre: true,
1353
1357
  };
1354
- var element_names = Object.keys(elements).filter(function (name) {
1355
- return Boolean(elements[name]);
1356
- });
1358
+ var element_names = Object.keys(elements);
1357
1359
  var kBlockTextElements = element_names.map(function (it) { return new RegExp("^".concat(it, "$"), 'i'); });
1358
- var kIgnoreElements = element_names.filter(function (it) { return elements[it]; }).map(function (it) { return new RegExp("^".concat(it, "$"), 'i'); });
1360
+ var kIgnoreElements = element_names.filter(function (it) { return Boolean(elements[it]); }).map(function (it) { return new RegExp("^".concat(it, "$"), 'i'); });
1359
1361
  function element_should_be_ignore(tag) {
1360
1362
  return kIgnoreElements.some(function (it) { return it.test(tag); });
1361
1363
  }
@@ -257,6 +257,10 @@ var HTMLElement = /** @class */ (function (_super) {
257
257
  * @return {string} text content
258
258
  */
259
259
  get: function () {
260
+ // https://github.com/taoqf/node-html-parser/issues/249
261
+ if (/br/i.test(this.rawTagName)) {
262
+ return '\n';
263
+ }
260
264
  return this.childNodes.reduce(function (pre, cur) {
261
265
  return (pre += cur.rawText);
262
266
  }, '');
@@ -1017,11 +1021,9 @@ function base_parse(data, options) {
1017
1021
  style: true,
1018
1022
  pre: true,
1019
1023
  };
1020
- var element_names = Object.keys(elements).filter(function (name) {
1021
- return Boolean(elements[name]);
1022
- });
1024
+ var element_names = Object.keys(elements);
1023
1025
  var kBlockTextElements = element_names.map(function (it) { return new RegExp("^".concat(it, "$"), 'i'); });
1024
- var kIgnoreElements = element_names.filter(function (it) { return elements[it]; }).map(function (it) { return new RegExp("^".concat(it, "$"), 'i'); });
1026
+ var kIgnoreElements = element_names.filter(function (it) { return Boolean(elements[it]); }).map(function (it) { return new RegExp("^".concat(it, "$"), 'i'); });
1025
1027
  function element_should_be_ignore(tag) {
1026
1028
  return kIgnoreElements.some(function (it) { return it.test(tag); });
1027
1029
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-html-parser",
3
- "version": "6.1.8",
3
+ "version": "6.1.10",
4
4
  "description": "A very fast HTML parser, generating a simplified DOM, with basic element query support.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -60,6 +60,7 @@
60
60
  "@typescript-eslint/eslint-plugin-tslint": "latest",
61
61
  "@typescript-eslint/parser": "latest",
62
62
  "blanket": "latest",
63
+ "boolbase": "^1.0.0",
63
64
  "cheerio": "^1.0.0-rc.12",
64
65
  "cross-env": "^7.0.3",
65
66
  "eslint": "^8.23.1",