{"_id":"hast-util-from-html-isomorphic","_rev":"2-4e727adc073f6a4faf7ff0aa820cc2f7","name":"hast-util-from-html-isomorphic","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"hast-util-from-html-isomorphic","version":"1.0.0","description":"hast utility that turns HTML into a syntax tree (while being small in browsers)","license":"MIT","keywords":["unist","hast","hast-util","util","utility","html","parse","dom"],"repository":{"type":"git","url":"git+https://github.com/syntax-tree/hast-util-from-html-isomorphic.git"},"bugs":{"url":"https://github.com/syntax-tree/hast-util-from-html-isomorphic/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"Remco Haszing","email":"remcohaszing@gmail.com"},"contributors":[{"name":"Remco Haszing","email":"remcohaszing@gmail.com"}],"sideEffects":false,"type":"module","exports":{".":{"deno":"./index.js","react-native":"./index.js","worker":"./index.js","browser":"./lib/browser.js","default":"./index.js"}},"dependencies":{"@types/hast":"^2.0.0","hast-util-from-html":"^1.0.0","hast-util-from-dom":"^4.0.0","unist-util-remove-position":"^4.0.0"},"devDependencies":{"@types/jsdom":"^21.0.0","@types/node":"^18.0.0","c8":"^7.0.0","jsdom":"^21.0.0","prettier":"^2.0.0","remark-cli":"^11.0.0","remark-preset-wooorm":"^9.0.0","type-coverage":"^2.0.0","typescript":"^5.0.0","xo":"^0.53.0"},"scripts":{"prepack":"npm run build && npm run format","build":"tsc --build --clean && tsc --build && type-coverage","format":"remark . -qfo && prettier . -w --loglevel warn && xo --fix","test-browser":"node --conditions development --conditions browser -r ./test/dom.cjs test/index.js","test-node":"node --conditions development test/index.js","test-worker":"node --conditions development --conditions worker test/index.js","test-api":"npm run test-browser && npm run test-node && npm run test-worker","test-coverage":"c8 --check-coverage --100 --reporter lcov npm run test-api","test":"npm run build && npm run format && npm run test-coverage"},"prettier":{"tabWidth":2,"useTabs":false,"singleQuote":true,"bracketSpacing":false,"semi":false,"trailingComma":"none"},"xo":{"prettier":true,"env":["browser"]},"remarkConfig":{"plugins":["remark-preset-wooorm",["remark-lint-no-html",false]]},"typeCoverage":{"atLeast":100,"detail":true,"strict":true},"types":"./index.d.ts","gitHead":"804aebbf07761e6228d15137e951fcb3049335c3","homepage":"https://github.com/syntax-tree/hast-util-from-html-isomorphic#readme","_id":"hast-util-from-html-isomorphic@1.0.0","_nodeVersion":"19.3.0","_npmVersion":"9.6.2","dist":{"integrity":"sha512-Yu480AKeOEN/+l5LA674a+7BmIvtDj24GvOt7MtQWuhzUwlaaRWdEPXAh3Qm5vhuthpAipFb2vTetKXWOjmTvw==","shasum":"592b2bea880d476665b76ca1cf7d1a94925c80ec","tarball":"https://registry.npmjs.org/hast-util-from-html-isomorphic/-/hast-util-from-html-isomorphic-1.0.0.tgz","fileCount":9,"unpackedSize":14104,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDSCFghO4GmhHtqeHO1BRdQ7Cc6qhwPeqtUEHOq1daaDQIhAJ/fBNiZgSnRfhy7/UibeJGkOJ5OZlHBotiIj9C9HkLp"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkE2jkACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmpfhg//bKJ5oPWcoihdWiq9KGg1ETA1wnIJ/8W0EuDEezfBqOimj8lO\r\nKRYRYQyN2eQO/gsnEX8KYRPBYmgpqIHkNv8oHXdJSqX37bUxIzhOFNpIf5iH\r\nAQYdL1L03VuMpQG7YWJFo4Top6OFew1BFUw6DvZ2B6wocGCDoJRxye2jOSoe\r\nSXjI1gclAOaCgbjm90G6zTBuNaXjznC3o1VnciH9BXqMqDCO5yRLP9vgyQy2\r\nyEO0IYLJNVQ0Yi6ecEwU4KOJiWc32pxMAC2/z8CWhpTDr8kEbhnARakFvVnk\r\nUW8Tn49kb3fzXbMca1fC8wkbI4ZCEwwd03rXfsa1hlYygnExrx4y+4wG5okP\r\nv3D5EASxwzCONlDECgRGTb8Tme/13lCvQQOsIyhaITnVMrK1uODESYPHjXmE\r\n28StczpzRdpTcLKukrvOS7YMz6Fa+Eb+J7NLF0dDDf5VM2H3LNU+aw1bL/Ne\r\nfJEZ1rZUsSuqAavH1ye4sWO/o/RQ+lquwCV/QGcMhj8eAuEC4TWj6FSO8e6q\r\nQnKvB/03+s4Y5gQuQ1U3VWQJr7sbmyOEuh1gKSRO5u5UOhtIZy34L0JfRZPp\r\nyL4ZmclNZtglDz+kwImq/w6Te30HvDptU/YxLR9ZYG+HcLyJ1TuUTRRl6xiw\r\nZNcNvhq2I02obJSPe2g6uQpIELaDeYL4RHc=\r\n=+tBV\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hast-util-from-html-isomorphic_1.0.0_1678993636086_0.055141263192918455"},"_hasShrinkwrap":false},"2.0.0":{"name":"hast-util-from-html-isomorphic","version":"2.0.0","description":"hast utility that turns HTML into a syntax tree (while being small in browsers)","license":"MIT","keywords":["unist","hast","hast-util","util","utility","html","parse","dom"],"repository":{"type":"git","url":"git+https://github.com/syntax-tree/hast-util-from-html-isomorphic.git"},"bugs":{"url":"https://github.com/syntax-tree/hast-util-from-html-isomorphic/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"Remco Haszing","email":"remcohaszing@gmail.com"},"contributors":[{"name":"Remco Haszing","email":"remcohaszing@gmail.com"}],"sideEffects":false,"type":"module","exports":{".":{"deno":"./index.js","react-native":"./index.js","worker":"./index.js","browser":"./lib/browser.js","default":"./index.js"}},"dependencies":{"@types/hast":"^3.0.0","hast-util-from-html":"^2.0.0","hast-util-from-dom":"^5.0.0","unist-util-remove-position":"^5.0.0"},"devDependencies":{"@types/jsdom":"^21.0.0","@types/node":"^20.0.0","c8":"^8.0.0","jsdom":"^22.0.0","prettier":"^3.0.0","remark-cli":"^11.0.0","remark-preset-wooorm":"^9.0.0","type-coverage":"^2.0.0","typescript":"^5.0.0","xo":"^0.55.0"},"scripts":{"prepack":"npm run build && npm run format","build":"tsc --build --clean && tsc --build && type-coverage","format":"remark . -qfo && prettier . -w --log-level warn && xo --fix","test-browser":"node --conditions development --conditions browser -r ./test/dom.cjs test/index.js","test-node":"node --conditions development test/index.js","test-worker":"node --conditions development --conditions worker test/index.js","test-api":"npm run test-browser && npm run test-node && npm run test-worker","test-coverage":"c8 --100 --reporter lcov npm run test-api","test":"npm run build && npm run format && npm run test-coverage"},"prettier":{"bracketSpacing":false,"semi":false,"singleQuote":true,"tabWidth":2,"trailingComma":"none","useTabs":false},"remarkConfig":{"plugins":["remark-preset-wooorm",["remark-lint-no-html",false]]},"typeCoverage":{"atLeast":100,"detail":true,"ignoreCatch":true,"strict":true},"xo":{"env":["browser"],"prettier":true},"gitHead":"40747b5cd8c907fa773f8915ab3248cde06c3549","types":"./index.d.ts","homepage":"https://github.com/syntax-tree/hast-util-from-html-isomorphic#readme","_id":"hast-util-from-html-isomorphic@2.0.0","_nodeVersion":"20.0.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-zJfpXq44yff2hmE0XmwEOzdWin5xwH+QIhMLOScpX91e/NSGPsAzNCvLQDIEPyO2TXi+lBmU6hjLIhV8MwP2kw==","shasum":"b31baee386a899a2472326a3c5692f29f86d1d3c","tarball":"https://registry.npmjs.org/hast-util-from-html-isomorphic/-/hast-util-from-html-isomorphic-2.0.0.tgz","fileCount":9,"unpackedSize":14201,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD9ikzofBMW4TZbFOl4h5dZsUl7vUyteOwYTjHcBmBfjwIgWG7BIhZW4Y0Do7kdy3M81haI4Mk5jp4P+x0TjFSChTo="}]},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"},{"name":"kmck","email":"keith@mcknig.ht"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hast-util-from-html-isomorphic_2.0.0_1691500143592_0.26575400302104346"},"_hasShrinkwrap":false}},"time":{"created":"2023-03-16T19:07:16.086Z","1.0.0":"2023-03-16T19:07:16.234Z","modified":"2023-08-08T13:09:03.901Z","2.0.0":"2023-08-08T13:09:03.725Z"},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"},{"name":"kmck","email":"keith@mcknig.ht"}],"description":"hast utility that turns HTML into a syntax tree (while being small in browsers)","homepage":"https://github.com/syntax-tree/hast-util-from-html-isomorphic#readme","keywords":["unist","hast","hast-util","util","utility","html","parse","dom"],"repository":{"type":"git","url":"git+https://github.com/syntax-tree/hast-util-from-html-isomorphic.git"},"contributors":[{"name":"Remco Haszing","email":"remcohaszing@gmail.com"}],"author":{"name":"Remco Haszing","email":"remcohaszing@gmail.com"},"bugs":{"url":"https://github.com/syntax-tree/hast-util-from-html-isomorphic/issues"},"license":"MIT","readme":"# hast-util-from-html-isomorphic\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 that turns HTML into a syntax tree, using browser APIs\nwhen available, so it has a smaller bundle size there.\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    *   [`fromHtmlIsomorphic(value[, options])`](#fromhtmlisomorphicvalue-options)\n    *   [`Options`](#options)\n*   [Examples](#examples)\n    *   [Example: fragment versus document](#example-fragment-versus-document)\n*   [Syntax](#syntax)\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 takes HTML input and turns it into a hast syntax\ntree.\n\nIn a browser, this uses [`hast-util-from-dom`][hast-util-from-dom],\notherwise it uses [`hast-util-from-html`][hast-util-from-html].\n\n## When should I use this?\n\nIf you want to get a syntax tree without positional info, and your code should\nbe isomorphic (it could run anywhere), as it results in a smaller bundle size.\n\nIf you need positional information, use\n[`hast-util-from-html`][hast-util-from-html].\n\nIf you don’t care about positional info and your code only runs in browsers,\nuse [`hast-util-from-dom`][hast-util-from-dom].\n\nFinally you can use the utility [`hast-util-to-html`][hast-util-to-html],\nor [`hast-util-to-dom`][hast-util-to-dom] with `.outerHTML`, to do the inverse\nof this utility.\nThat turns hast into HTML.\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-from-html-isomorphic\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport {fromHtmlIsomorphic} from 'https://esm.sh/hast-util-from-html-isomorphic@2'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import {fromHtmlIsomorphic} from 'https://esm.sh/hast-util-from-html-isomorphic@2?bundle'\n</script>\n```\n\n## Use\n\n```js\nimport {fromHtmlIsomorphic} from 'hast-util-from-html-isomorphic'\n\nconst tree = fromHtmlIsomorphic('<h1>Hello, world!</h1>', {fragment: true})\n\nconsole.log(tree)\n```\n\nYields (positional info and data omitted for brevity):\n\n```js\n{\n  type: 'root',\n  children: [\n    {\n      type: 'element',\n      tagName: 'h1',\n      properties: {},\n      children: [Array],\n    }\n  ]\n}\n```\n\n## API\n\nThis package exports the identifier\n[`fromHtmlIsomorphic`][api-from-html-isomorphic].\nThere is no default export.\n\n### `fromHtmlIsomorphic(value[, options])`\n\nTurn serialized HTML into a hast tree.\n\n###### Parameters\n\n*   `value` (`string`)\n    — serialized HTML to parse\n*   `options` ([`Options`][api-options], optional)\n    — configuration\n\n###### Returns\n\nTree ([`Root`][root]).\n\n### `Options`\n\nConfiguration (TypeScript type).\n\n##### Fields\n\n###### `fragment`\n\nWhether to parse as a fragment (`boolean`, default: `false`).\nThe default is to expect a whole document.\nIn document mode, unopened `html`, `head`, and `body` elements are opened.\n\n## Examples\n\n### Example: fragment versus document\n\nThe following example shows the difference between parsing as a document and\nparsing as a fragment:\n\n```js\nimport {fromHtml} from 'hast-util-from-html-isomorphic'\n\nconst doc = '<title>Hi!</title><h1>Hello!</h1>'\n\nconsole.log(fromHtml(doc))\n\nconsole.log(fromHtml(doc, {fragment: true}))\n```\n\n…yields (positional info and data omitted for brevity):\n\n```js\n{\n  type: 'root',\n  children: [\n    {type: 'element', tagName: 'html', properties: {}, children: [Array]}\n  ]\n}\n```\n\n```js\n{\n  type: 'root',\n  children: [\n    {type: 'element', tagName: 'title', properties: {}, children: [Array]},\n    {type: 'element', tagName: 'h1', properties: {}, children: [Array]}\n  ]\n}\n```\n\n> 👉 **Note**: observe that when a whole document is expected (first example),\n> missing elements are opened and closed.\n\n## Syntax\n\nHTML is parsed according to WHATWG HTML (the living standard), which is also\nfollowed by browsers such as Chrome and Firefox.\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional type [`Options`][api-options].\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,\n`hast-util-from-html-isomorphic@^1`, compatible with Node.js 16.\n\n## Security\n\nParsing HTML is safe but using user-provided content can open you up to a\n[cross-site scripting (XSS)][xss] attack.\nUse [`hast-util-santize`][hast-util-sanitize] to make the hast tree safe.\n\n## Related\n\n*   [`hast-util-from-html`](https://github.com/syntax-tree/hast-util-from-html)\n    — parse html into hast\n*   [`hast-util-from-dom`](https://github.com/syntax-tree/hast-util-from-dom)\n    — parse a DOM tree into hast\n*   [`hast-util-to-html`](https://github.com/syntax-tree/hast-util-to-html)\n    — serialize hast\n*   [`hast-util-sanitize`](https://github.com/syntax-tree/hast-util-sanitize)\n    — sanitize hast\n*   [`xast-util-from-xml`][xast-util-from-xml]\n    — parse XML\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] © [Remco Haszing][author]\n\n<!-- Definitions -->\n\n[build-badge]: https://github.com/syntax-tree/hast-util-from-html-isomorphic/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/hast-util-from-html-isomorphic/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hast-util-from-html-isomorphic.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/hast-util-from-html-isomorphic\n\n[downloads-badge]: https://img.shields.io/npm/dm/hast-util-from-html-isomorphic.svg\n\n[downloads]: https://www.npmjs.com/package/hast-util-from-html-isomorphic\n\n[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=hast-util-from-html-isomorphic\n\n[size]: https://bundlejs.com/?q=hast-util-from-html-isomorphic\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://github.com/remcohaszing\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[root]: https://github.com/syntax-tree/hast#root\n\n[hast-util-sanitize]: https://github.com/syntax-tree/hast-util-sanitize\n\n[hast-util-from-dom]: https://github.com/syntax-tree/hast-util-from-dom\n\n[hast-util-from-html]: https://github.com/syntax-tree/hast-util-from-html\n\n[hast-util-to-dom]: https://github.com/syntax-tree/hast-util-to-dom\n\n[hast-util-to-html]: https://github.com/syntax-tree/hast-util-to-html\n\n[xast-util-from-xml]: https://github.com/syntax-tree/xast-util-from-xml\n\n[api-from-html-isomorphic]: #fromhtmlisomorphicvalue-options\n\n[api-options]: #options\n","readmeFilename":"readme.md"}