Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Sharcoux/node-html-parser
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.4.7
Choose a base ref
...
head repository: Sharcoux/node-html-parser
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.4.8
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Mar 20, 2025

  1. Copy the full SHA
    c4a8208 View commit details
  2. Release 1.4.8

    Sharcoux committed Mar 20, 2025
    Copy the full SHA
    8fc94ba View commit details
Showing with 15 additions and 5 deletions.
  1. +2 −2 package-lock.json
  2. +2 −2 package.json
  3. +1 −1 src/index.ts
  4. +10 −0 test/html.ts
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-html-better-parser",
"version": "1.4.7",
"version": "1.4.8",
"description": "A very fast HTML parser, generating a simplified DOM, with basic element query support.",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
@@ -9,7 +9,7 @@
"clean": "del-cli ./dist/",
"ts:cjs": "tsc -m commonjs",
"ts:umd": "tsc -t es5 -m umd -d false --outDir ./dist/umd/",
"build": "npm run clean && npm run ts:cjs && npm run ts:umd",
"build": "npm run test && npm run clean && npm run ts:cjs && npm run ts:umd",
"dev": "tsc -w",
"prepare": "npm run build",
"release": "release-it",
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -825,7 +825,7 @@ export class Matcher {
}

// https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
const kMarkupPattern = /<!--[^]*?(?=-->)-->|<(\/?)([a-z][-.:0-9_a-z]*)((\s+[a-z][-.:0-9_a-z]*(\s*=\s*("[^"]*"|'([^']*')|([^\s\/>]+)))?)*)\s*(\/?)>/ig;
const kMarkupPattern = /<!--[^]*?(?=-->)-->|<(\/?)([a-z][-.:0-9_a-z]*)((?:\s+[a-z][-.:0-9_a-z]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s\/>]+))?|\s+[^<>\s/]*?)*)\s*(\/?)>/ig;
const kIdClassAttributePattern = /(^|\s)(id|class)\s*=\s*("([^"]+)"|'([^']+)'|(\S+))/ig;
const kAttributePattern = /([a-z][-.:0-9_a-z]*)(\s*=\s*("([^"]*)"|'([^']*)'|(\S+)))?/ig
const kSelfClosingElements = {
10 changes: 10 additions & 0 deletions test/html.ts
Original file line number Diff line number Diff line change
@@ -241,6 +241,16 @@ describe('HTML Parser', function () {
child.attributes.attr.should.eql(">")
})

it('should parse malformed attributes : <span id="tree-title-end" class="editable" "=""></span>', function () {
const root = parse("<span id='tree-title-end' ;=\"\" test='a' \"random text\" 'more text' \"=\"\" '=' class='editable'></span>")
const child = root.firstChild as HTMLElement
child.tagName.should.eql("span")
child.attributes.id.should.eql("tree-title-end")
child.attributes.class.should.eql("editable")
child.attributes['class'].should.eql("editable")
child.attributes['id'].should.eql("tree-title-end")
})

});

describe('parseWithValidation', function () {