{"id":14384908,"url":"https://github.com/kitze/react-in-markdown","last_synced_at":"2025-04-13T13:07:52.887Z","repository":{"id":85825327,"uuid":"72094090","full_name":"kitze/react-in-markdown","owner":"kitze","description":"Render custom React components in Markdown","archived":false,"fork":false,"pushed_at":"2019-01-15T10:41:17.000Z","size":11,"stargazers_count":66,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T13:07:44.492Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kitze.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-10-27T09:43:37.000Z","updated_at":"2025-02-11T15:48:55.000Z","dependencies_parsed_at":"2023-05-15T12:30:22.615Z","dependency_job_id":null,"html_url":"https://github.com/kitze/react-in-markdown","commit_stats":{"total_commits":8,"total_committers":2,"mean_commits":4.0,"dds":0.125,"last_synced_commit":"94f143ddbbe081eedbfcdc138040aeddb88eaf72"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitze%2Freact-in-markdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitze%2Freact-in-markdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitze%2Freact-in-markdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kitze%2Freact-in-markdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kitze","download_url":"https://codeload.github.com/kitze/react-in-markdown/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248717242,"owners_count":21150389,"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":[],"created_at":"2024-08-28T18:01:46.298Z","updated_at":"2025-04-13T13:07:52.853Z","avatar_url":"https://github.com/kitze.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"### 🙋‍♂️ Made by [@thekitze](https://twitter.com/thekitze)  \n\n### Other projects:\n- 🏫 [React Academy](https://reactacademy.io) - Interactive React and GraphQL workshops\n- 💌 [Twizzy](https://twizzy.app) - A standalone app for Twitter DM\n- 💻 [Sizzy](https://sizzy.co) - A tool for testing responsive design on multiple devices at once\n- 🤖 [JSUI](https://github.com/kitze/JSUI) - A powerful UI toolkit for managing JavaScript apps\n\n---\n\n# react-in-markdown (DEPRECATED)\nThis library is deprecated and won't be supported anymore. Please use [Marksy](https://github.com/cerebral/marksy) or [MDX](https://github.com/mdx-js/mdx).\n\n### Usage\n\nIt should be used along with the [markdown-to-react-components](https://github.com/christianalfoni/markdown-to-react-components) library\n\n### What does it do?\n\nThis library allows you to render custom React Components when writing Markdown, using a special syntax.\n\n```[emoji](code=fire, size=35)```\n\nThis will render the ```emoji``` component, with ```{code:'fire', size:'35'}``` as props.\n\n\n### How does rendering Markdown to React work?\n\nIn order to render Markdown to React components you should use the [markdown-to-react-components](https://github.com/christianalfoni/markdown-to-react-components) library. Under the hood it's really simple, it uses [marked](https://github.com/chjj/marked) to parse a string that contains Markdown, and it returns back React components.\n\nThe cool thing about the MTRC library is the ```configure``` method which can customize the output of the components. An example:\n\n```js\nimport MTRC from 'markdown-to-react-components';\n\nMTRC.configure({\n  h1: React.createClass({\n    render() {\n      return \u003ch1 id={this.props.id} style={{color: 'red'}}\u003e{this.props.children}\u003c/h1\u003e\n    }\n  })\n});\n```\n\n### How to use react-in-markdown\n\nIn order to render custom React components inside of Markdown, you should plug the ```renderCustomComponents``` method into the configuration of the **```a```** element:\n\n```js\nimport MTRC from 'markdown-to-react-components';\nimport {renderCustomComponents} from 'react-in-markdown';\n\nconst customComponents = {\n\temoji: ({code,size}) =\u003e \u003cdiv style={{fontSize:size}}\u003e {code} \u003c/div\u003e,\n\tawesomeHeader: ({size=22, children}) =\u003e \u003ch1\u003e style={{fontSize:size}}\u003echildren \u003c/h1\u003e\n};\n\nMTRC.configure({\n  a: props =\u003e renderCustomComponents(props, customComponents)\n});\n```\n\nSo when the parser finds the anchor syntax ```[emoji](code=fire,size=35)``` it will try to check if ```emoji``` is a key in our ```customComponents``` object. In this case, ```emoji``` is a key in our ```customComponents``` object, so it will render that component with the props.\n\nBut if we have a regular link like ```[Kitze.io](http://kitze.io)```, it will see that ```Kitze.io``` isn't a key in the ```customComponents``` object so it will just render a regular link 👉 [Kitze.io](http://kitze.io)\n\n### ToDo\n\n- Eval props after parsing them so we can use integers, booleans, arrays, and objects as props\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitze%2Freact-in-markdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkitze%2Freact-in-markdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkitze%2Freact-in-markdown/lists"}