-
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/TSX: Tags of React components are styled as classes #1519
Conversation
Hey @RunDevelopment – Just wanted to say I appreciate the reviews & PRs you've made to Prism. I haven't had a lot of time to dig into all of them, and a lot of the regex changes I'm unfortunately not really qualified to review, but I just wanted to let you know we see the work you've done and thank you for it. |
@RunDevelopment Thanks for writing this so quickly, exactly what I needed. The code/results looks good to me. 😃 |
Could this be changed to |
@atomiks The theme will just use a more specific CSS selector. .token.tag.class-name {
color: red;
} |
Ah ok, looks good then! |
Can we get tests for this? |
Unfortunately, it is not possible to test this feature with our usual tests. |
But you could confirm that |
Depends: But, we could change the implementation of this PR so that it will replace the string |
I dig this, much closer to what I was thinking. |
One last note: Because the implementation is now different, the CSS selector to highlight the .token.tag > .token.class-name {
color: red;
} |
This PR implements #1518 but it uses
class-name
in favor of the proposedtag-class
. Like this, we don't have to change the themes.The PR adds a
class-name
alias to all the tags of React components. Tags which start with an uppercase letter are considered React components.HTML tags remain unchanged.
The new styling is similar to VS Code's.
Example: (taken from the React tutorial)
VS Code: