File tree Expand file tree Collapse file tree 4 files changed +178
-11
lines changed Expand file tree Collapse file tree 4 files changed +178
-11
lines changed Original file line number Diff line number Diff line change 49
49
"babel-loader" : " ^8.1.0" ,
50
50
"husky" : " ^4.2.5" ,
51
51
"jest-environment-jsdom-sixteen" : " ^1.0.3" ,
52
+ "katex" : " ^0.11.1" ,
52
53
"react" : " ^16.13.1" ,
53
54
"react-docgen-typescript-loader" : " ^3.7.2" ,
54
55
"react-dom" : " ^16.13.1" ,
55
56
"react-is" : " ^16.13.1" ,
56
57
"react-test-renderer" : " ^16.13.1" ,
58
+ "rehype-katex" : " ^3.0.0" ,
59
+ "remark-math" : " ^2.0.1" ,
57
60
"ts-loader" : " ^7.0.4" ,
58
61
"tsdx" : " ^0.13.2" ,
59
62
"tslib" : " ^2.0.0" ,
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import { text } from '@storybook/addon-knobs' ;
3
+ import remarkMath from 'remark-math' ;
4
+ import rehypeKatex from 'rehype-katex' ;
5
+ import 'katex/dist/katex.min.css' ;
6
+
3
7
import { Remark } from '../src' ;
4
8
5
9
export default {
6
10
title : 'Remark Component' ,
7
11
component : Remark ,
8
12
} ;
9
13
10
- export const Default = ( ) =>
11
- // prettier-ignore
14
+ export const Default = ( ) => (
12
15
< Remark >
13
- { text ( "content" , `# header
16
+ { text (
17
+ 'content' ,
18
+ `# header
14
19
15
20
1. ordered
16
21
2. list
17
22
18
23
* unordered
19
- * list
24
+ * list`
25
+ ) }
26
+ </ Remark >
27
+ ) ;
28
+
29
+ export const Math = ( ) => (
30
+ < Remark remarkPlugins = { [ remarkMath ] } rehypePlugins = { [ rehypeKatex ] } >
31
+ { text (
32
+ 'content' ,
33
+ `Lift($L$) can be determined by Lift Coefficient ($C_L$) like the following equation.
20
34
21
- ` ) }
22
- </ Remark > ;
35
+ $$
36
+ L = \\frac{1}{2} \\rho v^2 S C_L
37
+ $$`
38
+ ) }
39
+ </ Remark >
40
+ ) ;
Original file line number Diff line number Diff line change 1
-
2
-
3
1
import { useEffect } from 'react' ;
4
2
import { text } from '@storybook/addon-knobs' ;
3
+ import remarkMath from 'remark-math' ;
4
+ import rehypeKatex from 'rehype-katex' ;
5
+ import 'katex/dist/katex.min.css' ;
6
+
5
7
import { useRemark } from '../src' ;
6
8
7
9
export default {
8
10
title : 'Remark Hook' ,
9
- component : useRemark
11
+ component : useRemark ,
10
12
} ;
11
13
12
14
export const Default = ( ) => {
@@ -18,4 +20,25 @@ export const Default = () => {
18
20
} , [ markdownSource ] ) ;
19
21
20
22
return reactContent ;
21
- } ;
23
+ } ;
24
+
25
+ export const Math = ( ) => {
26
+ const [ reactContent , setMarkdownSource ] = useRemark ( {
27
+ remarkPlugins : [ remarkMath ] ,
28
+ rehypePlugins : [ rehypeKatex ] ,
29
+ } ) ;
30
+ const markdownSource = text (
31
+ 'markdown' ,
32
+ `Lift($L$) can be determined by Lift Coefficient ($C_L$) like the following equation.
33
+
34
+ $$
35
+ L = \\frac{1}{2} \\rho v^2 S C_L
36
+ $$`
37
+ ) ;
38
+
39
+ useEffect ( ( ) => {
40
+ setMarkdownSource ( markdownSource ) ;
41
+ } , [ markdownSource ] ) ;
42
+
43
+ return reactContent ;
44
+ } ;
You can’t perform that action at this time.
0 commit comments