Skip to content

Instantly share code, notes, and snippets.

@iksena
Created May 7, 2020 14:53
Show Gist options
  • Save iksena/d5fe5851fc4162ec0902622853f59d42 to your computer and use it in GitHub Desktop.
Save iksena/d5fe5851fc4162ec0902622853f59d42 to your computer and use it in GitHub Desktop.
Markdown with remark-math
import React from 'react';
import ReactMarkdown from 'react-markdown';
import RemarkMathPlugin from 'remark-math';
const _mapProps = (props) => ({
...props,
escapeHtml: false,
plugins: [
RemarkMathPlugin
],
renderers: {
...props.renderers,
math: ({ value }) => `math: ${value}`,
inlineMath: ({ value }) => `inlineMath: ${value}`
}
});
const Markdown = (props) => <ReactMarkdown {..._mapProps(props)} />;
export default Markdown;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment