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

Inside HTML chunks, some javascript syntax highlighting rules still apply #1

Open
jessep opened this issue Dec 6, 2013 · 4 comments

Comments

@jessep
Copy link

jessep commented Dec 6, 2013

Seems like js parsing rules are still applying inside html chunks, which makes writing html really hard. I've highlighted a few issues below:

  1. JS keywords are highlighted in html, which is confusing, but not terrible.
  2. Adding 'get' removes syntax highlighting from all remaining code in a fn
  3. Adding a single ' makes the rest of the file look like it is inside a string. That's kinda inconvenient.

image

@dvdplm
Copy link

dvdplm commented Dec 23, 2013

Ping

@jessep jessep closed this as completed Dec 24, 2013
@jessep jessep reopened this Dec 24, 2013
@bslatkin
Copy link

bslatkin commented May 1, 2014

I'm seeing this too. No idea how to fix it though. :(

@yungsters
Copy link
Owner

10980f0 fixes the common case where quotes surrounded by letters are interpreted as strings:

var component = <div>Hello, y'all!</div>; // Should now work.

Unfortunately, syntax highlighting uses regular expressions for speed reasons, and JavaScript (including JSX) are not regular languages. (Still, we can probably do better, but not without significantly refactoring the language file.)

To work around this at Facebook (when it comes up), we've been using expression interpolation:

var component = <div>All of my friends{"'"} photos are cooler than mine.</div>;

Kind of lame, but not the end of the world. I hope this helps, and I welcome any PRs that attempt to provide a better solution.

@bslatkin
Copy link

bslatkin commented May 1, 2014

It's working! Thank you!

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

No branches or pull requests

4 participants