{"_id":"@ai-markdown/hast-util-from-parse5","_rev":"3-229ce89aac20b9f2aef9b2a6316fd871","name":"@ai-markdown/hast-util-from-parse5","dist-tags":{"latest":"8.0.5"},"versions":{"8.0.4":{"name":"@ai-markdown/hast-util-from-parse5","version":"8.0.4","keywords":["ast","change","hast-util","hast","transform","unist","utility","util"],"author":{"url":"https://wooorm.com","name":"Titus Wormer","email":"tituswormer@gmail.com"},"license":"MIT","_id":"@ai-markdown/hast-util-from-parse5@8.0.4","maintainers":[{"name":"aiephoenix","email":"aiephoenixbl@gmail.com"}],"contributors":[{"url":"https://wooorm.com","name":"Titus Wormer","email":"tituswormer@gmail.com"}],"homepage":"https://github.com/ai-markdown/hast-util-from-parse5#readme","bugs":{"url":"https://github.com/ai-markdown/hast-util-from-parse5/issues"},"xo":{"rules":{"max-depth":"off","unicorn/prefer-at":"off"},"prettier":true,"overrides":[{"files":["**/*.d.ts"],"rules":{"@typescript-eslint/ban-types":["error",{"extendDefaults":true}],"@typescript-eslint/array-type":["error",{"default":"generic"}],"@typescript-eslint/consistent-type-definitions":["error","interface"]}},{"files":"test/**/*.js","rules":{"no-await-in-loop":"off"}}]},"dist":{"shasum":"348eef0e6425d0d74f2ca9a2ea89217cacacd591","tarball":"https://registry.npmjs.org/@ai-markdown/hast-util-from-parse5/-/hast-util-from-parse5-8.0.4.tgz","fileCount":6,"integrity":"sha512-0hAfn3HNU1Ysjza8qyqNut1+GVYgJ9NjynZoP74/r6cFaQ88uvXACkil/NNGn+PJxe3+C19Tdphe173sIeSXww==","signatures":[{"sig":"MEQCID1tdiiXt492grnKq+AhZyOEh8QjZDVZdBS2hjMPT00kAiAvZEpMVA749j7Vj5wfkKMHXl+KPJezu6TEInxtXX3ukg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24904},"type":"module","types":"./index.d.ts","exports":"./index.js","funding":{"url":"https://opencollective.com/unified","type":"opencollective"},"gitHead":"5112233daab05a66c62749253b4d95e77d637c9b","scripts":{"test":"npm run build && npm run format && npm run test-coverage","build":"tsc --build --clean && tsc --build && type-coverage","format":"remark --frail --quiet --output -- . && prettier --log-level warn --write -- . && xo --fix","test-api":"node --conditions development test/index.js","test-coverage":"c8 --100 --reporter lcov -- npm run test-api"},"_npmUser":{"name":"aiephoenix","email":"aiephoenixbl@gmail.com"},"prettier":{"semi":false,"useTabs":false,"tabWidth":2,"singleQuote":true,"trailingComma":"none","bracketSpacing":false},"repository":{"url":"git+https://github.com/ai-markdown/hast-util-from-parse5.git","type":"git"},"_npmVersion":"10.9.8","description":"hast utility to transform from a `parse5` AST","directories":{},"sideEffects":false,"_nodeVersion":"22.23.1","dependencies":{"vfile":"^6.0.0","devlop":"^1.0.0","hastscript":"^9.0.0","@types/hast":"^3.0.0","@types/unist":"^3.0.0","vfile-location":"^5.0.0","web-namespaces":"^2.0.0","property-information":"^7.0.0"},"remarkConfig":{"plugins":["remark-preset-wooorm"]},"typeCoverage":{"strict":true,"atLeast":100},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.0.0","xo":"^0.60.0","parse5":"^7.0.0","prettier":"^3.0.0","to-vfile":"^8.0.0","is-hidden":"^2.0.0","remark-cli":"^12.0.0","typescript":"^5.0.0","@types/node":"^22.0.0","type-coverage":"^2.0.0","unist-util-visit":"^5.0.0","remark-preset-wooorm":"^11.0.0"},"_npmOperationalInternal":{"tmp":"tmp/hast-util-from-parse5_8.0.4_1787566205230_0.21543137329190842","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Shipped without type declarations (TS7016). Use 8.0.5."},"8.0.5":{"name":"@ai-markdown/hast-util-from-parse5","version":"8.0.5","keywords":["ast","change","hast-util","hast","transform","unist","utility","util"],"author":{"url":"https://wooorm.com","name":"Titus Wormer","email":"tituswormer@gmail.com"},"license":"MIT","_id":"@ai-markdown/hast-util-from-parse5@8.0.5","maintainers":[{"name":"aiephoenix","email":"aiephoenixbl@gmail.com"}],"contributors":[{"url":"https://wooorm.com","name":"Titus Wormer","email":"tituswormer@gmail.com"}],"homepage":"https://github.com/ai-markdown/hast-util-from-parse5#readme","bugs":{"url":"https://github.com/ai-markdown/hast-util-from-parse5/issues"},"xo":{"rules":{"max-depth":"off","unicorn/prefer-at":"off"},"prettier":true,"overrides":[{"files":["**/*.d.ts"],"rules":{"@typescript-eslint/ban-types":["error",{"extendDefaults":true}],"@typescript-eslint/array-type":["error",{"default":"generic"}],"@typescript-eslint/consistent-type-definitions":["error","interface"]}},{"files":"test/**/*.js","rules":{"no-await-in-loop":"off"}}]},"dist":{"shasum":"a40d4c24aa6862ecdc4022915dbe13eb4e6597ba","tarball":"https://registry.npmjs.org/@ai-markdown/hast-util-from-parse5/-/hast-util-from-parse5-8.0.5.tgz","fileCount":8,"integrity":"sha512-fMeg9sOJxRmq8p7onzVqbsNjxlOQkBOQ7pwcsMCjoeG4Lh2jz2i3ToCQ7IqFWMnVd4MxviUmfrQrh460Ug8r7A==","signatures":[{"sig":"MEUCIQDzDaPLKJJsaMrO5SyYTPwC5gcUZ/JmrT+wIoM9iGU44QIgC0Q3rLR5czPU83ctL75b2gm9NslztJWkK6kKcTrqKBg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ai-markdown%2fhast-util-from-parse5@8.0.5","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":26289},"type":"module","types":"./index.d.ts","exports":"./index.js","funding":{"url":"https://opencollective.com/unified","type":"opencollective"},"gitHead":"b763407c6cf24ff8d68d8460b00ce400fc01459a","scripts":{"test":"npm run build && npm run format && npm run test-coverage","build":"tsc --build --clean && tsc --build && type-coverage","format":"remark --frail --quiet --output -- . && prettier --log-level warn --write -- . && xo --fix","test-api":"node --conditions development test/index.js","test-coverage":"c8 --100 --reporter lcov -- npm run test-api"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:dc7d2233-593d-4ac6-bf44-1932fe21f3e7"}},"prettier":{"semi":false,"useTabs":false,"tabWidth":2,"singleQuote":true,"trailingComma":"none","bracketSpacing":false},"repository":{"url":"git+https://github.com/ai-markdown/hast-util-from-parse5.git","type":"git"},"_npmVersion":"12.0.2","description":"hast utility to transform from a `parse5` AST","directories":{},"sideEffects":false,"_nodeVersion":"22.23.2","dependencies":{"vfile":"^6.0.0","devlop":"^1.0.0","hastscript":"^9.0.0","@types/hast":"^3.0.0","@types/unist":"^3.0.0","vfile-location":"^5.0.0","web-namespaces":"^2.0.0","property-information":"^7.0.0"},"remarkConfig":{"plugins":["remark-preset-wooorm"]},"typeCoverage":{"strict":true,"atLeast":100},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^10.0.0","xo":"^0.60.0","parse5":"^7.0.0","prettier":"^3.0.0","to-vfile":"^8.0.0","is-hidden":"^2.0.0","remark-cli":"^12.0.0","typescript":"^5.0.0","@types/node":"^22.0.0","type-coverage":"^2.0.0","unist-util-visit":"^5.0.0","remark-preset-wooorm":"^11.0.0"},"_npmOperationalInternal":{"tmp":"tmp/hast-util-from-parse5_8.0.5_1787567027527_0.2942550315910819","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2026-08-24T10:10:05.033Z","modified":"2026-08-24T11:31:34.780Z","8.0.4":"2026-08-24T10:10:05.362Z","8.0.5":"2026-08-24T10:23:47.698Z"},"bugs":{"url":"https://github.com/ai-markdown/hast-util-from-parse5/issues"},"author":{"url":"https://wooorm.com","name":"Titus Wormer","email":"tituswormer@gmail.com"},"license":"MIT","homepage":"https://github.com/ai-markdown/hast-util-from-parse5#readme","keywords":["ast","change","hast-util","hast","transform","unist","utility","util"],"repository":{"url":"git+https://github.com/ai-markdown/hast-util-from-parse5.git","type":"git"},"description":"hast utility to transform from a `parse5` AST","contributors":[{"url":"https://wooorm.com","name":"Titus Wormer","email":"tituswormer@gmail.com"}],"maintainers":[{"name":"aiephoenix","email":"aiephoenixbl@gmail.com"}],"readme":"# hast-util-from-parse5\n\n<!-- fork banner -->\n\n> **Fork notice** — this is `@ai-markdown/hast-util-from-parse5`, a fork of\n> [`hast-util-from-parse5`][upstream-repo] at 8.0.3 carrying one fix:\n> a `<template>` inside foreign content (`<svg>`, `<math>`) no longer\n> crashes the conversion. Upstream reads `.content` on every element named\n> `template`, but parse5 — per the HTML spec — only sets template contents\n> on an HTML-namespace template, so `<svg><template>x</template>` threw\n> `TypeError: Cannot read properties of undefined (reading 'nodeName')`\n> through every HTML→hast path (`hast-util-raw`, `hast-util-from-html`,\n> `rehype-parse`).\n>\n> Usage is identical to upstream — only the package name changes. When the\n> fix lands upstream, this fork will be deprecated in favour of it.\n>\n> [upstream-repo]: https://github.com/syntax-tree/hast-util-from-parse5\n\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<script type=\"module\">\n  import {fromParse5} from \"https://esm.sh/hast-util-from-parse5@8?bundle\"\n</script>\n```\n\n## Use\n\nSay our document `example.html` contains:\n\n```html\n<!doctype html><title>Hello!</title><h1 id=\"world\">World!<!--after-->\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<html>[2]\n    │ properties: {}\n    ├─0 element<head>[1]\n    │   │ properties: {}\n    │   └─0 element<title>[1] (1:16-1:37, 15-36)\n    │       │ properties: {}\n    │       └─0 text \"Hello!\" (1:23-1:29, 22-28)\n    └─1 element<body>[1]\n        │ properties: {}\n        └─0 element<h1>[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 `<svg>` 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> 👉 **Note**:\n> only used when `file` is given.\n\nFor the following HTML:\n\n```html\n<img src=\"http://example.com/fav.ico\" alt=\"foo\" title=\"bar\">\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<!-- Definitions -->\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","readmeFilename":"readme.md"}