Gathering detailed insights and metrics for domhandler-daily
Gathering detailed insights and metrics for domhandler-daily
npm install domhandler-daily
Typescript
Module System
NPM Version
73.6
Supply Chain
98.9
Quality
74.8
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
83,590
Last Day
1
Last Week
3
Last Month
78
Last Year
278
67 Commits
1 Forks
18 Watching
2 Branches
12 Contributors
Minified
Minified + Gzipped
Latest Version
2.3.0
Package Id
domhandler-daily@2.3.0
Size
7.12 kB
NPM Version
1.4.28
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
-85%
3
Compared to previous week
Last month
-6%
78
Compared to previous month
Last year
120.6%
278
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.
Custom version to handle Twig tags in elements.
##Usage
1var handler = new DomHandler([ <func> callback(err, dom), ] [ <obj> options ]); 2// var parser = new Parser(handler[, options]);
##Example
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.done();
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}]
##Option: normalizeWhitespace 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>
###Example: true
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}]
###Example: false
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}]
##Option: withStartIndices
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".
No vulnerabilities found.
No security vulnerabilities found.