[
  {
    "path": ".editorconfig",
    "content": "root = true\n\n[*]\ncharset = utf-8\nend_of_line = lf\nindent_size = 2\nindent_style = space\ninsert_final_newline = true\ntrim_trailing_whitespace = true\n"
  },
  {
    "path": ".github/workflows/bb.yml",
    "content": "jobs:\n  main:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: unifiedjs/beep-boop-beta@main\n        with:\n          repo-token: ${{secrets.GITHUB_TOKEN}}\nname: bb\non:\n  issues:\n    types: [closed, edited, labeled, opened, reopened, unlabeled]\n  pull_request_target:\n    types: [closed, edited, labeled, opened, reopened, unlabeled]\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "jobs:\n  main:\n    name: ${{matrix.node}}\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n      - uses: actions/setup-node@v4\n        with:\n          node-version: ${{matrix.node}}\n      - run: npm install\n      - run: npm test\n      - uses: codecov/codecov-action@v4\n    strategy:\n      matrix:\n        node:\n          - lts/hydrogen\n          - node\nname: main\non:\n  - pull_request\n  - push\n"
  },
  {
    "path": ".gitignore",
    "content": "*.d.ts\n*.log\n*.map\n*.tsbuildinfo\n.DS_Store\ncoverage/\nnode_modules/\nyarn.lock\n"
  },
  {
    "path": ".npmrc",
    "content": "ignore-scripts=true\npackage-lock=false\n"
  },
  {
    "path": ".prettierignore",
    "content": "coverage/\n*.md\n"
  },
  {
    "path": "index.js",
    "content": "/**\n * @typedef {import('./lib/index.js').Options} Options\n */\n\nexport {default} from './lib/index.js'\n"
  },
  {
    "path": "lib/index.js",
    "content": "/**\n * @import {Options as RawOptions} from 'hast-util-raw'\n * @import {Root} from 'hast'\n * @import {VFile} from 'vfile'\n */\n\n/**\n * @typedef {Omit<RawOptions, 'file'>} Options\n *   Configuration.\n */\n\nimport {raw} from 'hast-util-raw'\n\n/**\n * Parse the tree (and raw nodes) again, keeping positional info okay.\n *\n * @param {Options | null | undefined}  [options]\n *   Configuration (optional).\n * @returns\n *   Transform.\n */\nexport default function rehypeRaw(options) {\n  /**\n   * @param {Root} tree\n   *   Tree.\n   * @param {VFile} file\n   *   File.\n   * @returns {Root}\n   *   New tree.\n   */\n  return function (tree, file) {\n    // Assume root in -> root out.\n    const result = /** @type {Root} */ (raw(tree, {...options, file}))\n    return result\n  }\n}\n"
  },
  {
    "path": "license",
    "content": "(The MIT License)\n\nCopyright (c) Titus Wormer <tituswormer@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"author\": \"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)\",\n  \"bugs\": \"https://github.com/rehypejs/rehype-raw/issues\",\n  \"contributors\": [\n    \"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)\"\n  ],\n  \"dependencies\": {\n    \"@types/hast\": \"^3.0.0\",\n    \"hast-util-raw\": \"^9.0.0\",\n    \"vfile\": \"^6.0.0\"\n  },\n  \"description\": \"rehype plugin to reparse the tree (and raw nodes)\",\n  \"devDependencies\": {\n    \"@types/node\": \"^22.0.0\",\n    \"c8\": \"^10.0.0\",\n    \"prettier\": \"^3.0.0\",\n    \"rehype-stringify\": \"^10.0.0\",\n    \"remark-cli\": \"^12.0.0\",\n    \"remark-parse\": \"^11.0.0\",\n    \"remark-preset-wooorm\": \"^10.0.0\",\n    \"remark-rehype\": \"^11.0.0\",\n    \"type-coverage\": \"^2.0.0\",\n    \"typescript\": \"^5.0.0\",\n    \"unified\": \"^11.0.0\",\n    \"unist-util-visit\": \"^5.0.0\",\n    \"xo\": \"^0.59.0\"\n  },\n  \"exports\": \"./index.js\",\n  \"files\": [\n    \"index.d.ts.map\",\n    \"index.d.ts\",\n    \"index.js\",\n    \"lib/\"\n  ],\n  \"funding\": {\n    \"type\": \"opencollective\",\n    \"url\": \"https://opencollective.com/unified\"\n  },\n  \"keywords\": [\n    \"html\",\n    \"plugin\",\n    \"raw\",\n    \"rehype-plugin\",\n    \"rehype\",\n    \"unified\"\n  ],\n  \"license\": \"MIT\",\n  \"name\": \"rehype-raw\",\n  \"prettier\": {\n    \"bracketSpacing\": false,\n    \"singleQuote\": true,\n    \"semi\": false,\n    \"tabWidth\": 2,\n    \"trailingComma\": \"none\",\n    \"useTabs\": false\n  },\n  \"version\": \"7.0.0\",\n  \"remarkConfig\": {\n    \"plugins\": [\n      \"remark-preset-wooorm\"\n    ]\n  },\n  \"repository\": \"rehypejs/rehype-raw\",\n  \"scripts\": {\n    \"build\": \"tsc --build --clean && tsc --build && type-coverage\",\n    \"format\": \"remark --frail --output --quiet -- . && prettier --log-level warn --write -- . && xo --fix\",\n    \"test\": \"npm run build && npm run format && npm run test-coverage\",\n    \"test-api\": \"node --conditions development test.js\",\n    \"test-coverage\": \"c8 --100 --reporter lcov -- npm run test-api\"\n  },\n  \"sideEffects\": false,\n  \"typeCoverage\": {\n    \"atLeast\": 100,\n    \"detail\": true,\n    \"ignoreCatch\": true,\n    \"strict\": true\n  },\n  \"type\": \"module\",\n  \"xo\": {\n    \"prettier\": true\n  }\n}\n"
  },
  {
    "path": "readme.md",
    "content": "# rehype-raw\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**[rehype][]** plugin to parse the tree (and raw nodes) again, keeping\npositional info okay.\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  * [`unified().use(rehypeRaw[, options])`](#unifieduserehyperaw-options)\n  * [`Options`](#options)\n* [Types](#types)\n* [Compatibility](#compatibility)\n* [Security](#security)\n* [Contribute](#contribute)\n* [License](#license)\n\n## What is this?\n\nThis package is a [unified][] ([rehype][]) plugin to parse a document again.\nTo understand how it works, requires knowledge of ASTs (specifically, [hast][]).\nThis plugin passes each node and embedded raw HTML through an HTML parser\n([`parse5`][parse5]), to recreate a tree exactly as how a browser would parse\nit, while keeping the original data and positional info intact.\n\n**unified** is a project that transforms content with abstract syntax trees\n(ASTs).\n**rehype** adds support for HTML to unified.\n**hast** is the HTML AST that rehype uses.\nThis is a rehype plugin that parses the tree again.\n\n## When should I use this?\n\nThis plugin is particularly useful when coming from markdown and wanting to\nsupport HTML embedded inside that markdown (which requires passing\n`allowDangerousHtml: true` to `remark-rehype`).\nMarkdown dictates how, say, a list item or emphasis can be parsed.\nWe can use that to turn the markdown syntax tree into an HTML syntax tree.\nBut markdown also dictates that things that look like HTML, are passed through\nuntouched, even when it just looks like XML but doesn’t really make sense, so we\ncan’t normally use these strings of “HTML” to create an HTML syntax tree.\nThis plugin can.\nIt can be used to take those strings of HTML and include them into the syntax\ntree as actual nodes.\n\nIf your final result is HTML and you trust content, then “strings” are fine\n(you can pass `allowDangerousHtml: true` to `rehype-stringify`, which passes\nHTML through untouched).\nBut there are two main cases where a proper syntax tree is preferred:\n\n* rehype plugins need a proper syntax tree as they operate on actual nodes to\n  inspect or transform things, they can’t operate on strings of HTML\n* other output formats (React, MDX, etc) need actual nodes and can’t handle\n  strings of HTML\n\nThis plugin is built on [`hast-util-raw`][hast-util-raw], which does the work on\nsyntax trees.\nrehype focusses on making it easier to transform content by abstracting such\ninternals away.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][]:\n\n```sh\nnpm install rehype-raw\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport rehypeRaw from 'https://esm.sh/rehype-raw@7'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import rehypeRaw from 'https://esm.sh/rehype-raw@7?bundle'\n</script>\n```\n\n## Use\n\nSay we have the following markdown file `example.md`:\n\n```markdown\n<div class=\"note\">\n\nA mix of *markdown* and <em>HTML</em>.\n\n</div>\n```\n\n…and our module `example.js` looks as follows:\n\n```js\nimport rehypeDocument from 'rehype-document'\nimport rehypeFormat from 'rehype-format'\nimport rehypeRaw from 'rehype-raw'\nimport rehypeStringify from 'rehype-stringify'\nimport remarkParse from 'remark-parse'\nimport remarkRehype from 'remark-rehype'\nimport {read} from 'to-vfile'\nimport {unified} from 'unified'\n\nconst file = await unified()\n  .use(remarkParse)\n  .use(remarkRehype, {allowDangerousHtml: true})\n  .use(rehypeRaw)\n  .use(rehypeDocument, {title: '🙌'})\n  .use(rehypeFormat)\n  .use(rehypeStringify)\n  .process(await read('example.md'))\n\nconsole.log(String(file))\n```\n\n…now running `node example.js` yields:\n\n```html\n<!doctype html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <title>🙌</title>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n  </head>\n  <body>\n    <div class=\"note\">\n      <p>A mix of <em>markdown</em> and <em>HTML</em>.</p>\n    </div>\n  </body>\n</html>\n```\n\n## API\n\nThis package exports no identifiers.\nThe default export is [`rehypeRaw`][api-rehype-raw].\n\n### `unified().use(rehypeRaw[, options])`\n\nParse the tree (and raw nodes) again, keeping positional info okay.\n\n###### Parameters\n\n* `options` ([`Options`][api-options], optional)\n  — configuration\n\n###### Returns\n\nTransform ([`Transformer`][transformer]).\n\n### `Options`\n\nConfiguration (TypeScript type).\n\n###### Fields\n\n* `passThrough` (`Array<string>`, default: `[]`)\n  — list of custom hast node types to pass through (as in, keep); this option\n  is a bit advanced as it requires knowledge of ASTs, so we defer to the docs\n  in [`hast-util-raw`][hast-util-raw]\n* `tagfilter?` (`boolean | null | undefined`)\n  — whether to disallow irregular tags in `raw` nodes according to GFM\n  tagfilter (default: `false`);\n  this affects the following tags,\n  grouped by their kind:\n  `RAWTEXT` (`iframe`, `noembed`, `noframes`, `style`, `xmp`),\n  `RCDATA` (`textarea`, `title`),\n  `SCRIPT_DATA` (`script`),\n  `PLAINTEXT` (`plaintext`);\n  when you know that you do not want authors to write these tags,\n  you can enable this option to prevent their use from running amok.\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nIt exports the additional type [`Options`][api-options].\n\nThe `Raw` node type is registered by and exposed from\n[`remark-rehype`][remark-rehype].\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, `rehype-raw@^7`, compatible\nwith Node.js 16.\n\n## Security\n\nThe `allowDangerousHtml` option in [`remark-rehype`][remark-rehype] is\ndangerous, so see that plugin on how to make it safe.\nOtherwise, this plugin is safe.\n\n## Contribute\n\nSee [`contributing.md`][contributing] in [`rehypejs/.github`][health] for ways\nto 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<!-- Definitions -->\n\n[build-badge]: https://github.com/rehypejs/rehype-raw/workflows/main/badge.svg\n\n[build]: https://github.com/rehypejs/rehype-raw/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype-raw.svg\n\n[coverage]: https://codecov.io/github/rehypejs/rehype-raw\n\n[downloads-badge]: https://img.shields.io/npm/dm/rehype-raw.svg\n\n[downloads]: https://www.npmjs.com/package/rehype-raw\n\n[size-badge]: https://img.shields.io/bundlejs/size/rehype-raw\n\n[size]: https://bundlejs.com/?q=rehype-raw\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/rehypejs/rehype/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[health]: https://github.com/rehypejs/.github\n\n[contributing]: https://github.com/rehypejs/.github/blob/main/contributing.md\n\n[support]: https://github.com/rehypejs/.github/blob/main/support.md\n\n[coc]: https://github.com/rehypejs/.github/blob/main/code-of-conduct.md\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[typescript]: https://www.typescriptlang.org\n\n[parse5]: https://github.com/inikulin/parse5\n\n[unified]: https://github.com/unifiedjs/unified\n\n[transformer]: https://github.com/unifiedjs/unified#transformer\n\n[hast]: https://github.com/syntax-tree/hast\n\n[hast-util-raw]: https://github.com/syntax-tree/hast-util-raw\n\n[rehype]: https://github.com/rehypejs/rehype\n\n[remark-rehype]: https://github.com/remarkjs/remark-rehype\n\n[api-options]: #options\n\n[api-rehype-raw]: #unifieduserehyperaw-options\n"
  },
  {
    "path": "test.js",
    "content": "/**\n * @import {Root} from 'hast'\n */\n\nimport assert from 'node:assert/strict'\nimport test from 'node:test'\nimport rehypeStringify from 'rehype-stringify'\nimport remarkParse from 'remark-parse'\nimport remarkRehype from 'remark-rehype'\nimport {unified} from 'unified'\nimport {visit} from 'unist-util-visit'\nimport rehypeRaw from 'rehype-raw'\n\ntest('rehypeRaw', async function (t) {\n  await t.test('should expose the public api', async function () {\n    assert.deepEqual(Object.keys(await import('rehype-raw')).sort(), [\n      'default'\n    ])\n  })\n\n  await t.test('should work', async function () {\n    const file = await unified()\n      .use(remarkParse)\n      .use(remarkRehype, {allowDangerousHtml: true})\n      .use(rehypeRaw)\n      .use(function () {\n        /**\n         * @param {Root} root\n         */\n        return function (root) {\n          visit(root, 'raw', function () {\n            assert.fail()\n          })\n        }\n      })\n      .use(rehypeStringify).process(`<div class=\"note\">\n\nA mix of *markdown* and <em>HTML</em>.\n\n</div>`)\n\n    assert.equal(\n      String(file),\n      `<div class=\"note\">\n<p>A mix of <em>markdown</em> and <em>HTML</em>.</p>\n</div>`\n    )\n  })\n\n  await t.test('tagfilter', async function () {\n    const file = await unified()\n      .use(remarkParse)\n      .use(remarkRehype, {allowDangerousHtml: true})\n      .use(rehypeRaw, {tagfilter: true})\n      .use(rehypeStringify)\n      .process('<script>alert(1)</script>')\n\n    assert.equal(String(file), '&#x3C;script>alert(1)&#x3C;/script>')\n  })\n})\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"checkJs\": true,\n    \"customConditions\": [\"development\"],\n    \"declarationMap\": true,\n    \"declaration\": true,\n    \"emitDeclarationOnly\": true,\n    \"exactOptionalPropertyTypes\": true,\n    \"lib\": [\"es2022\"],\n    \"module\": \"node16\",\n    \"strict\": true,\n    \"target\": \"es2022\"\n  },\n  \"exclude\": [\"coverage/\", \"node_modules/\"],\n  \"include\": [\"**/*.js\"]\n}\n"
  }
]