{"id":13426591,"url":"https://github.com/rehypejs/rehype","last_synced_at":"2025-05-14T21:00:32.674Z","repository":{"id":38375628,"uuid":"52511671","full_name":"rehypejs/rehype","owner":"rehypejs","description":"HTML processor powered by plugins part of the @unifiedjs collective","archived":false,"fork":false,"pushed_at":"2025-02-28T09:58:20.000Z","size":626,"stargazers_count":1974,"open_issues_count":1,"forks_count":93,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-30T01:57:30.318Z","etag":null,"topics":["ast","html","javascript","rehype","unified"],"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/rehypejs.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","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-02-25T09:11:41.000Z","updated_at":"2025-04-29T22:33:45.000Z","dependencies_parsed_at":"2024-06-18T11:13:19.672Z","dependency_job_id":"bdb21f39-8914-496f-8cf0-d13d133a6708","html_url":"https://github.com/rehypejs/rehype","commit_stats":{"total_commits":346,"total_committers":43,"mean_commits":8.046511627906977,"dds":"0.17052023121387283","last_synced_commit":"cef16fec65afd750f2035d6f0c84a655dac55e0d"},"previous_names":["wooorm/rehype"],"tags_count":57,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehypejs%2Frehype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rehypejs","download_url":"https://codeload.github.com/rehypejs/rehype/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251801183,"owners_count":21645968,"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":["ast","html","javascript","rehype","unified"],"created_at":"2024-07-31T00:01:38.591Z","updated_at":"2025-05-07T07:39:19.271Z","avatar_url":"https://github.com/rehypejs.png","language":"JavaScript","readme":"# [![rehype][logo]][unified]\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** is a tool that transforms HTML with plugins.\nThese plugins can inspect and change the HTML.\nYou can use rehype on the server, the client, CLIs, deno, etc.\n\n## Intro\n\nrehype is an ecosystem of plugins that work with HTML as structured data,\nspecifically ASTs (abstract syntax trees).\nASTs make it easy for programs to deal with HTML.\nWe call those programs plugins.\nPlugins inspect and change trees.\nYou can use the many existing plugins or you can make your own.\n\n* to learn HTML, see [MDN][] and [WHATWG HTML][html]\n* for more about us, see [`unifiedjs.com`][site]\n* for questions, see [support][]\n* to help, see [contribute][] or [sponsor][] below\n\n## Contents\n\n* [What is this?](#what-is-this)\n* [When should I use this?](#when-should-i-use-this)\n* [Plugins](#plugins)\n* [Types](#types)\n* [Compatibility](#compatibility)\n* [Security](#security)\n* [Contribute](#contribute)\n* [Sponsor](#sponsor)\n* [License](#license)\n\n## What is this?\n\nWith this project and a plugin, you can turn this HTML:\n\n```html\n\u003c!doctype html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"utf-8\"\u003e\n    \u003ctitle\u003eSaturn\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1\u003eSaturn\u003c/h1\u003e\n    \u003cp\u003eSaturn is a gas giant composed predominantly of hydrogen and helium.\u003c/p\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n…into the following HTML:\n\n```html\n\u003c!doctypehtml\u003e\u003chtml lang=en\u003e\u003cmeta charset=utf8\u003e\u003ctitle\u003eSaturn\u003c/title\u003e\u003ch1\u003eSaturn\u003c/h1\u003e\u003cp\u003eSaturn is a gas giant composed predominantly of hydrogen and helium.\n```\n\n\u003cdetails\u003e\u003csummary\u003eShow example code\u003c/summary\u003e\n\n```js\nimport rehypeParse from 'rehype-parse'\nimport rehypePresetMinify from 'rehype-preset-minify'\nimport rehypeStringify from 'rehype-stringify'\nimport {unified} from 'unified'\n\nconst file = await unified()\n  .use(rehypeParse)\n  .use(rehypePresetMinify)\n  .use(rehypeStringify).process(`\u003c!doctype html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"utf-8\"\u003e\n    \u003ctitle\u003eSaturn\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1\u003eSaturn\u003c/h1\u003e\n    \u003cp\u003eSaturn is a gas giant composed predominantly of hydrogen and helium.\u003c/p\u003e\n  \u003c/body\u003e\n\u003c/html\u003e`)\n\nconsole.log(String(file))\n```\n\n\u003c/details\u003e\n\nWith another plugin, you can turn this HTML:\n\n```html\n\u003ch1\u003eHi, Saturn!\u003c/h1\u003e\n```\n\n…into the following HTML:\n\n```html\n\u003ch2\u003eHi, Saturn!\u003c/h2\u003e\n```\n\n\u003cdetails\u003e\u003csummary\u003eShow example code\u003c/summary\u003e\n\n```js\n/**\n * @import {Root} from 'hast'\n */\n\nimport rehypeParse from 'rehype-parse'\nimport rehypeStringify from 'rehype-stringify'\nimport {unified} from 'unified'\nimport {visit} from 'unist-util-visit'\n\nconst file = await unified()\n  .use(rehypeParse, {fragment: true})\n  .use(myRehypePluginToIncreaseHeadings)\n  .use(rehypeStringify)\n  .process('\u003ch1\u003eHi, Saturn!\u003c/h1\u003e')\n\nconsole.log(String(file))\n\nfunction myRehypePluginToIncreaseHeadings() {\n  /**\n   * @param {Root} tree\n   */\n  return function (tree) {\n    visit(tree, 'element', function (node) {\n      if (['h1', 'h2', 'h3', 'h4', 'h5'].includes(node.tagName)) {\n        node.tagName = 'h' + (Number(node.tagName.charAt(1)) + 1)\n      }\n    })\n  }\n}\n```\n\n\u003c/details\u003e\n\nYou can use rehype for many different things.\n**[unified][]** is the core project that transforms content with ASTs.\n**rehype** adds support for HTML to unified.\n**[hast][]** is the HTML AST that rehype uses.\n\nThis GitHub repository is a monorepo that contains the following packages:\n\n* [`rehype-parse`][rehype-parse]\n  — plugin to take HTML as input and turn it into a syntax tree (hast)\n* [`rehype-stringify`][rehype-stringify]\n  — plugin to take a syntax tree (hast) and turn it into HTML as output\n* [`rehype`][rehype-core]\n  — `unified`, `rehype-parse`, and `rehype-stringify`, useful when input and\n  output are HTML\n* [`rehype-cli`][rehype-cli]\n  — CLI around `rehype` to inspect and format HTML in scripts\n\n## When should I use this?\n\nDepending on the input you have and output you want, you can use different parts\nof rehype.\nIf the input is HTML, you can use `rehype-parse` with `unified`.\nIf the output is HTML, you can use `rehype-stringify` with `unified`\nIf both the input and output are HTML, you can use `rehype` on its own.\nWhen you want to inspect and format HTML files in a project, you can use\n`rehype-cli`.\n\n## Plugins\n\nrehype plugins deal with HTML.\nYou can choose from the many plugins that already exist.\nHere are three good ways to find plugins:\n\n* [`awesome-rehype`][awesome-rehype]\n  — selection of the most awesome projects\n* [List of plugins][list-of-plugins]\n  — list of all plugins\n* [`rehype-plugin` topic][topic]\n  — any tagged repo on GitHub\n\nSome plugins are maintained by us here in the `@rehypejs` organization while\nothers are maintained by folks elsewhere.\nAnyone can make rehype plugins, so as always when choosing whether to include\ndependencies in your project, make sure to carefully assess the quality of\nrehype plugins too.\n\n## Types\n\nThe rehype organization and the unified collective as a whole is fully typed\nwith [TypeScript][].\nTypes for hast are available in [`@types/hast`][types-hast].\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 compatible with Node.js 16.\n\n## Security\n\nAs improper use of HTML can open you up to a [cross-site scripting (XSS)][xss]\nattacks, use of rehype can also be unsafe.\nUse [`rehype-sanitize`][rehype-sanitize] to make the tree safe.\n\nUse of rehype plugins could also open you up to other attacks.\nCarefully assess each plugin and the risks involved in using them.\n\nFor info on how to submit a report, see our [security policy][security].\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.\nJoin us in [Discussions][chat] to chat with the community and contributors.\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## Sponsor\n\nSupport this effort and give back by sponsoring on [OpenCollective][collective]!\n\n\u003ctable\u003e\n\u003ctr valign=\"middle\"\u003e\n\u003ctd width=\"20%\" align=\"center\" rowspan=\"2\" colspan=\"2\"\u003e\n  \u003ca href=\"https://vercel.com\"\u003eVercel\u003c/a\u003e\u003cbr\u003e\u003cbr\u003e\n  \u003ca href=\"https://vercel.com\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/14985020?s=256\u0026v=4\" width=\"128\"\u003e\u003c/a\u003e\n\u003c/td\u003e\n\u003ctd width=\"20%\" align=\"center\" rowspan=\"2\" colspan=\"2\"\u003e\n  \u003ca href=\"https://motif.land\"\u003eMotif\u003c/a\u003e\u003cbr\u003e\u003cbr\u003e\n  \u003ca href=\"https://motif.land\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/74457950?s=256\u0026v=4\" width=\"128\"\u003e\u003c/a\u003e\n\u003c/td\u003e\n\u003ctd width=\"20%\" align=\"center\" rowspan=\"2\" colspan=\"2\"\u003e\n  \u003ca href=\"https://www.hashicorp.com\"\u003eHashiCorp\u003c/a\u003e\u003cbr\u003e\u003cbr\u003e\n  \u003ca href=\"https://www.hashicorp.com\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/761456?s=256\u0026v=4\" width=\"128\"\u003e\u003c/a\u003e\n\u003c/td\u003e\n\u003ctd width=\"20%\" align=\"center\" rowspan=\"2\" colspan=\"2\"\u003e\n  \u003ca href=\"https://www.gitbook.com\"\u003eGitBook\u003c/a\u003e\u003cbr\u003e\u003cbr\u003e\n  \u003ca href=\"https://www.gitbook.com\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/7111340?s=256\u0026v=4\" width=\"128\"\u003e\u003c/a\u003e\n\u003c/td\u003e\n\u003ctd width=\"20%\" align=\"center\" rowspan=\"2\" colspan=\"2\"\u003e\n  \u003ca href=\"https://www.gatsbyjs.org\"\u003eGatsby\u003c/a\u003e\u003cbr\u003e\u003cbr\u003e\n  \u003ca href=\"https://www.gatsbyjs.org\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/12551863?s=256\u0026v=4\" width=\"128\"\u003e\u003c/a\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr valign=\"middle\"\u003e\n\u003c/tr\u003e\n\u003ctr valign=\"middle\"\u003e\n\u003ctd width=\"20%\" align=\"center\" rowspan=\"2\" colspan=\"2\"\u003e\n  \u003ca href=\"https://www.netlify.com\"\u003eNetlify\u003c/a\u003e\u003cbr\u003e\u003cbr\u003e\n  \u003c!--OC has a sharper image--\u003e\n  \u003ca href=\"https://www.netlify.com\"\u003e\u003cimg src=\"https://images.opencollective.com/netlify/4087de2/logo/256.png\" width=\"128\"\u003e\u003c/a\u003e\n\u003c/td\u003e\n\u003ctd width=\"10%\" align=\"center\"\u003e\n  \u003ca href=\"https://www.coinbase.com\"\u003eCoinbase\u003c/a\u003e\u003cbr\u003e\u003cbr\u003e\n  \u003ca href=\"https://www.coinbase.com\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/1885080?s=256\u0026v=4\" width=\"64\"\u003e\u003c/a\u003e\n\u003c/td\u003e\n\u003ctd width=\"10%\" align=\"center\"\u003e\n  \u003ca href=\"https://themeisle.com\"\u003eThemeIsle\u003c/a\u003e\u003cbr\u003e\u003cbr\u003e\n  \u003ca href=\"https://themeisle.com\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/58979018?s=128\u0026v=4\" width=\"64\"\u003e\u003c/a\u003e\n\u003c/td\u003e\n\u003ctd width=\"10%\" align=\"center\"\u003e\n  \u003ca href=\"https://expo.io\"\u003eExpo\u003c/a\u003e\u003cbr\u003e\u003cbr\u003e\n  \u003ca href=\"https://expo.io\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/12504344?s=128\u0026v=4\" width=\"64\"\u003e\u003c/a\u003e\n\u003c/td\u003e\n\u003ctd width=\"10%\" align=\"center\"\u003e\n  \u003ca href=\"https://boostnote.io\"\u003eBoost Note\u003c/a\u003e\u003cbr\u003e\u003cbr\u003e\n  \u003ca href=\"https://boostnote.io\"\u003e\u003cimg src=\"https://images.opencollective.com/boosthub/6318083/logo/128.png\" width=\"64\"\u003e\u003c/a\u003e\n\u003c/td\u003e\n\u003ctd width=\"10%\" align=\"center\"\u003e\n  \u003ca href=\"https://markdown.space\"\u003eMarkdown Space\u003c/a\u003e\u003cbr\u003e\u003cbr\u003e\n  \u003ca href=\"https://markdown.space\"\u003e\u003cimg src=\"https://images.opencollective.com/markdown-space/e1038ed/logo/128.png\" width=\"64\"\u003e\u003c/a\u003e\n\u003c/td\u003e\n\u003ctd width=\"10%\" align=\"center\"\u003e\n  \u003ca href=\"https://www.holloway.com\"\u003eHolloway\u003c/a\u003e\u003cbr\u003e\u003cbr\u003e\n  \u003ca href=\"https://www.holloway.com\"\u003e\u003cimg src=\"https://avatars1.githubusercontent.com/u/35904294?s=128\u0026v=4\" width=\"64\"\u003e\u003c/a\u003e\n\u003c/td\u003e\n\u003ctd width=\"10%\"\u003e\u003c/td\u003e\n\u003ctd width=\"10%\"\u003e\u003c/td\u003e\n\u003c/tr\u003e\n\u003ctr valign=\"middle\"\u003e\n\u003ctd width=\"100%\" align=\"center\" colspan=\"8\"\u003e\n  \u003cbr\u003e\n  \u003ca href=\"https://opencollective.com/unified\"\u003e\u003cstrong\u003eYou?\u003c/strong\u003e\u003c/a\u003e\n  \u003cbr\u003e\u003cbr\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n\u003c!-- Definitions --\u003e\n\n[logo]: https://raw.githubusercontent.com/rehypejs/rehype/cb624bd/logo.svg?sanitize=true\n\n[build-badge]: https://github.com/rehypejs/rehype/workflows/main/badge.svg\n\n[build]: https://github.com/rehypejs/rehype/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype.svg\n\n[coverage]: https://codecov.io/github/rehypejs/rehype\n\n[downloads-badge]: https://img.shields.io/npm/dm/rehype.svg\n\n[downloads]: https://www.npmjs.com/package/rehype\n\n[size-badge]: https://img.shields.io/bundlejs/size/rehype\n\n[size]: https://bundlejs.com/?q=rehype\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[health]: https://github.com/rehypejs/.github\n\n[security]: https://github.com/rehypejs/.github/blob/main/security.md\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[unified]: https://github.com/unifiedjs/unified\n\n[types-hast]: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/hast\n\n[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n\n[typescript]: https://www.typescriptlang.org\n\n[mdn]: https://developer.mozilla.org/docs/Web/HTML\n\n[html]: https://html.spec.whatwg.org/multipage/\n\n[site]: https://unifiedjs.com\n\n[topic]: https://github.com/topics/rehype-plugin\n\n[hast]: https://github.com/syntax-tree/hast\n\n[awesome-rehype]: https://github.com/rehypejs/awesome-rehype\n\n[rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize\n\n[rehype-parse]: packages/rehype-parse/\n\n[rehype-stringify]: packages/rehype-stringify/\n\n[rehype-core]: packages/rehype/\n\n[rehype-cli]: packages/rehype-cli/\n\n[list-of-plugins]: doc/plugins.md#list-of-plugins\n\n[contribute]: #contribute\n\n[sponsor]: #sponsor\n","funding_links":["https://github.com/sponsors/unifiedjs","https://opencollective.com/unified"],"categories":["JavaScript","Syntaxes","javascript","Official"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frehypejs%2Frehype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frehypejs%2Frehype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frehypejs%2Frehype/lists"}