vscode-markdown icon indicating copy to clipboard operation
vscode-markdown copied to clipboard

Suggestion: Allow extension to work within MDX files

Open thomaskoppelaar opened this issue 3 years ago • 13 comments

Hello everyone,

MDX allows for JSX components within Markdown. I personally love this extension, and I'd love it to work within MDX files as well.

I'm able to provide this functionality myself and open a PR that allows this extension to activate and function within MDX files.

I understand that some functionality such as "Print current document to HTML" will not work wont work for these type of files, but that's okay.

thomaskoppelaar avatar Jul 23 '20 11:07 thomaskoppelaar

Thanks.

I guess you can enable this extension by associate .mdx (?) to markdown languageID with option

image

(I remember there was a similar issue talking about MDX but can't find it now.)

yzhang-gh avatar Jul 23 '20 11:07 yzhang-gh

Hi,

This does indeed work, but then doesn't allow for MDX specific extensions to work :smile: . Is it alright if I open a PR to show the changes? Otherwise, you can check out the commit here.

thomaskoppelaar avatar Jul 23 '20 11:07 thomaskoppelaar

Looks good to me 😉. (Is injectTo a new VSCode feature? I know there have been a quite long discussion about this in the VSCode repository.)

yzhang-gh avatar Jul 23 '20 12:07 yzhang-gh

I understand that some functionality such as "Print current document to HTML" will not work wont work for these type of files, but that's okay.

We can disable these features for MDX and just show a warning then.

yzhang-gh avatar Jul 23 '20 12:07 yzhang-gh

Is injectTo a new VSCode feature?

Not sure haha, I started working with extensions yesterday

We can disable these features for MDX and just show a warning then.

Fine by me, I'll open a draft PR and mark it done once I finish that.

thomaskoppelaar avatar Jul 23 '20 12:07 thomaskoppelaar

Is it implemented? Do I need to change some settings to make it work with *.mdx file? specifically looking to have an option to create TOC for mdx files.

GorvGoyl avatar Jan 14 '21 17:01 GorvGoyl

There doesn't seem to be a good solution for this up to now 🤔.

yzhang-gh avatar Jan 14 '21 17:01 yzhang-gh

As mentioned by @yzhang-gh, File associations worked for me image

mikemajara avatar Aug 27 '21 16:08 mikemajara

^^ the above fix for file associations still works. Thank you!

TaylorKrusen avatar Jul 28 '22 23:07 TaylorKrusen

Hi, MDX file association with markdown doesn't provide full color syntaxique in VSCode, but works well with this extension. The must have with this extension is to support mdx file.

Cedric-ruiu avatar Dec 12 '22 13:12 Cedric-ruiu

Creating the file file association works great for creating TOCs in .mdx files. However, when trying to omit a header from the TOC, I'm getting a syntax error as I believe <!-- omit in toc --> is not a valid .mdx comment. Has anyone found a workaround for this?

mxstrand avatar Dec 14 '22 18:12 mxstrand

@yzhang-gh How do you do the file association you show in the screenshot please? I can't see it in the extension settings.

RichardJECooke avatar Aug 14 '23 09:08 RichardJECooke

@yzhang-gh How do you do the file association you show in the screenshot please? I can't see it in the extension settings.

This is a setting item for VSCode itself, not for extensions, so it is not on the extension's settings screen. You can find the setting item by the following steps:

  1. press ctrl + , to open the settings page
  2. search for files.associations in the search box at the top of the screen

r4ai avatar Nov 21 '23 12:11 r4ai