{"id":19533958,"url":"https://github.com/rafgraph/react-markdown-tree","last_synced_at":"2025-07-25T07:33:59.286Z","repository":{"id":57334323,"uuid":"90655426","full_name":"rafgraph/react-markdown-tree","owner":"rafgraph","description":"Renders markdown as React components and never uses dangerouslySetInnerHTML","archived":false,"fork":false,"pushed_at":"2020-10-02T02:41:16.000Z","size":636,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-04T19:07:47.883Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://react-markdown-tree.rafgraph.dev","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/rafgraph.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-08T17:36:51.000Z","updated_at":"2024-11-17T14:10:27.000Z","dependencies_parsed_at":"2022-08-31T18:50:49.944Z","dependency_job_id":null,"html_url":"https://github.com/rafgraph/react-markdown-tree","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/rafgraph/react-markdown-tree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafgraph%2Freact-markdown-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafgraph%2Freact-markdown-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafgraph%2Freact-markdown-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafgraph%2Freact-markdown-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rafgraph","download_url":"https://codeload.github.com/rafgraph/react-markdown-tree/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafgraph%2Freact-markdown-tree/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266973330,"owners_count":24014676,"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","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-11T02:11:27.948Z","updated_at":"2025-07-25T07:33:59.258Z","avatar_url":"https://github.com/rafgraph.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Markdown Tree\n\n[Demo website](https://react-markdown-tree.rafgraph.dev) (demo code on [`gh-pages` branch](https://github.com/rafgraph/react-markdown-tree/tree/gh-pages))\n\nReact Markdown Tree renders markdown as customizable React components and *never* uses `dangerouslySetInnerHTML`.\n- Renders markdown according to the [CommonMark spec](https://commonmark.org/) (powered by [`commonmark.js`](https://github.com/jgm/commonmark.js) and [`commonmark-react-renderer`](https://github.com/rexxars/commonmark-react-renderer)).\n- Create your own renderers as React components for custom styling or use [`react-markdown-tree-config-default`](https://github.com/rafgraph/react-markdown-tree-config-default) for zero setup default styling with syntax highlighting.\n- Easy to use provider/child pattern - set the config once in `\u003cMarkdownProvider\u003e` and use `\u003cMarkdown\u003e` anywhere in your app with zero props.\n\n```shell\n$ yarn add react-markdown-tree\n# OR\n$ npm install --save react-markdown-tree\n```\n\n```shell\n# to use with the default config:\n$ yarn add react-markdown-tree-config-default\n# OR\n$ npm install --save react-markdown-tree-config-default\n```\n\n```js\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport { MarkdownProvider } from 'react-markdown-tree';\nimport markdownConfig from 'react-markdown-tree-config-default';\nimport App from './App';\n\nReactDOM.render(\n  \u003cMarkdownProvider config={markdownConfig}\u003e\n    \u003cApp /\u003e\n  \u003c/MarkdownProvider\u003e,\n  document.getElementById('root'),\n);\n```\n\n\n```js\n// App.js or any component that is a child of \u003cMarkdownProvider\u003e\nimport { Markdown } from 'react-markdown-tree';\n...\n\nrender() {\n  return (\n    \u003cMarkdown\u003e\n      {this.state.stringInMarkdownFormat /* any string containing the markdown source to render */}\n    \u003c/Markdown\u003e\n  );\n}\n```\n\nYou can also use the UMD build that's available from Unpkg:\n```html\n\u003c!-- Available at window.ReactMarkdownTree --\u003e\n\u003cscript src=\"https://unpkg.com/react-markdown-tree/dist/react-markdown-tree.min.js\"\u003e\u003c/script\u003e\n\n\u003c!-- Available at window.ReactMarkdownTreeConfigDefault --\u003e\n\u003cscript src=\"https://unpkg.com/react-markdown-tree-config-default/dist/react-markdown-tree-config-default.min.js\"\u003e\u003c/script\u003e\n```\n\n## API\n\n### `\u003cMarkdown\u003e`\n#### `children: string`\n- String containing the markdown source to render\n- Not required, but if not provided `\u003cMarkdown\u003e` returns `null` and does not render\n\n#### `as: string | ReactComponent`\n- Not required, default is `'div'`\n- What the markdown container element is rendered as\n- String as an html tag name, e.g. `'div'` will render a `\u003cdiv\u003e` container, `'section'` will render a `\u003csection\u003e` container, etc...\n- By default the container is rendered as a `\u003cdiv\u003e`\n- If you provide a `ReactComponent` instead of a string, the rendered markdown will be passed down as an array of `children` to that component\n\n#### `...rest`\n- All other props will be passed down to the markdown container element, e.g. `className`, `style`, etc...\n\n#### For Example\n- `\u003cMarkdown as=\"section\" className=\"some-markdown\"\u003e# Some Heading\u003c/Markdown\u003e` will render on the page as `\u003csection class=\"some-markdown\"\u003e\u003ch1\u003eSome Heading\u003c/h1\u003e\u003csection/\u003e`\n\n### `\u003cMarkdownProvider\u003e`\n#### `config: object`\n- Not required, but if it is not provided unstyled html will be rendered\n- Object with keys for `renderers` and `containerProps`\n- Note that you can only set the config once when the `\u003cMarkdownProvider\u003e` is mounted, and you cannot change the config once it has been set.\n- For a reference config with unstyled renderers see [`referenceMarkdownConfigWithUnstyledRenderers.js`](https://github.com/rafgraph/react-markdown-tree/blob/main/reference/referenceMarkdownConfigWithUnstyledRenderers.js)\n```js\nconst config = {\n  renderers: {\n    Heading: /* ReactComponent */,\n    Paragraph: /* ReactComponent */,\n    Link: /* ReactComponent */,\n    Image: /* ReactComponent */,\n    List: /* ReactComponent */,\n    Item: /* ReactComponent */,\n    BlockQuote: /* ReactComponent */,\n    Emph: /* ReactComponent */,\n    Strong: /* ReactComponent */,\n    Softbreak: /* ReactComponent */,\n    Linebreak: /* ReactComponent */,\n    ThematicBreak: /* ReactComponent */,\n    Code: /* ReactComponent */,\n    CodeBlock: /* ReactComponent */,\n  },\n  containerProps: {\n    // default props passed down to every instance of \u003cMarkdown\u003e\n    // see \u003cMarkdown\u003e API for prop definitions\n  },\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafgraph%2Freact-markdown-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frafgraph%2Freact-markdown-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafgraph%2Freact-markdown-tree/lists"}