{"id":29125777,"url":"https://github.com/syntax-tree/hast-util-to-parse5","last_synced_at":"2025-07-25T21:05:07.819Z","repository":{"id":10050486,"uuid":"64220376","full_name":"syntax-tree/hast-util-to-parse5","owner":"syntax-tree","description":"utility to transform hast to Parse5’s AST","archived":false,"fork":false,"pushed_at":"2023-07-31T11:57:27.000Z","size":146,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-23T20:52:38.296Z","etag":null,"topics":["hast","hast-util","html","parse5","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"}},"created_at":"2016-07-26T12:42:11.000Z","updated_at":"2023-01-31T16:44:15.000Z","dependencies_parsed_at":"2024-11-14T22:01:51.396Z","dependency_job_id":"db1c0fc0-fc65-4bb1-80ee-b1e3dc11a230","html_url":"https://github.com/syntax-tree/hast-util-to-parse5","commit_stats":{"total_commits":119,"total_committers":3,"mean_commits":"39.666666666666664","dds":0.04201680672268904,"last_synced_commit":"b92b23d91ce311ac5d81c0eaee94865387e6dcc5"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/syntax-tree/hast-util-to-parse5","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-to-parse5","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-to-parse5/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-to-parse5/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-to-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-to-parse5/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntax-tree%2Fhast-util-to-parse5/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262590206,"owners_count":23333276,"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":["hast","hast-util","html","parse5","util"],"created_at":"2025-06-29T22:03:37.257Z","updated_at":"2025-06-29T22:03:38.070Z","avatar_url":"https://github.com/syntax-tree.png","language":"JavaScript","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":[],"sub_categories":[],"readme":"# hast-util-to-parse5\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n[hast][] utility to transform to a [`parse5`][parse5] [AST][parse5-node].\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    *   [`toParse5(tree[, options])`](#toparse5tree-options)\n    *   [`Options`](#options)\n    *   [`Space`](#space)\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 hast syntax tree into a `parse5` AST.\nWhy not use a Parse5 adapter, you might ask?\nWell, because it’s more code weight to use adapters, and more fragile.\n\n## When should I use this?\n\nThis package is useful when working with `parse5`, and for some reason want to\ngenerate its AST again.\nThe inverse utility, [`hast-util-from-parse5`][hast-util-from-parse5], is more\nlikely what you want.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install hast-util-to-parse5\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {toParse5} from 'https://esm.sh/hast-util-to-parse5@8'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import {toParse5} from 'https://esm.sh/hast-util-to-parse5@8?bundle'\n\u003c/script\u003e\n```\n\n## Use\n\n```js\nimport {toParse5} from 'hast-util-to-parse5'\n\nconst tree = toParse5({\n  type: 'element',\n  tagName: 'h1',\n  properties: {},\n  children: [{type: 'text', value: 'World!'}]\n})\n\nconsole.log(tree)\n```\n\nYields:\n\n```js\n{ nodeName: 'h1',\n  tagName: 'h1',\n  attrs: [],\n  namespaceURI: 'http://www.w3.org/1999/xhtml',\n  childNodes: [ { nodeName: '#text', value: 'World!', parentNode: [Circular] } ] }\n```\n\n## API\n\nThis package exports the identifier [`toParse5`][api-to-parse5].\nThere is no default export.\n\n### `toParse5(tree[, options])`\n\nTransform a hast tree to a `parse5` AST.\n\n###### Parameters\n\n*   `tree` ([`HastNode`][hast-node])\n    — tree to transform\n*   `options` ([`Options`][api-options], optional)\n    — configuration\n\n###### Returns\n\n`parse5` node ([`Parse5Node`][parse5-node]).\n\n### `Options`\n\nConfiguration (TypeScript type).\n\n###### Fields\n\n*   `space` ([`Space`][api-space], optional)\n    — which space the document is in\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, we drop support for unmaintained versions of\nNode.\nThis means we try to keep the current release line, `hast-util-to-parse5@^8`,\ncompatible with Node.js 16.\n\n## Security\n\nUse of `hast-util-to-parse5` can open you up to a\n[cross-site scripting (XSS)][xss] attack if the hast tree is unsafe.\n\n## Related\n\n*   [`hast-util-from-parse5`](https://github.com/syntax-tree/hast-util-from-parse5)\n    — transform from Parse5’s AST to hast\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`][contributing] in [`syntax-tree/.github`][health] for\nways to get started.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n\u003c!-- Definitions --\u003e\n\n[build-badge]: https://github.com/syntax-tree/hast-util-to-parse5/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/hast-util-to-parse5/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-to-parse5.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/hast-util-to-parse5\n\n[downloads-badge]: https://img.shields.io/npm/dm/hast-util-to-parse5.svg\n\n[downloads]: https://www.npmjs.com/package/hast-util-to-parse5\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size\u0026query=$.size.compressedSize\u0026url=https://deno.bundlejs.com/?q=hast-util-to-parse5\n\n[size]: https://bundlejs.com/?q=hast-util-to-parse5\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/syntax-tree/unist/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[typescript]: https://www.typescriptlang.org\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[health]: https://github.com/syntax-tree/.github\n\n[contributing]: https://github.com/syntax-tree/.github/blob/main/contributing.md\n\n[support]: https://github.com/syntax-tree/.github/blob/main/support.md\n\n[coc]: https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md\n\n[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n\n[hast]: https://github.com/syntax-tree/hast\n\n[hast-node]: https://github.com/syntax-tree/hast#nodes\n\n[parse5]: https://github.com/inikulin/parse5\n\n[parse5-node]: https://github.com/inikulin/parse5/blob/master/packages/parse5/lib/tree-adapters/default.ts\n\n[hast-util-from-parse5]: https://github.com/syntax-tree/hast-util-from-parse5\n\n[api-to-parse5]: #toparse5tree-options\n\n[api-options]: #options\n\n[api-space]: #space\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fhast-util-to-parse5","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyntax-tree%2Fhast-util-to-parse5","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntax-tree%2Fhast-util-to-parse5/lists"}