@aligov/markdown-render
带语法高亮的 markdown 渲染组件
参数名 | 说明 | 必填 | 类型 | 默认值 | 备注 |
---|---|---|---|---|---|
content | 内容 | 是 | String | "" |
本 Demo 演示一行文字的用法。
import React, { Component } from "react";
import ReactDOM from "react-dom";
import MarkdownRender from "@aligov/markdown-render";
// 引入代码高亮样式 具体见 https://unpkg.com/browse/prismjs@1.17.1/themes/
import "prismjs/themes/prism.css";
const md = `
# 123
## 456
*123445*
- 1
- 2
- 3
\`\`\`Javascript
cosnt val = 1;
\`\`\`
# 123
\`\`\`CSS
.h1 {color: red;}
\`\`\`
`;
class App extends Component {
render() {
return (
<div>
<MarkdownRender content={md} className="md-render"/>
</div>
);
}
}
ReactDOM.render(<App />, mountNode);