Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support for jsx html element highlights#57

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
TomiS wants to merge1 commit intorescript-lang:masterfromTomiS:jsx-html-elements

Conversation

@TomiS
Copy link
Contributor

I'm not sure if this is at all how you want to solve this. But since I spent some time toying with this approach, I might as well post it as a PR.

Some notes:

  • Regex matches all html tags based on the existence of opening chevron and one of explicitly listed tag names. The opening tag then expects either closing chevron or at least one whitespace character (to avoid collisions with type arguments)
  • Closing tag works similarly except that it doesn't allow any content other than the tag name.
  • The tag list is just pasted from somewhere and is almost certainly not complete. I can figure out where to find a complete list if the approach is considered good otherwise.

Austaras reacted with eyes emoji
@TomiS
Copy link
ContributorAuthor

TomiS commentedDec 30, 2020
edited
Loading

Hmm, I realized this fails with code that uses html tag names as type names.

type div = boollet foo: option<div> = Some(false)

Might be super hard to get around the fact that both jsx tags and types use chevrons now, assuming there is no deeper knowledge of the syntax tree.

EDIT: After thinking about this a bit, unless there exists a significantly better approach, I would personally just accept that there are a few corner cases like this and still implement the highlight. The pros overweight the cons clearly.

Faliszek, yunti, and fhammerschmidt reacted with thumbs up emoji

@chenglou
Copy link
Member

Whoever's reading this: make sure you've seen my comment at#8 (comment) first

I'm open to consider coloring lower-cased JSX tags. But not if they discoloroption<foo>. There might be some circumventions for this. I'll think about it.

@amiralies
Copy link
Contributor

what about just coloring angle brackets and equal signs?
image

This is from vim-rescript
image

@chenglou
Copy link
Member

chenglou commentedFeb 3, 2021
edited
Loading

That could work, but requires detection the jsx block anyway. We already detect most of them, but don't highlight them, since highlighting them requires detectingall of them. Note how the ligature is already active.

The troubling one is the open and closing angular brackets for the opening tag

@chenglou
Copy link
Member

chenglou commentedFeb 3, 2021
edited
Loading

Btw@amiralies seehttps://github.com/rescript-lang/rescript-vscode/#recommendation and#8 (comment).= is already recognized, though not colored in your particular theme.

amiralies reacted with thumbs up emoji

@chenglou
Copy link
Member

The highlighting (using the same ported grammar) in Sublime Text:

Screen Shot 2021-02-03 at 2 26 09 AM

Unfortunately vscode's default dark theme doesn't highlight any operator...

amiralies and Faliszek reacted with thumbs up emoji

@amiralies
Copy link
Contributor

is that the same exact tm grammar mapped to submile-syntax?
I think submile-syntax is more powerful than tm grammar.

@chenglou
Copy link
Member

It's the same, though for the example above I've tweaked a few things for clarity, ignore that. But the main point is that your theme (and mine, the default vscode dark theme) don't highlight stuff like operators.

Yeah I'm familiar with the difference between the two grammars. Part of why I didn't lazy out with reusing TM grammar for Sublime is precisely because the new Sublime grammar is much nicer.

amiralies reacted with thumbs up emoji

@zth
Copy link
Member

zth commentedMar 17, 2022

Note:#367 will implement the equivalent of this. Thank you@TomiS !

@zthzth mentioned this pull requestMar 20, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@TomiS@chenglou@amiralies@zth

[8]ページ先頭

©2009-2025 Movatter.jp