Gathering detailed insights and metrics for x-domhandler
Gathering detailed insights and metrics for x-domhandler
Gathering detailed insights and metrics for x-domhandler
Gathering detailed insights and metrics for x-domhandler
npm install x-domhandler
Typescript
Module System
Node Version
NPM Version
74.7
Supply Chain
98.9
Quality
74.8
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
464,100
Last Day
11
Last Week
322
Last Month
3,369
Last Year
62,895
1 Stars
89 Commits
2 Watching
3 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
2.4.2
Package Id
x-domhandler@2.4.2
Size
7.73 kB
NPM Version
6.2.0
Node Version
10.8.0
Publised On
19 Aug 2018
Cumulative downloads
Total Downloads
Last day
-93.3%
11
Compared to previous day
Last week
-68.5%
322
Compared to previous week
Last month
-13.3%
3,369
Compared to previous month
Last year
-36.3%
62,895
Compared to previous year
1
3
The DOM handler (formally known as DefaultHandler) creates a tree containing all nodes of a page. The tree may be manipulated using the domutils library.
selfClose
flag to node.singleQuoteAttribs
map to node.This project can work with stricter-htmlparser2.
1var handler = new DomHandler([ <func> callback(err, dom), ] [ <obj> options ]); 2// var parser = new Parser(handler[, options]);
Available options are described below.
1var htmlparser = require("htmlparser2"); 2var rawHtml = "Xyz <script language= 'javascript'>var foo = '<<bar>>';< / script><!--<!-- Waah! -- -->"; 3var handler = new htmlparser.DomHandler(function (error, dom) { 4 if (error) 5 [...do something for errors...] 6 else 7 [...parsing done, do something...] 8 console.log(dom); 9}); 10var parser = new htmlparser.Parser(handler); 11parser.write(rawHtml); 12parser.end();
Output:
1[{ 2 data: 'Xyz ', 3 type: 'text' 4}, { 5 type: 'script', 6 name: 'script', 7 attribs: { 8 language: 'javascript' 9 }, 10 children: [{ 11 data: 'var foo = \'<bar>\';<', 12 type: 'text' 13 }] 14}, { 15 data: '<!-- Waah! -- ', 16 type: 'comment' 17}]
Indicates whether the whitespace in text nodes should be normalized (= all whitespace should be replaced with single spaces). The default value is "false".
The following HTML will be used:
1<font> 2 <br>this is the text 3<font>
1[{ 2 type: 'tag', 3 name: 'font', 4 children: [{ 5 data: ' ', 6 type: 'text' 7 }, { 8 type: 'tag', 9 name: 'br' 10 }, { 11 data: 'this is the text ', 12 type: 'text' 13 }, { 14 type: 'tag', 15 name: 'font' 16 }] 17}]
1[{ 2 type: 'tag', 3 name: 'font', 4 children: [{ 5 data: '\n\t', 6 type: 'text' 7 }, { 8 type: 'tag', 9 name: 'br' 10 }, { 11 data: 'this is the text\n', 12 type: 'text' 13 }, { 14 type: 'tag', 15 name: 'font' 16 }] 17}]
Adds DOM level 1 properties to all elements.
Indicates whether a startIndex
property will be added to nodes. When the parser is used in a non-streaming fashion, startIndex
is an integer indicating the position of the start of the node in the document. The default value is "false".
Indicates whether a endIndex
property will be added to nodes. When the parser is used in a non-streaming fashion, endIndex
is an integer indicating the position of the end of the node in the document. The default value is "false".
No vulnerabilities found.
No security vulnerabilities found.