{"id":13485047,"url":"https://github.com/fb55/domhandler","last_synced_at":"2025-05-13T21:12:12.308Z","repository":{"id":4284697,"uuid":"5414232","full_name":"fb55/domhandler","owner":"fb55","description":"Handler for htmlparser2, to get a DOM","archived":false,"fork":false,"pushed_at":"2025-04-25T13:43:18.000Z","size":4082,"stargazers_count":354,"open_issues_count":6,"forks_count":63,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-25T14:46:08.494Z","etag":null,"topics":["dom","dom-builder","domhandler","htmlparser2","tree"],"latest_commit_sha":null,"homepage":"https://domhandler.js.org","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fb55.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["fb55"],"tidelift":"npm/domhandler"}},"created_at":"2012-08-14T14:52:52.000Z","updated_at":"2025-04-25T13:42:05.000Z","dependencies_parsed_at":"2024-02-15T09:23:51.781Z","dependency_job_id":"e61ca8ed-947b-494c-9da0-14b3aaddd433","html_url":"https://github.com/fb55/domhandler","commit_stats":{"total_commits":1371,"total_committers":22,"mean_commits":62.31818181818182,"dds":"0.34135667396061264","last_synced_commit":"16c64d7e5afcd1932699f2b3ac8f7aa6babd3cc8"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2Fdomhandler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2Fdomhandler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2Fdomhandler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2Fdomhandler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fb55","download_url":"https://codeload.github.com/fb55/domhandler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251178043,"owners_count":21548153,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dom","dom-builder","domhandler","htmlparser2","tree"],"created_at":"2024-07-31T17:01:43.911Z","updated_at":"2025-04-28T14:13:14.757Z","avatar_url":"https://github.com/fb55.png","language":"TypeScript","readme":"# domhandler [![Node.js CI](https://github.com/fb55/domhandler/actions/workflows/nodejs-test.yml/badge.svg)](https://github.com/fb55/domhandler/actions/workflows/nodejs-test.yml)\n\nThe DOM handler creates a tree containing all nodes of a page.\nThe tree can be manipulated using the [domutils](https://github.com/fb55/domutils)\nor [cheerio](https://github.com/cheeriojs/cheerio) libraries and\nrendered using [dom-serializer](https://github.com/cheeriojs/dom-serializer) .\n\n## Usage\n\n```javascript\nconst handler = new DomHandler([ \u003cfunc\u003e callback(err, dom), ] [ \u003cobj\u003e options ]);\n// const parser = new Parser(handler[, options]);\n```\n\nAvailable options are described below.\n\n## Example\n\n```javascript\nconst { Parser } = require(\"htmlparser2\");\nconst { DomHandler } = require(\"domhandler\");\nconst rawHtml =\n    \"Xyz \u003cscript language= javascript\u003evar foo = '\u003c\u003cbar\u003e\u003e';\u003c/script\u003e\u003c!--\u003c!-- Waah! -- --\u003e\";\nconst handler = new DomHandler((error, dom) =\u003e {\n    if (error) {\n        // Handle error\n    } else {\n        // Parsing completed, do something\n        console.log(dom);\n    }\n});\nconst parser = new Parser(handler);\nparser.write(rawHtml);\nparser.end();\n```\n\nOutput:\n\n```javascript\n[\n    {\n        data: \"Xyz \",\n        type: \"text\",\n    },\n    {\n        type: \"script\",\n        name: \"script\",\n        attribs: {\n            language: \"javascript\",\n        },\n        children: [\n            {\n                data: \"var foo = '\u003cbar\u003e';\u003c\",\n                type: \"text\",\n            },\n        ],\n    },\n    {\n        data: \"\u003c!-- Waah! -- \",\n        type: \"comment\",\n    },\n];\n```\n\n## Option: `withStartIndices`\n\nAdd a `startIndex` property to nodes.\nWhen the parser is used in a non-streaming fashion, `startIndex` is an integer\nindicating the position of the start of the node in the document.\nThe default value is `false`.\n\n## Option: `withEndIndices`\n\nAdd an `endIndex` property to nodes.\nWhen the parser is used in a non-streaming fashion, `endIndex` is an integer\nindicating the position of the end of the node in the document.\nThe default value is `false`.\n\n---\n\nLicense: BSD-2-Clause\n\n## Security contact information\n\nTo report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).\nTidelift will coordinate the fix and disclosure.\n\n## `domhandler` for enterprise\n\nAvailable as part of the Tidelift Subscription\n\nThe maintainers of `domhandler` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-domhandler?utm_source=npm-domhandler\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo)\n","funding_links":["https://github.com/sponsors/fb55","https://tidelift.com/funding/github/npm/domhandler","https://tidelift.com/security","https://tidelift.com/subscription/pkg/npm-domhandler?utm_source=npm-domhandler\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo"],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffb55%2Fdomhandler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffb55%2Fdomhandler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffb55%2Fdomhandler/lists"}