项目
在 GitHub 查看
Thinkmill/react-markings
关于
在 <Components/> 中使用 **Markdown**,也能在 **Markdown** 中使用 <Components/>。
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Recommendation: Use MDX, it's the same thing, but better
(Although this library may be easier for you to integrate while MDX tools get built)
react-markings
Markdown in components, components in markdown
- Allows you to write markdown using commonmark.js
- Renders markdown as React elements using commonmark-react-renderer
- Embed React components inside your markdown (in any paragraph position) like this:
import * as React from 'react';
import md from 'react-markings';
function Example() {
return (
<pre>
<code>...</code>
</pre>
);
}
export default function ReadMe() {
return md`
# react-markings
> Markdown in components, components in markdown
- Allows you to write markdown using [commonmark.js](https://github.com/commonmark/commonmark.js)
- Renders markdown as React elements using [commonmark-react-renderer](https://github.com/rexxars/commonmark-react-renderer)
- Embed React components inside your markdown (in any paragraph position) like this:
${<Example/>}
`;
}
If you want to customize rendering further, you can use customize to pass your
own renderers.
import * as React from 'react';
import md from 'react-markings';
let customMd = md.customize({
renderers: {
// customize heading with class
heading: props => React.createElement('h' + props.level, { className: 'fancy-heading' }, props.children),
},
});
export default function CustomHeading() {
return customMd`
# Fancy Heading
`;
}
探索相关项目
加载中…