File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -27,16 +27,18 @@ const emptyOptions = {}
2727 */
2828export function toMdast ( tree , options ) {
2929 // We have to clone, cause we’ll use `rehype-minify-whitespace` on the tree,
30- // which modifies
30+ // which modifies.
3131 const cleanTree = structuredClone ( tree )
3232 const settings = options || emptyOptions
33+ const transformWhitespace = rehypeMinifyWhitespace ( {
34+ newlines : settings . newlines === true
35+ } )
3336 const state = createState ( settings )
3437 /** @type {MdastNodes } */
3538 let mdast
3639
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 )
4042
4143 visit ( cleanTree , function ( node ) {
4244 if ( node && node . type === 'element' && node . properties ) {
Original file line number Diff line number Diff line change 4545 "mdast-util-phrasing" : " ^4.0.0" ,
4646 "mdast-util-to-hast" : " ^13.0.0" ,
4747 "mdast-util-to-string" : " ^4.0.0" ,
48- "rehype-minify-whitespace" : " ^5 .0.0" ,
48+ "rehype-minify-whitespace" : " ^6 .0.0" ,
4949 "trim-trailing-lines" : " ^2.0.0" ,
5050 "unist-util-position" : " ^5.0.0" ,
5151 "unist-util-visit" : " ^5.0.0"
You can’t perform that action at this time.
0 commit comments