-
Notifications
You must be signed in to change notification settings - Fork 86
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
added JSX tags highlighting #45
base: master
Are you sure you want to change the base?
added JSX tags highlighting #45
Conversation
I don't use JavaScript much, so I'm not sure what JSX tags are. Let me look at this a bit... |
They are used for templates in React. Actually they are representation of a render function. Also it would be nice to have |
Hmmmm... I'm not sure it's a good idea to have library-specific highlighting for a highlighting a language. For a couple of reasons. ... Snip... |
@@ -10,6 +10,13 @@ color yellow "\<[-+]?([1-9][0-9]*|0[0-7]*|0x[0-9a-fA-F]+)([uU][lL]?|[lL][uU]?)?\ | |||
color yellow "\<[-+]?([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([EePp][+-]?[0-9]+)?[fFlL]?" | |||
color yellow "\<[-+]?([0-9]+[EePp][+-]?[0-9]+)[fFlL]?" | |||
|
|||
## JSX tags | |||
color cyan "<[^> ]+" | |||
color cyan "<[a-zA-Z][a-zA-Z0-9]*>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe list HTML tags here? To differentiate a color of standard tags from components?
Also <[a-zA-Z][a-zA-Z0-9]*>
will match <>
, but <[a-zA-Z][a-zA-Z0-9]+>
don't!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a different color for standard tags rather than components could be nice, but don't you think listing them is overkill? I would suggest it's sufficient to say that <[a-z]+>
is an HTML tag and <[A-Z][a-zA-Z0-9]*>
is a component.
(Also <[a-zA-Z][a-zA-Z0-9]*>
will not match <>
, it will match at least <[a-zA-Z]>
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what if someone uses all caps when they do their HTML??
<HTML>
<BODY>
I LIKE SCREAMING CAPS!!!
</BODY>
</HTML>
dumb i agree, but I've seen this in more than one place...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About *
/+
you are right, it's my bad, sorry))
About overkill: listing of JS reserved words is not overkill...
HTML has 144 tags. Reference https://developer.mozilla.org/en-US/docs/Web/HTML/Element
document.body.innerText.match(/<\w+>/g).reduce((acc, cur) => {
if (!acc.includes(cur)) {
acc.push(cur)
}
return acc
}, [])
Run this code in the console on a reference page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In JSX, any tag that starts with a lowercase letter is assumed to be a native tag, whereas tags starting with uppercase letters are component tags.
It's not library specific now if you are talking about JSX. Earlier it was, but not now. |
@Piterden thank you for the info. I accidentally posted my previous thing and i had a whole set of reasons and was going to suggest "make a Again I'm not much in the js community, so some of these things i don't know. I like @Piterden 's suggestion for adding HTML tags as a different color, so if you could do that @remyoudemans (at least some of the more often used ones) I'll accept the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @remyoudemans suggestion is good enough. If the pr is changed to that I'll go ahead and pull it in. Sorry for the very long delay...
No description provided.