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

added JSX tags highlighting #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

remyoudemans
Copy link
Contributor

No description provided.

@serialhex
Copy link
Owner

I don't use JavaScript much, so I'm not sure what JSX tags are. Let me look at this a bit...

@Piterden
Copy link
Contributor

Piterden commented Oct 30, 2018

They are used for templates in React. Actually they are representation of a render function.

Also it would be nice to have .vue files highlight... Do you use vue, @remyoudemans?

@serialhex
Copy link
Owner

serialhex commented Oct 30, 2018

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]*>"
Copy link
Contributor

@Piterden Piterden Oct 30, 2018

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!

Copy link
Contributor Author

@remyoudemans remyoudemans Oct 30, 2018

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]>.)

Copy link
Owner

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...

Copy link
Contributor

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.

Copy link

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.

@Piterden
Copy link
Contributor

Piterden commented Oct 30, 2018

Hmmmm... I'm not sure it's a good idea to have library-specific highlighting for a

It's not library specific now if you are talking about JSX. Earlier it was, but not now.
If you are talking about vue, then pay attention that GitHub has vue language in its language list.

image
https://github.com/Piterden/vue-crossword

@serialhex
Copy link
Owner

@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 js-react.nanorc file instead"and whatever...

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.

@Piterden
Copy link
Contributor

Piterden commented Oct 31, 2018

I'm not much in the js community

Right choice my friend, it is horrible shit!!!
image

Copy link
Owner

@serialhex serialhex left a 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...

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

Successfully merging this pull request may close these issues.

4 participants