File tree 2 files changed +7
-5
lines changed
2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -27,16 +27,18 @@ const emptyOptions = {}
27
27
*/
28
28
export function toMdast ( tree , options ) {
29
29
// We have to clone, cause we’ll use `rehype-minify-whitespace` on the tree,
30
- // which modifies
30
+ // which modifies.
31
31
const cleanTree = structuredClone ( tree )
32
32
const settings = options || emptyOptions
33
+ const transformWhitespace = rehypeMinifyWhitespace ( {
34
+ newlines : settings . newlines === true
35
+ } )
33
36
const state = createState ( settings )
34
37
/** @type {MdastNodes } */
35
38
let mdast
36
39
37
- // To do: use `satisfies` in `rehype-minify-whitespace`
38
- // @ts -expect-error: does return a transformer, that does accept any node.
39
- rehypeMinifyWhitespace ( { newlines : settings . newlines === true } ) ( cleanTree )
40
+ // @ts -expect-error: fine to pass an arbitrary node.
41
+ transformWhitespace ( cleanTree )
40
42
41
43
visit ( cleanTree , function ( node ) {
42
44
if ( node && node . type === 'element' && node . properties ) {
Original file line number Diff line number Diff line change 45
45
"mdast-util-phrasing" : " ^4.0.0" ,
46
46
"mdast-util-to-hast" : " ^13.0.0" ,
47
47
"mdast-util-to-string" : " ^4.0.0" ,
48
- "rehype-minify-whitespace" : " ^5 .0.0" ,
48
+ "rehype-minify-whitespace" : " ^6 .0.0" ,
49
49
"trim-trailing-lines" : " ^2.0.0" ,
50
50
"unist-util-position" : " ^5.0.0" ,
51
51
"unist-util-visit" : " ^5.0.0"
You can’t perform that action at this time.
0 commit comments