Skip to content

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


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