-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
JSX: Add partial support for plain text between tags #1304
Conversation
3c21695
to
7305739
Compare
Just to clarify what you mean, you're worried that because the first batch of plaintext ("this is plaintext" in ur screenshot) doesn't highlight "this", the second batch that does looks more like a bug? |
Yes, it's exactly what I mean. It's clearer, expressed like this, thanks ^^ |
Yeah, that’s definitely a bug… |
@LeaVerou well no it's not a bug, that's precisely my point here. It is an case that is explicitly not handled by the behaviour I described in the first post. Changing the order of the patterns won't help here AFAICT. But maybe there is a better algorithm... |
Oh I see, you fixed the highlighting for some of the plain text, but not all cases! |
I’m pretty late in the game so I might be suggesting silly ideas that you've already considered, but instead of merging the two languages like this (where you have no control over how it works), have you considered using the JS def (cloned obvs), adding a token to it for the tags (before keywords) and then matching HTML inside it? |
I'm afraid we would face the same issue (although I agree the way the component is done currently differs from our other embedded languages). Currently, the Quick list of ideas I already tried:
I honestly think we can't get a perfect result here. So the following question would be: is it worth adding partial support as shown in the screenshots in the PR, or it is better if we assume Prism can't match plain text in JSX? |
Closing this PR in favor of #1357. |
This is an attempt at a better support for plain text between tags in JSX (and incidently TSX). See #1294.
Plain text will be matched between an opening tag (
<xxx>
) and the next tag encountered (<xxx>
,</xxx>
or<xxx/>
).This behaviour gives decent results IMO, but is not perfect.
It will fail on those examples:
The thing that worries me is that with this improvement, those look even more like bugs than unhandled cases.
What do you think? @m-allanson, @LeaVerou, @mAAdhaTTah, @vkbansal