File tree Expand file tree Collapse file tree 2 files changed +4
-9
lines changed Expand file tree Collapse file tree 2 files changed +4
-9
lines changed Original file line number Diff line number Diff line change 5
5
6
6
import katex from 'katex'
7
7
import { visit } from 'unist-util-visit'
8
- import { removePosition } from 'unist-util-remove-position'
9
8
import { toText } from 'hast-util-to-text'
10
- import { unified } from 'unified'
11
- import rehypeParse from 'rehype-parse'
9
+ import { fromHtmlIsomorphic } from 'hast-util-from-html-isomorphic'
12
10
13
11
const assign = Object . assign
14
12
15
- const parseHtml = unified ( ) . use ( rehypeParse , { fragment : true } )
16
-
17
13
const source = 'rehype-katex'
18
14
19
15
/**
@@ -85,8 +81,9 @@ export default function rehypeKatex(options) {
85
81
)
86
82
}
87
83
84
+ const root = fromHtmlIsomorphic ( result , { fragment : true } )
88
85
// @ts -expect-error: assume no `doctypes` in KaTeX result.
89
- element . children = removePosition ( parseHtml . parse ( result ) , true ) . children
86
+ element . children = root . children
90
87
} )
91
88
}
92
89
}
Original file line number Diff line number Diff line change 40
40
"dependencies" : {
41
41
"@types/hast" : " ^2.0.0" ,
42
42
"@types/katex" : " ^0.14.0" ,
43
+ "hast-util-from-html-isomorphic" : " ^1.0.0" ,
43
44
"hast-util-to-text" : " ^3.1.0" ,
44
45
"katex" : " ^0.16.0" ,
45
- "rehype-parse" : " ^8.0.0" ,
46
- "unified" : " ^10.0.0" ,
47
- "unist-util-remove-position" : " ^4.0.0" ,
48
46
"unist-util-visit" : " ^4.0.0"
49
47
},
50
48
"scripts" : {
You can’t perform that action at this time.
0 commit comments