{"id":13339489,"url":"https://github.com/syntax-tree/hast-util-from-parse5","last_synced_at":"2026-02-03T19:14:41.690Z","repository":{"id":10050482,"uuid":"64220390","full_name":"syntax-tree/hast-util-from-parse5","owner":"syntax-tree","description":"utility to transform Parse5’s AST to hast","archived":false,"fork":false,"pushed_at":"2025-02-19T14:42:43.000Z","size":186,"stargazers_count":17,"open_issues_count":0,"forks_count":8,"subscribers_count":7,"default_branch":"main","last_synced_at":"2026-01-27T07:55:47.471Z","etag":null,"topics":["hast","hast-util","html","parse5","syntax-tree","unist","util"],"latest_commit_sha":null,"homepage":"https://unifiedjs.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/syntax-tree.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"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},"funding":{"github":"unifiedjs","open_collective":"unified","thanks_dev":"u/gh/syntax-tree"}},"created_at":"2016-07-26T12:42:29.000Z","updated_at":"2025-10-02T12:25:23.000Z","dependencies_parsed_at":"2024-06-18T14:04:07.090Z","dependency_job_id":"9b55d8c6-a45c-45fa-bd11-484794bede2a","html_url":"https://github.com/syntax-tree/hast-util-from-parse5","commit_stats":{"total_commits":137,"total_committers":5,"mean_commits":27.4,"dds":0.04379562043795615,"last_synced_commit":"d33d275c2c31426215bfb8fed01a0760733b8796"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/syntax-tree/hast-util-from-parse5","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-from-parse5","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-from-parse5/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-from-parse5/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-from-parse5/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syntax-tree","download_url":"https://codeload.github.com/syntax-tree/hast-util-from-parse5/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-from-parse5/sbom","scorecard":{"id":863441,"data":{"date":"2025-08-11","repo":{"name":"github.com/syntax-tree/hast-util-from-parse5","commit":"6fd23c9a4b53a6bce106ebc842de6f1727792954"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.1,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: third-party GitHubAction not pinned by hash: .github/workflows/bb.yml:5: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/hast-util-from-parse5/bb.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:6: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/hast-util-from-parse5/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:7: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/hast-util-from-parse5/main.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/syntax-tree/hast-util-from-parse5/main.yml/main?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/main.yml:11","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":0,"reason":"Found 1/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/bb.yml:1","Warn: no topLevel permission defined: .github/workflows/main.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: license:0","Info: FSF or OSI recognized license: MIT License: license:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":10,"reason":"security policy file detected","details":["Info: security policy file detected: github.com/syntax-tree/.github/security.md:1","Info: Found linked content: github.com/syntax-tree/.github/security.md:1","Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/syntax-tree/.github/security.md:1","Info: Found text in security policy: github.com/syntax-tree/.github/security.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 1 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-24T02:00:22.466Z","repository_id":10050482,"created_at":"2025-08-24T02:00:22.466Z","updated_at":"2025-08-24T02:00:22.466Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29054205,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T15:43:47.601Z","status":"ssl_error","status_checked_at":"2026-02-03T15:43:46.709Z","response_time":96,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["hast","hast-util","html","parse5","syntax-tree","unist","util"],"created_at":"2024-07-29T19:20:04.044Z","updated_at":"2026-02-03T19:14:38.693Z","avatar_url":"https://github.com/syntax-tree.png","language":"JavaScript","readme":"# hast-util-from-parse5\n\n[![Build][badge-build-image]][badge-build-url]\n[![Coverage][badge-coverage-image]][badge-coverage-url]\n[![Downloads][badge-downloads-image]][badge-downloads-url]\n[![Size][badge-size-image]][badge-size-url]\n\n[hast][github-hast] utility to transform from the\n[`parse5`][github-parse5] AST.\n\n## Contents\n\n* [What is this?](#what-is-this)\n* [When should I use this?](#when-should-i-use-this)\n* [Install](#install)\n* [Use](#use)\n* [API](#api)\n  * [`fromParse5(tree[, options])`](#fromparse5tree-options)\n  * [`Options`](#options)\n  * [`Space`](#space-1)\n* [Types](#types)\n* [Compatibility](#compatibility)\n* [Security](#security)\n* [Related](#related)\n* [Contribute](#contribute)\n* [License](#license)\n\n## What is this?\n\nThis package is a utility that can turn a parse5 tree into a hast tree.\n\n## When should I use this?\n\nYou can use this package when using `parse5` as an HTML parser and wanting to\nwork with hast.\n\nThe utility [`hast-util-to-parse5`][github-hast-util-to-parse5] does the\ninverse of this utility.\nIt generates `parse5`s AST again.\n\nThe utility [`hast-util-from-html`][github-hast-util-from-html] wraps this\nutility and `parse5` to both parse HTML and generate hast from it.\n\n## Install\n\nThis package is [ESM only][github-gist-esm].\nIn Node.js (version 16+),\ninstall with [npm][npmjs-install]:\n\n```sh\nnpm install hast-util-from-parse5\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {fromParse5} from \"https://esm.sh/hast-util-from-parse5@8\"\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import {fromParse5} from \"https://esm.sh/hast-util-from-parse5@8?bundle\"\n\u003c/script\u003e\n```\n\n## Use\n\nSay our document `example.html` contains:\n\n```html\n\u003c!doctype html\u003e\u003ctitle\u003eHello!\u003c/title\u003e\u003ch1 id=\"world\"\u003eWorld!\u003c!--after--\u003e\n```\n\n…and our module `example.js` looks as follows:\n\n```js\nimport {fromParse5} from 'hast-util-from-parse5'\nimport {parse} from 'parse5'\nimport {read} from 'to-vfile'\nimport {inspect} from 'unist-util-inspect'\n\nconst file = await read('example.html')\nconst p5ast = parse(String(file), {sourceCodeLocationInfo: true})\nconst hast = fromParse5(p5ast, {file})\n\nconsole.log(inspect(hast))\n```\n\n…now running `node example.js` yields:\n\n```text\nroot[2] (1:1-2:1, 0-70)\n│ data: {\"quirksMode\":false}\n├─0 doctype (1:1-1:16, 0-15)\n└─1 element\u003chtml\u003e[2]\n    │ properties: {}\n    ├─0 element\u003chead\u003e[1]\n    │   │ properties: {}\n    │   └─0 element\u003ctitle\u003e[1] (1:16-1:37, 15-36)\n    │       │ properties: {}\n    │       └─0 text \"Hello!\" (1:23-1:29, 22-28)\n    └─1 element\u003cbody\u003e[1]\n        │ properties: {}\n        └─0 element\u003ch1\u003e[3] (1:37-2:1, 36-70)\n            │ properties: {\"id\":\"world\"}\n            ├─0 text \"World!\" (1:52-1:58, 51-57)\n            ├─1 comment \"after\" (1:58-1:70, 57-69)\n            └─2 text \"\\n\" (1:70-2:1, 69-70)\n```\n\n## API\n\nThis package exports the identifier [`fromParse5`][api-from-parse5].\nThere is no default export.\n\n### `fromParse5(tree[, options])`\n\nTransform a `parse5` AST to hast.\n\n###### Parameters\n\n* `tree`\n  ([`Parse5Node`][github-parse5-node])\n  — `parse5` tree to transform\n* `options`\n  ([`Options`][api-options], optional)\n  — configuration\n\n###### Returns\n\nhast tree ([`HastNode`][github-hast-nodes]).\n\n### `Options`\n\nConfiguration (TypeScript type).\n\n##### Fields\n\n###### `file`\n\nFile used to add positional info to nodes\n([`VFile`][github-vfile], optional).\n\nIf given,\nthe file should represent the original HTML source.\n\n###### `space`\n\nWhich space the document is in\n([`Space`][api-space], default: `'html'`).\n\nWhen an `\u003csvg\u003e` element is found in the HTML space,\nthis package already automatically switches to and from the SVG space when\nentering and exiting it.\n\n###### `verbose`\n\nWhether to add extra positional info about starting tags,\nclosing tags,\nand attributes to elements\n(`boolean`, default: `false`).\n\n\u003e 👉 **Note**:\n\u003e only used when `file` is given.\n\nFor the following HTML:\n\n```html\n\u003cimg src=\"http://example.com/fav.ico\" alt=\"foo\" title=\"bar\"\u003e\n```\n\nThe verbose info would looks as follows:\n\n```js\n{\n  type: 'element',\n  tagName: 'img',\n  properties: {src: 'http://example.com/fav.ico', alt: 'foo', title: 'bar'},\n  children: [],\n  data: {\n    position: {\n      opening: {\n        start: {line: 1, column: 1, offset: 0},\n        end: {line: 1, column: 61, offset: 60}\n      },\n      closing: null,\n      properties: {\n        src: {\n          start: {line: 1, column: 6, offset: 5},\n          end: {line: 1, column: 38, offset: 37}\n        },\n        alt: {\n          start: {line: 1, column: 39, offset: 38},\n          end: {line: 1, column: 48, offset: 47}\n        },\n        title: {\n          start: {line: 1, column: 49, offset: 48},\n          end: {line: 1, column: 60, offset: 59}\n        }\n      }\n    }\n  },\n  position: {\n    start: {line: 1, column: 1, offset: 0},\n    end: {line: 1, column: 61, offset: 60}\n  }\n}\n```\n\n### `Space`\n\nNamespace (TypeScript type).\n\n###### Type\n\n```ts\ntype Space = 'html' | 'svg'\n```\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional types [`Options`][api-options] and\n[`Space`][api-space].\n\n## Compatibility\n\nProjects maintained by the unified collective are compatible with maintained\nversions of Node.js.\n\nWhen we cut a new major release,\nwe drop support for unmaintained versions of Node.\nThis means we try to keep the current release line,\n`hast-util-from-parse5@8`,\ncompatible with Node.js 16.\n\n## Security\n\nUse of `hast-util-from-parse5` can open you up to a\n[cross-site scripting (XSS)][wikipedia-xss] attack if Parse5’s AST is unsafe.\n\n## Related\n\n* [`hast-util-to-parse5`][github-hast-util-to-parse5]\n  — transform hast to Parse5’s AST\n* [`hast-util-to-nlcst`](https://github.com/syntax-tree/hast-util-to-nlcst)\n  — transform hast to nlcst\n* [`hast-util-to-mdast`](https://github.com/syntax-tree/hast-util-to-mdast)\n  — transform hast to mdast\n* [`hast-util-to-xast`](https://github.com/syntax-tree/hast-util-to-xast)\n  — transform hast to xast\n* [`mdast-util-to-hast`](https://github.com/syntax-tree/mdast-util-to-hast)\n  — transform mdast to hast\n* [`mdast-util-to-nlcst`](https://github.com/syntax-tree/mdast-util-to-nlcst)\n  — transform mdast to nlcst\n\n## Contribute\n\nSee [`contributing.md`][health-contributing]\nin\n[`syntax-tree/.github`][health]\nfor ways to get started.\nSee [`support.md`][health-support] for ways to get help.\n\nThis project has a [code of conduct][health-coc].\nBy interacting with this repository,\norganization,\nor community you agree to abide by its terms.\n\n## License\n\n[MIT][file-license] © [Titus Wormer][wooorm]\n\n\u003c!-- Definitions --\u003e\n\n[api-from-parse5]: #fromparse5tree-options\n\n[api-options]: #options\n\n[api-space]: #space-1\n\n[badge-build-image]: https://github.com/syntax-tree/hast-util-from-parse5/workflows/main/badge.svg\n\n[badge-build-url]: https://github.com/syntax-tree/hast-util-from-parse5/actions\n\n[badge-coverage-image]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-from-parse5.svg\n\n[badge-coverage-url]: https://codecov.io/github/syntax-tree/hast-util-from-parse5\n\n[badge-downloads-image]: https://img.shields.io/npm/dm/hast-util-from-parse5.svg\n\n[badge-downloads-url]: https://www.npmjs.com/package/hast-util-from-parse5\n\n[badge-size-image]: https://img.shields.io/bundlejs/size/hast-util-from-parse5\n\n[badge-size-url]: https://bundlejs.com/?q=hast-util-from-parse5\n\n[esmsh]: https://esm.sh\n\n[file-license]: license\n\n[github-gist-esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[github-hast]: https://github.com/syntax-tree/hast\n\n[github-hast-nodes]: https://github.com/syntax-tree/hast#nodes\n\n[github-hast-util-from-html]: https://github.com/syntax-tree/hast-util-from-html\n\n[github-hast-util-to-parse5]: https://github.com/syntax-tree/hast-util-to-parse5\n\n[github-parse5]: https://github.com/inikulin/parse5\n\n[github-parse5-node]: https://github.com/inikulin/parse5/blob/master/packages/parse5/lib/tree-adapters/default.ts\n\n[github-vfile]: https://github.com/vfile/vfile\n\n[health]: https://github.com/syntax-tree/.github\n\n[health-coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md\n\n[health-contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md\n\n[health-support]: https://github.com/syntax-tree/.github/blob/main/support.md\n\n[npmjs-install]: https://docs.npmjs.com/cli/install\n\n[typescript]: https://www.typescriptlang.org\n\n[wikipedia-xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n\n[wooorm]: https://wooorm.com\n","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified","https://thanks.dev/u/gh/syntax-tree"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fhast-util-from-parse5","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyntax-tree%2Fhast-util-from-parse5","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fhast-util-from-parse5/lists"}