{"versions":{"1.0.0":{"name":"@desertnet/html-parser","version":"1.0.0","description":"HTML parser and non-strict validator","main":"index.js","scripts":{"test":"mocha --compilers js:babel-register","build":"rimraf ./dist && babel -d ./dist/es5 -s inline ./lib","preversion":"npm test","prepublish":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/desertnet/html-parser.git"},"keywords":["html","parser","validator"],"author":{"name":"Eric McCarthy","email":"eric@limulus.net","url":"http://www.limulus.net/"},"license":"SEE LICENSE IN LICENSE","bugs":{"url":"https://github.com/desertnet/html-parser/issues"},"homepage":"https://github.com/desertnet/html-parser#readme","devDependencies":{"babel-cli":"^6.11.4","babel-preset-es2015":"^6.13.2","babel-register":"^6.11.6","chai":"^3.5.0","chai-things":"^0.2.0","mocha":"^3.0.2","rimraf":"^2.5.4","sinon":"^1.17.5","sinon-chai":"^2.8.0"},"dependencies":{"@desertnet/scanner":"^1.1.0"},"gitHead":"3f28d8187d41691154fc039ae6dde8f58a6dbc86","_id":"@desertnet/html-parser@1.0.0","_shasum":"98a3a14a3c75a85ba1e85da1882684c55be6371f","_from":".","_npmVersion":"3.10.5","_nodeVersion":"6.3.1","_npmUser":{"name":"anonymous","email":"eric@limulus.net"},"dist":{"shasum":"98a3a14a3c75a85ba1e85da1882684c55be6371f","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@desertnet/html-parser/-/html-parser-1.0.0.tgz","size":100700,"integrity":"sha512-yLC4g28M45F5ZmELoVXUq0dSJYAJCWjuzAMQDQz991FsJHL9CAUmAB/1fcdoFAQXoAINjZHJ7FPftsi8XmqJPw=="},"maintainers":[{"name":"anonymous","email":"eric@limulus.net"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/html-parser-1.0.0.tgz_1471469488817_0.5430930047295988"},"directories":{},"_cnpmcore_publish_time":"2021-12-23T05:12:29.040Z","contributors":[]},"1.0.1":{"name":"@desertnet/html-parser","version":"1.0.1","description":"HTML parser and non-strict validator","main":"index.js","scripts":{"test":"mocha --compilers js:babel-register","build":"rimraf ./dist && babel -d ./dist/es5 -s inline ./lib","preversion":"npm test","prepublish":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/desertnet/html-parser.git"},"keywords":["html","parser","validator"],"author":{"name":"Eric McCarthy","email":"eric@limulus.net","url":"http://www.limulus.net/"},"license":"MIT","bugs":{"url":"https://github.com/desertnet/html-parser/issues"},"homepage":"https://github.com/desertnet/html-parser#readme","devDependencies":{"babel-cli":"^6.11.4","babel-preset-es2015":"^6.13.2","babel-register":"^6.11.6","chai":"^3.5.0","chai-things":"^0.2.0","mocha":"^3.0.2","rimraf":"^2.5.4","sinon":"^1.17.5","sinon-chai":"^2.8.0"},"dependencies":{"@desertnet/scanner":"^1.1.0"},"gitHead":"b86d3f08113a554173033acfd1c949961da68ef9","_id":"@desertnet/html-parser@1.0.1","_npmVersion":"6.2.0","_nodeVersion":"10.6.0","_npmUser":{"name":"anonymous","email":"eric@limulus.net"},"dist":{"integrity":"sha512-q8X6ntD2UL68P7BY6zoQtHU7BupSDn8QNis2HjlMwsGQ88+zMZAbLmUcY0z/4FOE8UKywEf2C1e7abKyraPNTQ==","shasum":"7b5ecbe75ae843268b8e4c640e310932146537df","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@desertnet/html-parser/-/html-parser-1.0.1.tgz","fileCount":40,"unpackedSize":462951,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbYhylCRA9TVsSAnZWagAAWHkP/1CmkKEQD6kejVCyeEJe\nMxKIc6JVvTPX5vSiogogaEQZM+OHo18ixlUFq2WuR9GHq0zRSdrQ9npZdcdl\nxFOlRb8T1gcG5lEU1FMo6IukIsuDozKzsOSkuacwJVogFUhc4xk+dyVWjNlK\nq6wRXKhwVzrfsHg51COR1n7QbQgvkp0NPkp0var25nMMQf+Yscv1KfadK1fL\new/BbqcV+Rs0AKBdFsPkLXIyaBNjl/M/k+5vwpIKBNKk8xvGfvqfVGZIYcmY\nufV2br87D9bw2SN0T0YM4WLoDG3EEjKs9MQpES6kNooGbNbOZ4Wcmnf6aqLR\nFQMumzJ+4wVoTN85diaOjn38SBdWPv5JqcSIm+4LlPLkCAKpi66VXhWwcdE+\na1sHApObn8BHS5XFNBE+LyIzZU7XxYNt8lGBIqLn2Tyq6PXZNP4jlUkng9Ba\ngwZJGS7ErlH9KSzQvC7gbmyph7t2NBP7979pYTssSvs7XMrOS0MqchXRTWlG\niwBH0MbUe2ixpVZAM9D06lZksKzGZHdXpd32Gb1d3U8Vvb11tiBOuiMGXICe\nKScLfVEMNUo3Pr5DVRdNAm3EOQvWf1QKfeNmV5J/z++QslKGn5BB/jmMqz4c\nYCsE36z8ZqZ0EhbWI5LSvoNtZKZJWGHTNoRlr6DDGbk3WgXNzuvKXTeO+FGb\n83R+\r\n=ItRn\r\n-----END PGP SIGNATURE-----\r\n","size":101212},"maintainers":[{"email":"eric@limulus.net","name":"anonymous"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/html-parser_1.0.1_1533156516868_0.934127734615809"},"_cnpmcore_publish_time":"2021-12-23T05:12:31.123Z","contributors":[]}},"dist-tags":{"latest":"1.0.1"},"name":"@desertnet/html-parser","time":{"created":"2022-01-26T20:43:23.488Z","modified":"2022-01-26T20:43:23.488Z","1.0.0":"2016-08-17T21:31:29.053Z","1.0.1":"2018-08-01T20:48:36.999Z"},"readme":"# html-parser\n\n\nThis HTML parser and validator is not a strict HTML parser in the vein of the XHTML strict validators of old. Instead, it aims to parse HTML as browsers do and only surface errors that are likely to confuse browsers or that are indicative of a confused HTML author.\n\n## Installation\n\n```sh\nnpm install --save @desertnet/html-parser\n```\n\n## Usage\n\n```javascript\nconst HTMLParser = require('@desertnet/html-parser')\n\nconst html = `\n<p>\n  <b>I forgot to close my b tag.\n</p>\n\n<p>\n  I&npsb;misspelled the no-break-space entity.\n</p>\n`.trim()\n\nconst errors = HTMLParser.validate(html)\n\nerrors.forEach(error => {\n  console.log(`${error.message} (line: ${error.line}, column: ${error.column})`)\n})\n```\n\nOutputs:\n\n```\nCould not find closing tag for \"<b>\". (line: 2, column: 3)\nUnexpected closing tag, \"</p>\". Expected closing tag for \"<b>\". (line: 3, column: 1)\nInvalid HTML entity name for \"&npsb;\". (line: 6, column: 5)\n```\n\n## API\n\n### HTMLParser.validate(htmlString)\n\nStatic method on `HTMLParser` constructor. It parses the HTML fragment in `htmlString` and returns an array of `HTMLParseError`s. If there were no errors, an empty array is returned.\n\n### HTMLParser\n\nThe `HTMLParser` constructor. It takes no arguments.\n\n```javascript\nconst parser = new HTMLParser()\n```\n\n#### .parse(htmlString)\n\nParses the HTML fragment in `htmlString` and returns an `HTMLNode` object containing the parsed HTML.\n\n```javascript\nconst parseTree = parser.parse('<h1>Hello world!</h1>')\n```\n\n### HTMLParseError\n\nRepresents an error discovered durning parsing of an HTML fragment.\n\n```javascript\nparseTree.errors.forEach(error => {\n  console.log(`${error.message} (line: ${error.line}, column: ${error.column})`)\n})\n```\n\n#### .message\n\nProperty that is a string containing an English description of the error.\n\n#### .startIndex\n\nProperty that is a number indicating the index into the source string where the error begins.\n\n#### .endIndex\n\nProperty that is a number indicating the index into the source string where the error ends.\n\n#### .line\n\nProperty that is a number indicating the line number where the error begins. Line numbers being at `1`, not `0`.\n\n#### .column\n\nProperty that is a number indicating the column of the line where the error begins. Columns also begin at `1`, not `0`.\n\n### HTMLNode\n\nThe base class for all node types. Returned by `HTMLParser`'s `.parse` method.\n\n```javascript\nconsole.log(indentedNodeList(parseTree))\n\nfunction indentedNodeList (node, indent = '') {\n  let str = ''\n  if (node.children) {\n    str += node.children.reduce((prev, child) => {\n      return prev + indentedNodeList(child, `${indent}  `)\n    }, '')\n  }\n  return `${indent}${node.type}\\n${str}`\n}\n```\n\n#### .type\n\nProperty indicating the type of node. It will be one of the following strings:\n\n  - `ROOT`: Root node of the tree.\n  - `TAG`: An HTML tag.\n  - `ATTRIBUTE`: An attribute of an HTML tag.\n  - `TEXT`: A text content node.\n  - `ENTITY`: An HTML entity (i.e. `&amp;`)\n  - `COMMENT`: An HTML comment tag.\n  - `CLOSETAG`: A closing HTML tag.\n\n#### .children\n\nProperty that is either `null`, or an array of `HTMLNode`s that are the node's children.\n\n#### .indexRange\n\nProperty that, if non-null, will be an array of two numbers. The first is the index of the source string where the node begins, and the second is the index of the source string where the node ends.\n\n#### .errors\n\nProperty that is an array of `HTMLParseError`s associated with this node and its descendants.\n\n#### .ownErrors\n\nProperty that is an array of `HTMLParseError`s associated with only this node (not its descendants).\n\n#### .tagName\n\nOn `TAG` and `CLOSETAG` type nodes, this is a string of the lowercased tag name.\n\n#### .attributes\n\nOn `TAG` type nodes, this is an array of `ATTRIBUTE` nodes that belong to the tag.\n\n#### .closingTag\n\nOn `TAG` type nodes, this is a `CLOSETAG` node, if a closing tag for this node was found.","users":{}}