{"_id":"x-domhandler","_rev":"3670592","name":"x-domhandler","description":"handler for htmlparser2 that turns pages into a dom","dist-tags":{"latest":"2.4.2"},"maintainers":[{"name":"yanghuabei","email":""}],"time":{"modified":"2025-02-13T05:41:01.000Z","created":"2018-08-19T12:35:27.665Z","2.4.2":"2018-08-19T12:35:27.665Z"},"users":{},"author":{"name":"Felix Boehm","email":"me@feedic.com"},"repository":{"type":"git","url":"git://github.com/yanghuabei/DomHandler.git"},"versions":{"2.4.2":{"name":"x-domhandler","version":"2.4.2","description":"handler for htmlparser2 that turns pages into a dom","main":"index.js","directories":{"test":"tests"},"scripts":{"test":"mocha -R list && jshint index.js test/"},"repository":{"type":"git","url":"git://github.com/yanghuabei/DomHandler.git"},"keywords":["dom","htmlparser2"],"dependencies":{"domelementtype":"1"},"devDependencies":{"htmlparser2":"^3.9.0","mocha":"^3.0.2","jshint":"^2.9.1"},"author":{"name":"Felix Boehm","email":"me@feedic.com"},"license":"BSD-2-Clause","jshintConfig":{"quotmark":"double","trailing":true,"unused":true,"undef":true,"node":true,"proto":true,"globals":{"it":true}},"gitHead":"9ab081cef256008a72590d5618f08f22e1e1983d","bugs":{"url":"https://github.com/yanghuabei/DomHandler/issues"},"homepage":"https://github.com/yanghuabei/DomHandler#readme","_id":"x-domhandler@2.4.2","_npmVersion":"6.2.0","_nodeVersion":"10.8.0","_npmUser":{"name":"yanghuabei","email":"yanghuabei@outlook.com"},"dist":{"shasum":"21afb2d71977118688e49e05c30894497ce3d5e9","size":7915,"noattachment":false,"key":"/x-domhandler/-/x-domhandler-2.4.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/x-domhandler/download/x-domhandler-2.4.2.tgz"},"maintainers":[{"name":"yanghuabei","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/x-domhandler_2.4.2_1534682127554_0.21325039779804666"},"_hasShrinkwrap":false,"publish_time":1534682127665,"_cnpm_publish_time":1534682127665,"_cnpmcore_publish_time":"2021-12-17T11:07:08.930Z"}},"readme":"# domhandler [![Build Status](https://travis-ci.org/yanghuabei/domhandler.svg?branch=master)](https://travis-ci.org/yanghuabei/domhandler)\n\nThe DOM handler (formally known as DefaultHandler) creates a tree containing all nodes of a page. The tree may be manipulated using the [domutils](https://github.com/fb55/domutils) library.\n\n## Differences with origin domhandler\n1. Add `selfClose` flag to node.\n2. Add `singleQuoteAttribs` map to node.\n\nThis project can work with [stricter-htmlparser2](https://github.com/yanghuabei/htmlparser2).\n\n## Usage\n```javascript\nvar handler = new DomHandler([ <func> callback(err, dom), ] [ <obj> options ]);\n// var parser = new Parser(handler[, options]);\n```\n\nAvailable options are described below.\n\n## Example\n```javascript\nvar htmlparser = require(\"htmlparser2\");\nvar rawHtml = \"Xyz <script language= 'javascript'>var foo = '<<bar>>';< /  script><!--<!-- Waah! -- -->\";\nvar handler = new htmlparser.DomHandler(function (error, dom) {\n    if (error)\n    \t[...do something for errors...]\n    else\n    \t[...parsing done, do something...]\n        console.log(dom);\n});\nvar parser = new htmlparser.Parser(handler);\nparser.write(rawHtml);\nparser.end();\n```\n\nOutput:\n\n```javascript\n[{\n    data: 'Xyz ',\n    type: 'text'\n}, {\n    type: 'script',\n    name: 'script',\n    attribs: {\n    \tlanguage: 'javascript'\n    },\n    children: [{\n    \tdata: 'var foo = \\'<bar>\\';<',\n    \ttype: 'text'\n    }]\n}, {\n    data: '<!-- Waah! -- ',\n    type: 'comment'\n}]\n```\n\n## Option: normalizeWhitespace\nIndicates whether the whitespace in text nodes should be normalized (= all whitespace should be replaced with single spaces). The default value is \"false\". \n\nThe following HTML will be used:\n\n```html\n<font>\n\t<br>this is the text\n<font>\n```\n\n### Example: true\n\n```javascript\n[{\n    type: 'tag',\n    name: 'font',\n    children: [{\n    \tdata: ' ',\n    \ttype: 'text'\n    }, {\n    \ttype: 'tag',\n    \tname: 'br'\n    }, {\n    \tdata: 'this is the text ',\n    \ttype: 'text'\n    }, {\n    \ttype: 'tag',\n    \tname: 'font'\n    }]\n}]\n```\n\n### Example: false\n\n```javascript\n[{\n    type: 'tag',\n    name: 'font',\n    children: [{\n    \tdata: '\\n\\t',\n    \ttype: 'text'\n    }, {\n    \ttype: 'tag',\n    \tname: 'br'\n    }, {\n    \tdata: 'this is the text\\n',\n    \ttype: 'text'\n    }, {\n    \ttype: 'tag',\n    \tname: 'font'\n    }]\n}]\n```\n\n## Option: withDomLvl1\n\nAdds DOM level 1 properties to all elements.\n\n<!-- TODO: description -->\n\n## Option: withStartIndices\nIndicates 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\".\n\n## Option: withEndIndices\nIndicates 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\".\n","_attachments":{},"homepage":"https://github.com/yanghuabei/DomHandler#readme","bugs":{"url":"https://github.com/yanghuabei/DomHandler/issues"},"license":"BSD-2-Clause"}