🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

node-html-parser

Package Overview
Dependencies
Maintainers
1
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-html-parser - npm Package Compare versions

Comparing version
8.0.1
to
8.0.2
+8
-0
CHANGELOG.md

@@ -5,2 +5,10 @@ # Changelog

### [8.0.2](https://github.com/taoqf/node-fast-html-parser/compare/v8.0.1...v8.0.2) (2026-06-21)
### Bug Fixes
* preserve backslashes in attribute values during serialization and round-trip parsing [#306](https://github.com/taoqf/node-fast-html-parser/issues/306) ([a9882b2](https://github.com/taoqf/node-fast-html-parser/commit/a9882b245d2a1e1adfe6b3a61d6f3fa3bfbb3e32))
* update casing of HTML tag names in usage example [#289](https://github.com/taoqf/node-fast-html-parser/issues/289) ([801d278](https://github.com/taoqf/node-fast-html-parser/commit/801d278d6b23c99b196461590dbbf3f60339a22d))
### [8.0.1](https://github.com/taoqf/node-fast-html-parser/compare/v8.0.0...v8.0.1) (2026-06-20)

@@ -7,0 +15,0 @@

+21
-13

@@ -106,6 +106,6 @@ "use strict";

return JSON.stringify(attr.replace(/"/g, '"'))
.replace(/\\t/g, '\t')
.replace(/\\n/g, '\n')
.replace(/\\r/g, '\r')
.replace(/\\/g, '');
.replace(/([^\\])\\t/g, '$1\t')
.replace(/([^\\])\\n/g, '$1\n')
.replace(/([^\\])\\r/g, '$1\r')
.replace(/([^\\])\\/g, '$1');
}

@@ -887,2 +887,3 @@ /**

const kMarkupPattern = /<!--[\s\S]*?-->|<(\/?)([a-zA-Z][-.:0-9_a-zA-Z@\xB7\xC0-\xD6\xD8-\xF6\u00F8-\u03A1\u03A3-\u03D9\u03DB-\u03EF\u03F7-\u03FF\u0400-\u04FF\u0500-\u052F\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E00-\u1E9B\u1F00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2126\u212A-\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA78E\uA790-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64-\uAB65\uFB00-\uFB06\uFB13-\uFB17\uFF21-\uFF3A\uFF41-\uFF5A\x37F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]*)((?:\s+[^>]*?(?:(?:'[^']*')|(?:"[^"]*"))?)*)\s*(\/?)>/gu;
const kMarkupPatternWithCDATA = /<!--[\s\S]*?-->|<!\[CDATA\[[\s\S]*?\]\]>|<(\/?)([a-zA-Z][-.:0-9_a-zA-Z@\xB7\xC0-\xD6\xD8-\xF6\u00F8-\u03A1\u03A3-\u03D9\u03DB-\u03EF\u03F7-\u03FF\u0400-\u04FF\u0500-\u052F\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E00-\u1E9B\u1F00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2126\u212A-\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA78E\uA790-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64-\uAB65\uFB00-\uFB06\uFB13-\uFB17\uFF21-\uFF3A\uFF41-\uFF5A\x37F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]*)((?:\s+[^>]*?(?:(?:'[^']*')|(?:"[^"]*"))?)*)\s*(\/?)>/gu;
// const kMarkupPattern = /<!--[\s\S]*?-->|<(\/?)([a-zA-Z][-.:0-9_a-zA-Z]*)((?:\s+[^>]*?(?:(?:'[^']*')|(?:"[^"]*"))?)*)\s*(\/?)>/g;

@@ -943,2 +944,4 @@ const kAttributePattern = /(?:^|\s)(id|class)\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+)/gi;

const voidTag = new void_tag_1.default((_a = options === null || options === void 0 ? void 0 : options.voidTag) === null || _a === void 0 ? void 0 : _a.closingSlash, (_b = options === null || options === void 0 ? void 0 : options.voidTag) === null || _b === void 0 ? void 0 : _b.tags);
const hasCDATA = data.includes('<![CDATA[');
const markupPattern = hasCDATA ? kMarkupPatternWithCDATA : kMarkupPattern;
const elements = options.blockTextElements || {

@@ -971,3 +974,4 @@ script: true,

const frameFlagOffset = frameflag.length + 2;
while ((match = kMarkupPattern.exec(data))) {
markupPattern.lastIndex = 0;
while ((match = markupPattern.exec(data))) {
// Note: Object destructuring here consistently tests as higher performance than array destructuring

@@ -977,4 +981,4 @@ // eslint-disable-next-line prefer-const

const matchLength = matchText.length;
const tagStartPos = kMarkupPattern.lastIndex - matchLength;
const tagEndPos = kMarkupPattern.lastIndex;
const tagStartPos = markupPattern.lastIndex - matchLength;
const tagEndPos = markupPattern.lastIndex;
// Add TextNode if content

@@ -987,3 +991,7 @@ if (lastTextPos > -1) {

}
lastTextPos = kMarkupPattern.lastIndex;
lastTextPos = markupPattern.lastIndex;
if (hasCDATA && matchText.startsWith('<![CDATA[')) {
currentParent.appendChild(new text_1.default(matchText, currentParent, createRange(tagStartPos, tagEndPos)));
continue;
}
// https://github.com/taoqf/node-html-parser/issues/38

@@ -1030,3 +1038,3 @@ // Skip frameflag node

}
const tagEndPos = kMarkupPattern.lastIndex;
const tagEndPos = markupPattern.lastIndex;
const tagStartPos = tagEndPos - matchLength;

@@ -1041,4 +1049,4 @@ currentParent = currentParent.appendChild(

const closeIndex = lowerCaseTagName
? data.toLocaleLowerCase().indexOf(closeMarkup, kMarkupPattern.lastIndex)
: data.indexOf(closeMarkup, kMarkupPattern.lastIndex);
? data.toLocaleLowerCase().indexOf(closeMarkup, markupPattern.lastIndex)
: data.indexOf(closeMarkup, markupPattern.lastIndex);
const textEndPos = closeIndex === -1 ? dataEndPos : closeIndex;

@@ -1052,6 +1060,6 @@ if (element_should_be_ignore(tagName)) {

if (closeIndex === -1) {
lastTextPos = kMarkupPattern.lastIndex = data.length + 1;
lastTextPos = markupPattern.lastIndex = data.length + 1;
}
else {
lastTextPos = kMarkupPattern.lastIndex = closeIndex + closeMarkup.length;
lastTextPos = markupPattern.lastIndex = closeIndex + closeMarkup.length;
// Cause to be treated as self-closing, because no close found

@@ -1058,0 +1066,0 @@ leadingSlash = '/';

{
"name": "node-html-parser",
"version": "8.0.1",
"version": "8.0.2",
"description": "A very fast HTML parser, generating a simplified DOM, with basic element query support.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -53,6 +53,6 @@ # Fast HTML Parser [![NPM version](https://badge.fury.io/js/node-html-parser.png)](http://badge.fury.io/js/node-html-parser) [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Ftaoqf%2Fnode-html-parser%2Fbadge%3Fref%3Dmain&style=flat)](https://actions-badge.atrox.dev/taoqf/node-html-parser/goto?ref=main)

console.log(root.querySelector('#list'));
// { tagName: 'ul',
// { tagName: 'UL',
// rawAttrs: 'id="list"',
// childNodes:
// [ { tagName: 'li',
// [ { tagName: 'LI',
// rawAttrs: '',

@@ -59,0 +59,0 @@ // childNodes: [Object],

Sorry, the diff of this file is too big to display