Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 8c967b3

Browse files
author
Anders Fredrik Kiær
committed
Math in dcc.Markdown
1 parent cfe5bfa commit 8c967b3

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

demo/Demo.react.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ Some code
5858
\\\`\\\`\\\`
5959
6060
Inline \\\`code\\\` example.
61+
62+
***
63+
64+
Some block mathematics:
65+
66+
$$
67+
e^{ix} = \\\\cos x + i\\\\sin x.
68+
$$
69+
70+
Some inline mathematics $\\\\alpha=2$ and $\\\\beta=3$.
71+
6172
\`
6273
6374
ReactDOM.render(<Markdown>{markdown}</Markdown>, mountNode);

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@
4040
"react-dates": "^20.1.0",
4141
"react-docgen": "^3.0.0",
4242
"react-dropzone": "^4.1.2",
43+
"react-katex": "^2.0.2",
4344
"react-markdown": "^4.0.6",
4445
"react-select-fast-filter-options": "^0.2.3",
4546
"react-virtualized-select": "^3.1.3",
47+
"remark-math": "^1.0.6",
4648
"uniqid": "^5.0.3",
4749
"fast-isnumeric": "^1.1.3"
4850
},
@@ -73,6 +75,7 @@
7375
"react-dom": "^16.8.6",
7476
"style-loader": "^0.23.1",
7577
"styled-jsx": "^3.1.1",
78+
"url-loader": "^2.1.0",
7679
"webpack": "^4.29.6",
7780
"webpack-cli": "^3.3.0",
7881
"webpack-serve": "^2.0.3"

src/components/Markdown.react.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
33
import {type} from 'ramda';
44
import Markdown from 'react-markdown';
5+
import RemarkMathPlugin from 'remark-math';
6+
import { InlineMath, BlockMath } from 'react-katex';
7+
import 'katex/dist/katex.min.css';
58
import './css/highlight.css';
69

710
// eslint-disable-next-line valid-jsdoc
@@ -115,6 +118,11 @@ class DashMarkdown extends Component {
115118
<Markdown
116119
source={displayText}
117120
escapeHtml={!dangerously_allow_html}
121+
plugins={[RemarkMathPlugin]}
122+
renderers={{
123+
math: ({value}) => <BlockMath>{value}</BlockMath>,
124+
inlineMath: ({value}) => <InlineMath>{value}</InlineMath>
125+
}}
118126
/>
119127
</div>
120128
);

webpack.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,15 @@ module.exports = (env, argv) => {
7575
},
7676
],
7777
},
78+
{
79+
test: /\.(png|woff|woff2|eot|ttf|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
80+
use:[
81+
{
82+
loader: 'url-loader'
83+
}
84+
]
85+
}
7886
],
7987
}
8088
}
81-
};
89+
};

0 commit comments

Comments
 (0)