{"author":{"name":"Espen Hovlandsdal","email":"espen@hovlandsdal.com"},"bugs":{"url":"https://github.com/remarkjs/react-markdown/issues"},"contributors":[{"name":"Alexander Wallin","email":"office@alexanderwallin.com"},{"name":"Alexander Wong","email":"admin@alexander-wong.com"},{"name":"André Staltz","email":"andre@staltz.com"},{"name":"Angus MacIsaac","email":"angus.macisaac@busbud.com"},{"name":"Beau Roberts","email":"beau.roberts@autodesk.com"},{"name":"Charlie Chen","email":"doveccl@live.com"},{"name":"Christian Murphy","email":"christian.murphy.42@gmail.com"},{"name":"Christoph Werner","email":"christoph@codepunkt.de"},{"name":"Danny","email":"dannyharding10@gmail.com"},{"name":"Dennis S","email":"denis.s@svsg.co"},{"name":"Espen Hovlandsdal","email":"espen@hovlandsdal.com"},{"name":"Evan Hensleigh","email":"futuraprime@gmail.com"},{"name":"Fabian Irsara","email":"info@fabianirsara.com"},{"name":"Florentin Luca Rieger","email":"florentin.rieger@gmail.com"},{"name":"Frank","email":"frankieali4@gmail.com"},{"name":"Igor Kamyshev","email":"garik.novel@gmail.com"},{"name":"Jack Williams","email":"jsw547@gmail.com"},{"name":"Jakub Chrzanowski","email":"jakub@chrzanowski.info"},{"name":"Jeremy Moseley","email":"jeremy@jeremymoseley.net"},{"name":"Jesse Pinho","email":"jesse@jessepinho.com"},{"name":"Kelvin Chan","email":"kchan@securitycompass.com"},{"name":"Kohei Asai","email":"me@axross.io"},{"name":"Linus Unnebäck","email":"linus@folkdatorn.se"},{"name":"Marshall Smith","email":"marshall@radialdevgroup.com"},{"name":"Nathan Bierema","email":"nbierema@gmail.com"},{"name":"Nicolas Venegas","email":"nvenegas@atlassian.com"},{"name":"Peng Guanwen","email":"pg999w@outlook.com"},{"name":"Petr Gazarov","email":"petrgazarov@gmail.com"},{"name":"Phil Rajchgot","email":"tophil@outlook.com"},{"name":"Rasmus Eneman","email":"rasmus@eneman.eu"},{"name":"René Kooi","email":"renee@kooi.me"},{"name":"Riku Rouvila","email":"riku.rouvila@gmail.com"},{"name":"Robin Wieruch","email":"wrobin@gmx.net"},{"name":"Rostyslav Melnychuk","email":"blackswordgc@gmail.com"},{"name":"Ted Piotrowski","email":"tppiotrowski@gmail.com"},{"name":"Thibaud Courtoison","email":"do.not.press.enter@gmail.com"},{"name":"Thomas Lindstrøm","email":"t@hom.as"},{"name":"Tiago Roldão","email":"focus5.6@gmail.com"},{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},{"name":"cerkiewny","email":"mstarzycki@gmail.com"},{"name":"evoye","email":"rosej@gmx.net"},{"name":"gRoberts84","email":"gavin@gav-roberts.co.uk"},{"name":"mudrz","email":"mudrz@outlook.com"},{"name":"vanchagreen","email":"vanchagreen@gmail.com"}],"dependencies":{"@types/hast":"^3.0.0","@types/mdast":"^4.0.0","devlop":"^1.0.0","hast-util-to-jsx-runtime":"^2.0.0","html-url-attributes":"^3.0.0","mdast-util-to-hast":"^13.0.0","remark-parse":"^11.0.0","remark-rehype":"^11.0.0","unified":"^11.0.0","unist-util-visit":"^5.0.0","vfile":"^6.0.0"},"description":"React component to render markdown","devDependencies":{"@testing-library/react":"^16.0.0","@types/node":"^22.0.0","@types/react":"^19.0.0","@types/react-dom":"^19.0.0","c8":"^10.0.0","concat-stream":"^2.0.0","esbuild":"^0.25.0","eslint-plugin-react":"^7.0.0","global-jsdom":"^26.0.0","prettier":"^3.0.0","react":"^19.0.0","react-dom":"^19.0.0","rehype-raw":"^7.0.0","rehype-starry-night":"^2.0.0","remark-cli":"^12.0.0","remark-gfm":"^4.0.0","remark-preset-wooorm":"^11.0.0","remark-toc":"^9.0.0","type-coverage":"^2.0.0","typescript":"^5.0.0","xo":"^0.60.0"},"exports":"./index.js","funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"keywords":["ast","commonmark","component","gfm","markdown","react","react-component","remark","unified"],"license":"MIT","name":"react-markdown","peerDependencies":{"@types/react":">=18","react":">=18"},"prettier":{"bracketSpacing":false,"singleQuote":true,"semi":false,"tabWidth":2,"trailingComma":"none","useTabs":false},"remarkConfig":{"plugins":["remark-preset-wooorm",["remark-lint-no-html",false]]},"repository":{"type":"git","url":"git+https://github.com/remarkjs/react-markdown.git"},"scripts":{"build":"tsc --build --clean && tsc --build && type-coverage","format":"remark --frail --output --quiet -- . && prettier --log-level warn --write -- . && xo --fix","test-api":"node --conditions development --experimental-loader=./script/load-jsx.js --no-warnings test.jsx","test-coverage":"c8 --100 --exclude script/ --reporter lcov -- npm run test-api","test":"npm run build && npm run format && npm run test-coverage"},"sideEffects":false,"typeCoverage":{"atLeast":100,"strict":true},"type":"module","version":"10.1.0","xo":{"envs":["shared-node-browser"],"extends":"plugin:react/jsx-runtime","overrides":[{"files":["**/*.jsx"],"rules":{"no-unused-vars":"off"}}],"prettier":true,"rules":{"complexity":"off","n/file-extension-in-import":"off","unicorn/prevent-abbreviations":"off"}},"_id":"react-markdown@10.1.0","gitHead":"44d2e4a44b37461ab7778d6870c1a9eb36393ad2","types":"./index.d.ts","homepage":"https://github.com/remarkjs/react-markdown#readme","_nodeVersion":"23.1.0","_npmVersion":"11.1.0","dist":{"integrity":"sha512-qKxVopLT/TyA6BX3Ue5NwabOsAzm0Q7kAPwq6L+wWDwisYs7R8vZ0nRXqq6rkueboxpkjvLGU9fWifiX/ZZFxQ==","shasum":"e22bc20faddbc07605c15284255653c0f3bad5ca","tarball":"http://registry-npm.ywwl.com/react-markdown/download/react-markdown-10.1.0.tgz","fileCount":9,"unpackedSize":52637,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFDa5w8PqqBGqoR+fKkd5YDj+MX231iD0jgUj71QqiQ2AiB37cB2Ja1dNCn3pISsxSPUlxzwpurt5S8TvMGRQLN15Q=="}],"size":15544,"noattachment":false,"key":"/react-markdown/-/react-markdown-10.1.0.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"johno","email":"johnotander@gmail.com"},{"name":"wooorm","email":"tituswormer@gmail.com"},{"name":"remcohaszing","email":"remcohaszing@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/react-markdown_10.1.0_1741343573010_0.4288439221247293"},"_hasShrinkwrap":false,"readme":"<!--\n  Notes for maintaining this document:\n\n  * update the version of the link for `commonmark-html` once in a while\n-->\n\n# react-markdown\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\nReact component to render markdown.\n\n## Feature highlights\n\n* [x] **[safe][section-security] by default**\n  (no `dangerouslySetInnerHTML` or XSS attacks)\n* [x] **[components][section-components]**\n  (pass your own component to use instead of `<h2>` for `## hi`)\n* [x] **[plugins][section-plugins]**\n  (many plugins you can pick and choose from)\n* [x] **[compliant][section-syntax]**\n  (100% to CommonMark, 100% to GFM with a plugin)\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  * [`Markdown`](#markdown)\n  * [`MarkdownAsync`](#markdownasync)\n  * [`MarkdownHooks`](#markdownhooks)\n  * [`defaultUrlTransform(url)`](#defaulturltransformurl)\n  * [`AllowElement`](#allowelement)\n  * [`Components`](#components)\n  * [`ExtraProps`](#extraprops)\n  * [`HooksOptions`](#hooksoptions)\n  * [`Options`](#options)\n  * [`UrlTransform`](#urltransform)\n* [Examples](#examples)\n  * [Use a plugin](#use-a-plugin)\n  * [Use a plugin with options](#use-a-plugin-with-options)\n  * [Use custom components (syntax highlight)](#use-custom-components-syntax-highlight)\n  * [Use remark and rehype plugins (math)](#use-remark-and-rehype-plugins-math)\n* [Plugins](#plugins)\n* [Syntax](#syntax)\n* [Compatibility](#compatibility)\n* [Architecture](#architecture)\n* [Appendix A: HTML in markdown](#appendix-a-html-in-markdown)\n* [Appendix B: Components](#appendix-b-components)\n* [Appendix C: line endings in markdown (and JSX)](#appendix-c-line-endings-in-markdown-and-jsx)\n* [Security](#security)\n* [Related](#related)\n* [Contribute](#contribute)\n* [License](#license)\n\n## What is this?\n\nThis package is a [React][] component that can be given a string of markdown\nthat it’ll safely render to React elements.\nYou can pass plugins to change how markdown is transformed and pass components\nthat will be used instead of normal HTML elements.\n\n* to learn markdown, see this [cheatsheet and tutorial][commonmark-help]\n* to try out `react-markdown`, see [our demo][github-io-react-markdown]\n\n## When should I use this?\n\nThere are other ways to use markdown in React out there so why use this one?\nThe three main reasons are that they often rely on `dangerouslySetInnerHTML`,\nhave bugs with how they handle markdown, or don’t let you swap elements for\ncomponents.\n`react-markdown` builds a virtual DOM, so React only replaces what changed,\nfrom a syntax tree.\nThat’s supported because we use [unified][github-unified],\nspecifically [remark][github-remark] for markdown and [rehype][github-rehype]\nfor HTML,\nwhich are popular tools to transform content with plugins.\n\nThis package focusses on making it easy for beginners to safely use markdown in\nReact.\nWhen you’re familiar with unified, you can use a modern hooks based alternative\n[`react-remark`][github-react-remark] or [`rehype-react`][github-rehype-react]\nmanually.\nIf you instead want to use JavaScript and JSX *inside* markdown files, use\n[MDX][github-mdx].\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 16+), install with [npm][npm-install]:\n\n```sh\nnpm install react-markdown\n```\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```js\nimport Markdown from 'https://esm.sh/react-markdown@10'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n<script type=\"module\">\n  import Markdown from 'https://esm.sh/react-markdown@10?bundle'\n</script>\n```\n\n## Use\n\nA basic hello world:\n\n```js\nimport React from 'react'\nimport {createRoot} from 'react-dom/client'\nimport Markdown from 'react-markdown'\n\nconst markdown = '# Hi, *Pluto*!'\n\ncreateRoot(document.body).render(<Markdown>{markdown}</Markdown>)\n```\n\n<details>\n<summary>Show equivalent JSX</summary>\n\n```js\n<h1>\n  Hi, <em>Pluto</em>!\n</h1>\n```\n\n</details>\n\nHere is an example that shows how to use a plugin\n([`remark-gfm`][github-remark-gfm],\nwhich adds support for footnotes, strikethrough, tables, tasklists and\nURLs directly):\n\n```js\nimport React from 'react'\nimport {createRoot} from 'react-dom/client'\nimport Markdown from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\n\nconst markdown = `Just a link: www.nasa.gov.`\n\ncreateRoot(document.body).render(\n  <Markdown remarkPlugins={[remarkGfm]}>{markdown}</Markdown>\n)\n```\n\n<details>\n<summary>Show equivalent JSX</summary>\n\n```js\n<p>\n  Just a link: <a href=\"http://www.nasa.gov\">www.nasa.gov</a>.\n</p>\n```\n\n</details>\n\n## API\n\nThis package exports the identifiers\n[`MarkdownAsync`][api-markdown-async],\n[`MarkdownHooks`][api-markdown-hooks],\nand\n[`defaultUrlTransform`][api-default-url-transform].\nThe default export is [`Markdown`][api-markdown].\n\nIt also exports the additional [TypeScript][] types\n[`AllowElement`][api-allow-element],\n[`Components`][api-components],\n[`ExtraProps`][api-extra-props],\n[`HooksOptions`][api-hooks-options],\n[`Options`][api-options],\nand\n[`UrlTransform`][api-url-transform].\n\n### `Markdown`\n\nComponent to render markdown.\n\nThis is a synchronous component.\nWhen using async plugins,\nsee [`MarkdownAsync`][api-markdown-async] or\n[`MarkdownHooks`][api-markdown-hooks].\n\n###### Parameters\n\n* `options` ([`Options`][api-options])\n  — props\n\n###### Returns\n\nReact element (`ReactElement`).\n\n### `MarkdownAsync`\n\nComponent to render markdown with support for async plugins\nthrough async/await.\n\nComponents returning promises are supported on the server.\nFor async support on the client,\nsee [`MarkdownHooks`][api-markdown-hooks].\n\n###### Parameters\n\n* `options` ([`Options`][api-options])\n  — props\n\n###### Returns\n\nPromise to a React element (`Promise<ReactElement>`).\n\n### `MarkdownHooks`\n\nComponent to render markdown with support for async plugins through hooks.\n\nThis uses `useEffect` and `useState` hooks.\nHooks run on the client and do not immediately render something.\nFor async support on the server,\nsee [`MarkdownAsync`][api-markdown-async].\n\n###### Parameters\n\n* `options` ([`Options`][api-options])\n  — props\n\n###### Returns\n\nReact node (`ReactNode`).\n\n### `defaultUrlTransform(url)`\n\nMake a URL safe.\n\n###### Parameters\n\n* `url` (`string`)\n  — URL\n\n###### Returns\n\nSafe URL (`string`).\n\n### `AllowElement`\n\nFilter elements (TypeScript type).\n\n###### Parameters\n\n* `node` ([`Element` from `hast`][github-hast-element])\n  — element to check\n* `index` (`number | undefined`)\n  — index of `element` in `parent`\n* `parent` ([`Node` from `hast`][github-hast-nodes])\n  — parent of `element`\n\n###### Returns\n\nWhether to allow `element` (`boolean`, optional).\n\n### `Components`\n\nMap tag names to components (TypeScript type).\n\n###### Type\n\n```ts\nimport type {ExtraProps} from 'react-markdown'\nimport type {ComponentProps, ElementType} from 'react'\n\ntype Components = {\n  [Key in Extract<ElementType, string>]?: ElementType<ComponentProps<Key> & ExtraProps>\n}\n```\n\n### `ExtraProps`\n\nExtra fields we pass to components (TypeScript type).\n\n###### Fields\n\n* `node` ([`Element` from `hast`][github-hast-element], optional)\n  — original node\n\n### `HooksOptions`\n\nConfiguration for [`MarkdownHooks`][api-markdown-hooks] (TypeScript type);\nextends the regular [`Options`][api-options] with a `fallback` prop.\n\n###### Extends\n\n[`Options`][api-options].\n\n###### Fields\n\n* `fallback` (`ReactNode`, optional)\n  — content to render while the processor processing the markdown\n\n### `Options`\n\nConfiguration (TypeScript type).\n\n###### Fields\n\n* `allowElement` ([`AllowElement`][api-allow-element], optional)\n  — filter elements;\n  `allowedElements` / `disallowedElements` is used first\n* `allowedElements` (`Array<string>`, default: all tag names)\n  — tag names to allow;\n  cannot combine w/ `disallowedElements`\n* `children` (`string`, optional)\n  — markdown\n* `components` ([`Components`][api-components], optional)\n  — map tag names to components\n* `disallowedElements` (`Array<string>`, default: `[]`)\n  — tag names to disallow;\n  cannot combine w/ `allowedElements`\n* `rehypePlugins` (`Array<Plugin>`, optional)\n  — list of [rehype plugins][github-rehype-plugins] to use\n* `remarkPlugins` (`Array<Plugin>`, optional)\n  — list of [remark plugins][github-remark-plugins] to use\n* `remarkRehypeOptions`\n  ([`Options` from `remark-rehype`][github-remark-rehype-options],\n  optional)\n  — options to pass through to `remark-rehype`\n* `skipHtml` (`boolean`, default: `false`)\n  — ignore HTML in markdown completely\n* `unwrapDisallowed` (`boolean`, default: `false`)\n  — extract (unwrap) what’s in disallowed elements;\n  normally when say `strong` is not allowed, it and it’s children are dropped,\n  with `unwrapDisallowed` the element itself is replaced by its children\n* `urlTransform` ([`UrlTransform`][api-url-transform], default:\n  [`defaultUrlTransform`][api-default-url-transform])\n  — change URLs\n\n### `UrlTransform`\n\nTransform URLs (TypeScript type).\n\n###### Parameters\n\n* `url` (`string`)\n  — URL\n* `key` (`string`, example: `'href'`)\n  — property name\n* `node` ([`Element` from `hast`][github-hast-element])\n  — element to check\n\n###### Returns\n\nTransformed URL (`string`, optional).\n\n## Examples\n\n### Use a plugin\n\nThis example shows how to use a remark plugin.\nIn this case, [`remark-gfm`][github-remark-gfm],\nwhich adds support for strikethrough, tables, tasklists and URLs directly:\n\n```js\nimport React from 'react'\nimport {createRoot} from 'react-dom/client'\nimport Markdown from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\n\nconst markdown = `A paragraph with *emphasis* and **strong importance**.\n\n> A block quote with ~strikethrough~ and a URL: https://reactjs.org.\n\n* Lists\n* [ ] todo\n* [x] done\n\nA table:\n\n| a | b |\n| - | - |\n`\n\ncreateRoot(document.body).render(\n  <Markdown remarkPlugins={[remarkGfm]}>{markdown}</Markdown>\n)\n```\n\n<details>\n<summary>Show equivalent JSX</summary>\n\n```js\n<>\n  <p>\n    A paragraph with <em>emphasis</em> and <strong>strong importance</strong>.\n  </p>\n  <blockquote>\n    <p>\n      A block quote with <del>strikethrough</del> and a URL:{' '}\n      <a href=\"https://reactjs.org\">https://reactjs.org</a>.\n    </p>\n  </blockquote>\n  <ul className=\"contains-task-list\">\n    <li>Lists</li>\n    <li className=\"task-list-item\">\n      <input type=\"checkbox\" disabled /> todo\n    </li>\n    <li className=\"task-list-item\">\n      <input type=\"checkbox\" disabled checked /> done\n    </li>\n  </ul>\n  <p>A table:</p>\n  <table>\n    <thead>\n      <tr>\n        <th>a</th>\n        <th>b</th>\n      </tr>\n    </thead>\n  </table>\n</>\n```\n\n</details>\n\n### Use a plugin with options\n\nThis example shows how to use a plugin and give it options.\nTo do that, use an array with the plugin at the first place, and the options\nsecond.\n[`remark-gfm`][github-remark-gfm] has an option to allow only double tildes for\nstrikethrough:\n\n```js\nimport React from 'react'\nimport {createRoot} from 'react-dom/client'\nimport Markdown from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\n\nconst markdown = 'This ~is not~ strikethrough, but ~~this is~~!'\n\ncreateRoot(document.body).render(\n  <Markdown remarkPlugins={[[remarkGfm, {singleTilde: false}]]}>\n    {markdown}\n  </Markdown>\n)\n```\n\n<details>\n<summary>Show equivalent JSX</summary>\n\n```js\n<p>\n  This ~is not~ strikethrough, but <del>this is</del>!\n</p>\n```\n\n</details>\n\n### Use custom components (syntax highlight)\n\nThis example shows how you can overwrite the normal handling of an element by\npassing a component.\nIn this case, we apply syntax highlighting with the seriously super amazing\n[`react-syntax-highlighter`][github-react-syntax-highlighter] by\n[**@conorhastings**][github-conorhastings]:\n\n<!-- To do: currently broken on actual ESM; let’s find an alternative? -->\n\n```js\nimport React from 'react'\nimport {createRoot} from 'react-dom/client'\nimport Markdown from 'react-markdown'\nimport {Prism as SyntaxHighlighter} from 'react-syntax-highlighter'\nimport {dark} from 'react-syntax-highlighter/dist/esm/styles/prism'\n\n// Did you know you can use tildes instead of backticks for code in markdown? ✨\nconst markdown = `Here is some JavaScript code:\n\n~~~js\nconsole.log('It works!')\n~~~\n`\n\ncreateRoot(document.body).render(\n  <Markdown\n    children={markdown}\n    components={{\n      code(props) {\n        const {children, className, node, ...rest} = props\n        const match = /language-(\\w+)/.exec(className || '')\n        return match ? (\n          <SyntaxHighlighter\n            {...rest}\n            PreTag=\"div\"\n            children={String(children).replace(/\\n$/, '')}\n            language={match[1]}\n            style={dark}\n          />\n        ) : (\n          <code {...rest} className={className}>\n            {children}\n          </code>\n        )\n      }\n    }}\n  />\n)\n```\n\n<details>\n<summary>Show equivalent JSX</summary>\n\n```js\n<>\n  <p>Here is some JavaScript code:</p>\n  <pre>\n    <SyntaxHighlighter language=\"js\" style={dark} PreTag=\"div\" children=\"console.log('It works!')\" />\n  </pre>\n</>\n```\n\n</details>\n\n### Use remark and rehype plugins (math)\n\nThis example shows how a syntax extension\n(through [`remark-math`][github-remark-math])\nis used to support math in markdown, and a transform plugin\n([`rehype-katex`][github-rehype-katex]) to render that math.\n\n```js\nimport React from 'react'\nimport {createRoot} from 'react-dom/client'\nimport Markdown from 'react-markdown'\nimport rehypeKatex from 'rehype-katex'\nimport remarkMath from 'remark-math'\nimport 'katex/dist/katex.min.css' // `rehype-katex` does not import the CSS for you\n\nconst markdown = `The lift coefficient ($C_L$) is a dimensionless coefficient.`\n\ncreateRoot(document.body).render(\n  <Markdown remarkPlugins={[remarkMath]} rehypePlugins={[rehypeKatex]}>\n    {markdown}\n  </Markdown>\n)\n```\n\n<details>\n<summary>Show equivalent JSX</summary>\n\n```js\n<p>\n  The lift coefficient (\n  <span className=\"katex\">\n    <span className=\"katex-mathml\">\n      <math xmlns=\"http://www.w3.org/1998/Math/MathML\">{/* … */}</math>\n    </span>\n    <span className=\"katex-html\" aria-hidden=\"true\">\n      {/* … */}\n    </span>\n  </span>\n  ) is a dimensionless coefficient.\n</p>\n```\n\n</details>\n\n## Plugins\n\nWe use [unified][github-unified],\nspecifically [remark][github-remark] for markdown and\n[rehype][github-rehype] for HTML,\nwhich are tools to transform content with plugins.\nHere are three good ways to find plugins:\n\n* [`awesome-remark`][github-awesome-remark] and\n  [`awesome-rehype`][github-awesome-rehype]\n  — selection of the most awesome projects\n* [List of remark plugins][github-remark-plugins] and\n  [list of rehype plugins][github-rehype-plugins]\n  — list of all plugins\n* [`remark-plugin`][github-topic-remark-plugin] and\n  [`rehype-plugin`][github-topic-rehype-plugin] topics\n  — any tagged repo on GitHub\n\n## Syntax\n\n`react-markdown` follows CommonMark, which standardizes the differences between\nmarkdown implementations, by default.\nSome syntax extensions are supported through plugins.\n\nWe use [`micromark`][github-micromark] under the hood for our parsing.\nSee its documentation for more information on markdown, CommonMark, and\nextensions.\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, `react-markdown@10`,\ncompatible with Node.js 16.\n\nThey work in all modern browsers (essentially: everything not IE 11).\nYou can use a bundler (such as esbuild, webpack, or Rollup) to use this package\nin your project, and use its options (or plugins) to add support for legacy\nbrowsers.\n\n## Architecture\n\n<pre><code>                                                           react-markdown\n         +----------------------------------------------------------------------------------------------------------------+\n         |                                                                                                                |\n         |  +----------+        +----------------+        +---------------+       +----------------+       +------------+ |\n         |  |          |        |                |        |               |       |                |       |            | |\n<a href=\"https://commonmark.org\">markdown</a>-+->+  <a href=\"https://github.com/remarkjs/remark\">remark</a>  +-<a href=\"https://github.com/syntax-tree/mdast\">mdast</a>->+ <a href=\"https://github.com/remarkjs/remark/blob/main/doc/plugins.md\">remark plugins</a> +-<a href=\"https://github.com/syntax-tree/mdast\">mdast</a>->+ <a href=\"https://github.com/remarkjs/remark-rehype\">remark-rehype</a> +-<a href=\"https://github.com/syntax-tree/hast\">hast</a>->+ <a href=\"https://github.com/rehypejs/rehype/blob/main/doc/plugins.md\">rehype plugins</a> +-<a href=\"https://github.com/syntax-tree/hast\">hast</a>->+ <a href=\"#appendix-b-components\">components</a> +-+->react elements\n         |  |          |        |                |        |               |       |                |       |            | |\n         |  +----------+        +----------------+        +---------------+       +----------------+       +------------+ |\n         |                                                                                                                |\n         +----------------------------------------------------------------------------------------------------------------+\n</code></pre>\n\nTo understand what this project does, it’s important to first understand what\nunified does: please read through the [`unifiedjs/unified`][github-unified]\nreadme\n(the part until you hit the API section is required reading).\n\n`react-markdown` is a unified pipeline — wrapped so that most folks don’t need\nto directly interact with unified.\nThe processor goes through these steps:\n\n* parse markdown to mdast (markdown syntax tree)\n* transform through remark (markdown ecosystem)\n* transform mdast to hast (HTML syntax tree)\n* transform through rehype (HTML ecosystem)\n* render hast to React with components\n\n## Appendix A: HTML in markdown\n\n`react-markdown` typically escapes HTML (or ignores it, with `skipHtml`)\nbecause it is dangerous and defeats the purpose of this library.\n\nHowever, if you are in a trusted environment (you trust the markdown), and\ncan spare the bundle size (±60kb minzipped), then you can use\n[`rehype-raw`][github-rehype-raw]:\n\n```js\nimport React from 'react'\nimport {createRoot} from 'react-dom/client'\nimport Markdown from 'react-markdown'\nimport rehypeRaw from 'rehype-raw'\n\nconst markdown = `<div class=\"note\">\n\nSome *emphasis* and <strong>strong</strong>!\n\n</div>`\n\ncreateRoot(document.body).render(\n  <Markdown rehypePlugins={[rehypeRaw]}>{markdown}</Markdown>\n)\n```\n\n<details>\n<summary>Show equivalent JSX</summary>\n\n```js\n<div className=\"note\">\n  <p>\n    Some <em>emphasis</em> and <strong>strong</strong>!\n  </p>\n</div>\n```\n\n</details>\n\n**Note**: HTML in markdown is still bound by how [HTML works in\nCommonMark][commonmark-html].\nMake sure to use blank lines around block-level HTML that again contains\nmarkdown!\n\n## Appendix B: Components\n\nYou can also change the things that come from markdown:\n\n```js\n<Markdown\n  components={{\n    // Map `h1` (`# heading`) to use `h2`s.\n    h1: 'h2',\n    // Rewrite `em`s (`*like so*`) to `i` with a red foreground color.\n    em(props) {\n      const {node, ...rest} = props\n      return <i style={{color: 'red'}} {...rest} />\n    }\n  }}\n/>\n```\n\nThe keys in components are HTML equivalents for the things you write with\nmarkdown (such as `h1` for `# heading`).\nNormally, in markdown, those are: `a`, `blockquote`, `br`, `code`, `em`, `h1`,\n`h2`, `h3`, `h4`, `h5`, `h6`, `hr`, `img`, `li`, `ol`, `p`, `pre`, `strong`, and\n`ul`.\nWith [`remark-gfm`][github-remark-gfm],\nyou can also use `del`, `input`, `table`, `tbody`, `td`, `th`, `thead`, and `tr`.\nOther remark or rehype plugins that add support for new constructs will also\nwork with `react-markdown`.\n\nThe props that are passed are what you probably would expect: an `a` (link) will\nget `href` (and `title`) props, and `img` (image) an `src`, `alt` and `title`,\netc.\n\nEvery component will receive a `node`.\nThis is the original [`Element` from `hast`][github-hast-element] element being\nturned into a React element.\n\n## Appendix C: line endings in markdown (and JSX)\n\nYou might have trouble with how line endings work in markdown and JSX.\nWe recommend the following, which solves all line ending problems:\n\n```js\n// If you write actual markdown in your code, put your markdown in a variable;\n// **do not indent markdown**:\nconst markdown = `\n# This is perfect!\n`\n\n// Pass the value as an expression as an only child:\nconst result = <Markdown>{markdown}</Markdown>\n```\n\n👆 That works.\nRead on for what doesn’t and why that is.\n\nYou might try to write markdown directly in your JSX and find that it **does\nnot** work:\n\n```js\n<Markdown>\n  # Hi\n\n  This is **not** a paragraph.\n</Markdown>\n```\n\nThe is because in JSX the whitespace (including line endings) is collapsed to\na single space.\nSo the above example is equivalent to:\n\n```js\n<Markdown> # Hi This is **not** a paragraph. </Markdown>\n```\n\nInstead, to pass markdown to `Markdown`, you can use an expression:\nwith a template literal:\n\n```js\n<Markdown>{`\n# Hi\n\nThis is a paragraph.\n`}</Markdown>\n```\n\nTemplate literals have another potential problem, because they keep whitespace\n(including indentation) inside them.\nThat means that the following **does not** turn into a heading:\n\n```js\n<Markdown>{`\n    # This is **not** a heading, it’s an indented code block\n`}</Markdown>\n```\n\n## Security\n\nUse of `react-markdown` is secure by default.\nOverwriting `urlTransform` to something insecure will open you up to XSS\nvectors.\nFurthermore, the `remarkPlugins`, `rehypePlugins`, and `components` you use may\nbe insecure.\n\nTo make sure the content is completely safe, even after what plugins do,\nuse [`rehype-sanitize`][github-rehype-sanitize].\nIt lets you define your own schema of what is and isn’t allowed.\n\n## Related\n\n* [`MDX`][github-mdx]\n  — JSX *in* markdown\n* [`remark-gfm`][github-remark-gfm]\n  — add support for GitHub flavored markdown support\n* [`react-remark`][github-react-remark]\n  — hook based alternative\n* [`rehype-react`][github-rehype-react]\n  — turn HTML into React elements\n\n## Contribute\n\nSee [`contributing.md`][health-contributing] in [`remarkjs/.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, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][file-license] © [Espen Hovlandsdal][author]\n\n[api-allow-element]: #allowelement\n\n[api-components]: #components\n\n[api-default-url-transform]: #defaulturltransformurl\n\n[api-extra-props]: #extraprops\n\n[api-hooks-options]: #hooksoptions\n\n[api-markdown]: #markdown\n\n[api-markdown-async]: #markdownasync\n\n[api-markdown-hooks]: #markdownhooks\n\n[api-options]: #options\n\n[api-url-transform]: #urltransform\n\n[author]: https://espen.codes/\n\n[badge-build-image]: https://github.com/remarkjs/react-markdown/workflows/main/badge.svg\n\n[badge-build-url]: https://github.com/remarkjs/react-markdown/actions\n\n[badge-coverage-image]: https://img.shields.io/codecov/c/github/remarkjs/react-markdown.svg\n\n[badge-coverage-url]: https://codecov.io/github/remarkjs/react-markdown\n\n[badge-downloads-image]: https://img.shields.io/npm/dm/react-markdown.svg\n\n[badge-downloads-url]: https://www.npmjs.com/package/react-markdown\n\n[badge-size-image]: https://img.shields.io/bundlejs/size/react-markdown\n\n[badge-size-url]: https://bundlejs.com/?q=react-markdown\n\n[commonmark-help]: https://commonmark.org/help/\n\n[commonmark-html]: https://spec.commonmark.org/0.31.2/#html-blocks\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[file-license]: license\n\n[github-awesome-rehype]: https://github.com/rehypejs/awesome-rehype\n\n[github-awesome-remark]: https://github.com/remarkjs/awesome-remark\n\n[github-conorhastings]: https://github.com/conorhastings\n\n[github-hast-element]: https://github.com/syntax-tree/hast#element\n\n[github-hast-nodes]: https://github.com/syntax-tree/hast#nodes\n\n[github-io-react-markdown]: https://remarkjs.github.io/react-markdown/\n\n[github-mdx]: https://github.com/mdx-js/mdx/\n\n[github-micromark]: https://github.com/micromark/micromark\n\n[github-react-remark]: https://github.com/remarkjs/react-remark\n\n[github-react-syntax-highlighter]: https://github.com/react-syntax-highlighter/react-syntax-highlighter\n\n[github-rehype]: https://github.com/rehypejs/rehype\n\n[github-rehype-katex]: https://github.com/remarkjs/remark-math/tree/main/packages/rehype-katex\n\n[github-rehype-plugins]: https://github.com/rehypejs/rehype/blob/main/doc/plugins.md#list-of-plugins\n\n[github-rehype-raw]: https://github.com/rehypejs/rehype-raw\n\n[github-rehype-react]: https://github.com/rehypejs/rehype-react\n\n[github-rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize\n\n[github-remark]: https://github.com/remarkjs/remark\n\n[github-remark-gfm]: https://github.com/remarkjs/remark-gfm\n\n[github-remark-math]: https://github.com/remarkjs/remark-math\n\n[github-remark-plugins]: https://github.com/remarkjs/remark/blob/main/doc/plugins.md#list-of-plugins\n\n[github-remark-rehype-options]: https://github.com/remarkjs/remark-rehype#options\n\n[github-topic-rehype-plugin]: https://github.com/topics/rehype-plugin\n\n[github-topic-remark-plugin]: https://github.com/topics/remark-plugin\n\n[github-unified]: https://github.com/unifiedjs/unified\n\n[health]: https://github.com/remarkjs/.github\n\n[health-coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md\n\n[health-contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md\n\n[health-support]: https://github.com/remarkjs/.github/blob/main/support.md\n\n[npm-install]: https://docs.npmjs.com/cli/install\n\n[react]: http://reactjs.org\n\n[section-components]: #appendix-b-components\n\n[section-plugins]: #plugins\n\n[section-security]: #security\n\n[section-syntax]: #syntax\n\n[typescript]: https://www.typescriptlang.org\n","publish_time":1741343573222,"_cnpm_publish_time":1741343573222,"dist-tags":{"latest":"10.1.0","next":"3.0.0-rc4"}}