-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MDX Support #81
Comments
This would be amazing |
I guess half of this is already kind of implemented (highlighting-wise) since HTML tags should be recognized as such in most situations. The rest (import/export/statements in curly braces) also seem to be quite well defined and easy to implement. Also I already made this parser configurable using compile time environment variables, as such this shouldn't require forking the parser. All that saying that everything is in place to implement this without too much effort. I don't think this will be a priority for me anytime soon as I don't have too much time to spend on this parser, but I will gladly help anybody trying to add this functionality. |
Hey! I was looking into how to extend this parser in a new project but it seems we can do this here.. I'm new to this whole tree-sitter parser authoring.. but I'm willing to learn and work on this if @MDeiml help me with this (mostly answering questions and pointing to the right resources). How can we move forward with this? I'm honestly surprised that MDX is not supported outside vscode since is quite popular. |
First of all I suggest we settle on a spec for There are two syntactical elements, that need to be implemented on top of this parser:
For 1. most of the code needs to go in For 2. most of the code needs to go in You can test your code by adding files to Finally, mdx should probably be treated as an optional extension, so you can have a look at the beginning of (I'd like to emphasize again that you should mainly copy code and modify it to your needs. There are some intricacies to this parser that stem from the restrictions tree-sitters parsing model and that lead to some pretty weird and ugly code, but I'd like to avoid getting into that.) Sry for the wall of text. If you have any more questions feel free to ask :) |
Thanks for the quick reply! Yeah they seem to have a specification in a github repo.. I think we can use the link you've provided plus the mentioned link to work on this. I'll checkout the structure of the project in detail after work. Will reach again soon, probably with some questions. |
Hello! I think I'm starting to understand the workflow with this project in particular (and treesitter in general).. so I have a couple o questions just to confirm:
Thanks for your time again! |
|
Hey! Sorry I took some time off from personal projects. Yesterday I came back to it but I think is just hard for me to learn all at once (treesitter and specially c) from an existing project. I'm going to create a new project and try to extend this parser with the |
Did you consider publishing this as an npm package? I see that some parsers do this and then other parsers use them (with npm install) to extend the parser. It'll be great for my use case 😄 |
Sure, I could try, though I'm not familiar. Could you give me an example for a parser that does that? |
Please consider doing this as a separate parser. MDX is a separate language with different syntax and semantics. We do a lot of html-in-markdown at work, and I'm concerned that layering mdx on top of the existing semantics will break things in subtle ways. |
Neovim's default Markdown syntax highlighting is currently better at handling MDX content than the Treesitter version |
@bennypowers considering that jsx exists fine alongside html, and considering that astros mdx-like-kinda-but-not has a functioning tree-sitter despite supporting more complex semantics I can't think of what can go wrong. Do you have some patterns you think would be extra fragile? UPDATE: There seems to be a pretty thorough spec for mdx (retrieved from the link) and it has explicit deviations from markdown. Meaning that not all valid markdown is valid mdx and not all valid mdx is valid markdown. This makes it impossible to avoid a different parser for MDX and MD since they are in essence different syntaxes. I'm getting de-ja-vu from the same bikeshed about typescript and tsx |
Surprised this hasn't been mentioned here before, but has anyone considered adding MDX support for this parser? I understand it may take some consideration to support MDX fully with JSX syntax recognition, but it would be really nice if this just also supported files with the
.mdx
extension.Thoughts?
The text was updated successfully, but these errors were encountered: