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

(JavaScript) Top level JSX expression not detected #3578

Closed
modderme123 opened this issue Jul 13, 2022 · 1 comment
Closed

(JavaScript) Top level JSX expression not detected #3578

modderme123 opened this issue Jul 13, 2022 · 1 comment
Labels
bug help welcome Could use help from community language

Comments

@modderme123
Copy link

Describe the issue

It seems like top level JSX code is not detected correctly

consider these two expressions (github highlights them correctly):

return <div> asdf </div>;
<div> asdf </div>;

which render as
Screen Shot 2022-07-13 at 12 11 59 AM

Which language seems to have the issue?

javascript/jsx

Are you using highlight or highlightAuto?
highlightAll

Sample Code to Reproduce

http://jsfiddle.net/sp9cg4f1/2/

Expected behavior

I would expect that JSX code should be treated as a value and highlighted the same as when it is returned.

@modderme123 modderme123 added bug help welcome Could use help from community language labels Jul 13, 2022
@joshgoebel
Copy link
Member

joshgoebel commented Jul 13, 2022

I would expect that JSX code should be treated as a value and highlighted the same as when it is returned.

We have no sure way to know it's JSX code without the leading hints (=, return) to indicate we're in an expression, etc... Add a bit more context and it'll work - as you see. If you're interested in actually solving this one and wanted to submit a PR (that shows no regressions) I'm open to reviewing, but this is a really hard problem and getting JSX right without a full parser is very, very difficult.

Closing as dup of #2998.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help welcome Could use help from community language
Projects
None yet
Development

No branches or pull requests

2 participants