Skip to content
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 Parser #137

Open
barrett-ruth opened this issue Feb 24, 2024 · 5 comments
Open

MDX Parser #137

barrett-ruth opened this issue Feb 24, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@barrett-ruth
Copy link

Hello,

(And no, I am not coming to complain about a lack of MDX Parser).

Rather, I'd like to get started on making an MDX parser over the next few months. I think consulting the creators of the markdown parser would be a good place to start - and I'd just like to ask: do you think this is feasible? If so, what projects should I start looking at (i.e. simple TS parsers, MDX parsers themselves, etc.)?

Looking at this markdown codebase, it seems like MDX would "just" be a superset of this parser, including:

  • frontmatter
  • component syntax
  • top-level export, import
  • JS inside braces

I (and others) would even be happy with just a subset of these being implemented.

Thanks for your response.

@barrett-ruth barrett-ruth added the enhancement New feature or request label Feb 24, 2024
@MDeiml
Copy link
Collaborator

MDeiml commented Feb 25, 2024

This has been discussed earlier, specifically see this issue and comment: #81 (comment)

You don't need to look at parsers for TS or MDX I think, since the javascript in these files would best be parsed using language injection. Basically you don't need to worry about parsing javascript, you just need to able to properly mark places where there is javascript, i.e. export statements, curly braces.

You're right that MDX would probably best be implemented as a superset / fork of this parser rather than from ground up, since most of the syntax is markdown anyways.

The main difficulty in implementing this is then understanding the markdown parser with markdown being a very messy language. It's probably helpful to read through the entirety of this page first if you haven't done so yet.

@barrett-ruth
Copy link
Author

You don't need to look at parsers for TS or MDX I think, since the javascript in these files would best be parsed using language injection. Basically you don't need to worry about parsing javascript, you just need to able to properly mark places where there is javascript, i.e. export statements, curly braces.

Ok great, that's what I thought. I see someone attempted to do it themselves but obviously didn't complete the task.

In that thread, another individual said they'd prefer MDX as a separate parser -- and I happen to agree. MDX seems to be a completely different language and I don't think it should be implemented on top of ts-markdown (unless it becomes stable in a long time). Once I start this in a few months I think forking will be the best option, although I'm not sure how keeping it updated will work.

Also, thanks for your patience constantly dealing with people who don't know a lot when you seem to be an expert on the matter. Hopefully I can contribute something meaningful in a month or two (or three).

@MDeiml
Copy link
Collaborator

MDeiml commented Mar 2, 2024

Haha, I'm not an expert by far, but I appreciate the comment. Feel free to ask me any questions that come up.

@dan-myles

This comment was marked as off-topic.

@arcmode
Copy link

arcmode commented Sep 22, 2024

@barrett-ruth I was looking for something similar and found https://github.com/wooorm/markdown-rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants