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

More intelligently try to match tags #5

Open
felipeochoa opened this issue Oct 24, 2016 · 3 comments
Open

More intelligently try to match tags #5

felipeochoa opened this issue Oct 24, 2016 · 3 comments

Comments

@felipeochoa
Copy link
Owner

When a child JSX tag is missing a closing tag, the current code uses its parent tag as a mismatched tag, so its parent ends up missing a tag and the rest of the buffer is screwed. By deferring matching of opening and closing tags to rjsx-parse-xml we could be smarter about this matching process.

image

@felipeochoa
Copy link
Owner Author

Thinking through this more, this would require parsing the body of the top-level tag in big chunks without trying to assign children to parents. After every tag-closer, we would run some matching heuristic and decide whether we were done parsing XML, but that's a difficult question. Only then would we be able to walk the tree and assign children to parents. An example of how this would get confusing:

<div className="top">
  <section className="middle">
    <div className="bottom">{/* missing closing tag */}
    Middle-text
  </section>
</div>

In order to correctly attach "Middle-text" to the section, we'd have to first hit the </section> tag, realize that .bottom is unmatched, and then add all the other children to .middle.

How do we deal with situations like:

<div>
  <div>
    <div>{/* missing closing tag */}
  </div>
</div>

@larebsyed
Copy link
Contributor

I would also like a functionality to auto closer missing tag, I believe this is related

@felipeochoa
Copy link
Owner Author

Yeah parsing when there are missing tags is very challenging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants