Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add emmet support for .mdx / markdown react file types in vscode

I am using .mdx files in gatsby and want to be able to have emmet recognize this as a valid file type for expansion / support. The .mdx files already get recognized in vscode as "Markdown React", and I have previously added .jsx support via:

"emmet.includeLanguages": {
  "javascript": "javascriptreact"
},

but can't seem to get it to work for markdown react. I've tried "javascript": "markdownreact", with variations on "markdown react", "Markdown React":

i.e.

"emmet.includeLanguages": {
  "javascript": "javascriptreact",
  "javascript": "markdownreact",
},

wondering if I either have the language name down wrong still, or if it doesn't support multiple file associations. Or maybe the order should be switched in the key value pair?

like image 851
mheavers Avatar asked Nov 03 '25 06:11

mheavers


1 Answers

This may not be the canonical answer (or the best one); a solution nonetheless.

Re html tags: One approach is just to enable html quickSuggestions in strings:

"emmet.includeLanguages": {
    "javascript": "html"
},
"[javascript]": {
    "editor.quickSuggestions": {
        "strings": true
    }
},

js

For .mdx files specifically, you need to make sure the language mode is set to Markdown React, or use an extension that incorporates this file association.

Then add it to the included emmet languages:

"emmet.includeLanguages": {
    "mdx": "html"
},

enter image description here

like image 74
soulshined Avatar answered Nov 04 '25 20:11

soulshined



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!