react-md-renderer
Version:
Simple batteries included rendering library for markdown files.
65 lines • 2.11 kB
JavaScript
import { __assign } from "tslib";
import Link from '@material-ui/core/Link';
import Typography from '@material-ui/core/Typography';
import ReactMarkdown from 'markdown-to-jsx';
import React from 'react';
var defaultOpts = {
overrides: {
h1: {
component: Typography,
props: {
gutterBottom: true,
variant: 'h1'
}
},
h2: {
component: Typography,
props: { gutterBottom: true, variant: 'h2' }
},
h3: {
component: Typography,
props: { gutterBottom: true, variant: 'h3' }
},
h4: {
component: Typography,
props: { gutterBottom: true, variant: 'h4' }
},
h5: {
component: Typography,
props: { gutterBottom: true, variant: 'h5' }
},
h6: {
component: Typography,
props: { gutterBottom: true, variant: 'h6' }
},
p: {
component: Typography,
props: { paragraph: true, variant: 'body1' }
},
a: { component: Link, props: { variant: 'body1' } },
img: {
props: {
style: {
maxWidth: '100%',
height: 'auto',
pointerEvents: 'none',
textAlign: 'center'
},
align: 'center'
}
}
},
forceBlock: true
};
/**
* @name ReactMdRenderer
* @description Render markdown string with stylized defaults. The default styles can be overridden with a custom options param
* @param opts ReactMdRendererOpts
* @returns JSX.Element
*/
export var ReactMdRenderer = function (opts) {
var _a;
var _opts = __assign(__assign({}, opts), { options: __assign(__assign({}, opts.options), { overrides: __assign(__assign({}, defaultOpts.overrides), (_a = opts.options) === null || _a === void 0 ? void 0 : _a.overrides) }) });
return React.createElement(ReactMarkdown, __assign({}, _opts));
};
//# sourceMappingURL=ReactMdRenderer.js.map