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

Rewrite MDX/react component parser into more general-purpose scanner #65

Open
Tracked by #76
NathanLovato opened this issue Oct 28, 2024 · 1 comment
Open
Tracked by #76
Labels
enhancement New feature or request

Comments

@NathanLovato
Copy link
Contributor

NathanLovato commented Oct 28, 2024

As part of #59 we'll need to parse all sorts of MDX components. Currently we use a specific regex to parse components instead.

The MDX components part can be done independently from other

There are some little edge cases with the MDX parsing the way we do it, using a regex:

  1. It's specific to given components
  2. It assumes the components are on a single line

We need to add parsing for more attributes in #63, #64, and #61 to get rid of MDX parser plugins in next, so this part of #59 can be done before the rest of the parser.

I'm thinking of going for a good old scanner and tokenizer with a big switch statement for this, to have the flexibility to gradually add support for all the component syntax (attributes, jsx values with {}, arrays, etc.).

Wishlist

  • Work on good error messages from the get-go, like make it explicit which attribute is missing or what exactly is malformed when a component doesn't close properly or has a typo.
@NathanLovato
Copy link
Contributor Author

Implementation plan:

  • Implement through parser Nathan/mdx component parser #71
  • Run through document character by character
  • Use a regex to find < ... /> or <...>...</...>
  • Pass the match to the parser and let it tokenize

This can then replace all specific regexes in the preprocessor for MDX components

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

1 participant