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

Inline JSX elements (CamelCase) do not seem syntax highlighted #9

Open
balupton opened this issue Jan 28, 2019 · 17 comments
Open

Inline JSX elements (CamelCase) do not seem syntax highlighted #9

balupton opened this issue Jan 28, 2019 · 17 comments
Labels
bug Something isn't working

Comments

@balupton
Copy link

They are treated just like markdown. Lowercasing the jsx element works for syntax highlighting, but then it doesn't function.

@silvenon
Copy link
Owner

Could you share a code snippet and/or screenshot? I don't understand what isn't syntax highlighted.

@silvenon
Copy link
Owner

Ah, I think you're referring to inline JSX, correct?

@balupton
Copy link
Author

balupton commented Jan 29, 2019

Correct. Sorry, posted the issue on my phone. An example is a JSX element (so CamelCase) within a nested markdown list

@balupton
Copy link
Author

screen shot 2019-01-29 at 4 31 32 pm

screen shot 2019-01-29 at 4 31 56 pm

@silvenon
Copy link
Owner

Yeah, in MDX that's what's classified as inline JSX, where a single line needs to be partially interpreted as Markdown and partially as JSX.

I'll see what I can do, thanks for reporting. 🙂

@silvenon silvenon changed the title JSX elements (CamelCase) do not seem syntax highlighted Inline JSX elements (CamelCase) do not seem syntax highlighted Jan 29, 2019
@silvenon silvenon added the bug Something isn't working label Jan 29, 2019
@blummis
Copy link

blummis commented Jul 13, 2019

Hi, any ideas how to fix this?

This is how it shows for me:

inline-tags

@silvenon
Copy link
Owner

In the near future no, I'm sorry, I'm very inexperienced with grammars in general. I think I need to rebuild this extension entirely to gain more more power over these cases because it's currently only looking for empty lines, as far as I can remember, but MDX is more complex now, with inline JSX, interpolations etc.

@karlhorky
Copy link

Because HTML tags are also valid when written uppercase, and web components would be classified as "Unknown", maybe this can be fixed in the base text.html.markdown grammar, which also has this issue:

Screen Shot 2019-08-14 at 15 57 10

Compare that with the HTML grammar highlighting:

Screen Shot 2019-08-14 at 16 02 35

I am also not experienced with grammars, but from a cursory look it seems like you're using here:

"markdown": {
"contentName": "text.html.markdown",
"patterns": [
{ "include": "text.html.markdown" }
]
}

I will open an issue on the grammar to request feedback on this change.

@karlhorky
Copy link

karlhorky commented Aug 14, 2019

Opened microsoft/vscode#79119 for this.

Edit: Copied to microsoft/vscode-markdown-tm-grammar#49, in case that is the correct place for it.

@karlhorky
Copy link

karlhorky commented Aug 14, 2019

Caveat: JSX highlighting would be of course better if someone can crack it (cc @mjbvz, could you possibly point us in the right direction for updating the grammar?) - because it would show a different color for capitalized tags, but this would at least be an improvement on the current situation.

@karlhorky
Copy link

Well case insensitivity was added in microsoft/vscode-markdown-tm-grammar@67b9b34 - should be out in the next VS Code Insiders build.

But unknown / custom elements were not addressed. I've asked about that in microsoft/vscode-markdown-tm-grammar#49 (comment)

@karlhorky
Copy link

Unknown / custom elements merged in! microsoft/vscode-markdown-tm-grammar#54

Still is not a complete fix, because other JSX syntax like non-string props passing (<Grid style={{ background: "green" }}>) is still not highlighted, but it's a start for simple components!

@silvenon
Copy link
Owner

silvenon commented Aug 20, 2019

Great! I'll see what I can do about that. 👍 Thanks for keeping this issue updated!

@karlhorky
Copy link

karlhorky commented Aug 20, 2019

No problem :) yeah I think the "correct" way to fix it would be for inline tags (probably all inline tags) to start triggering the JSX grammar again. Not entirely sure how to do this off the top of my head, but I guess the vscode-markdown-tm-grammar code could be illuminating in this regard... They switch to the other html grammar a lot within it.

@karlhorky
Copy link

Seems like looking at the Markdown grammar will be helpful in other ways too. For example, currently in the MDX grammar, the Markdown inside the HTML element is not highlighted (Markdown can be embedded within HTML if it starts at the start of the line):

Screen Shot 2019-08-28 at 12 20 38

Compare that to the Markdown grammar:

Screen Shot 2019-08-28 at 12 20 28

@karlhorky
Copy link

karlhorky commented Sep 12, 2019

The fix I refer to in #9 (comment) above was released in VS Code 1.38 btw:

https://code.visualstudio.com/updates/v1_38#_notable-fixes

79478: Highlight custom html tags in markdown files

@felixakiragreen
Copy link

This was fixed in the VSCode Markdown lib but still broken in this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants