-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Add tsx (TypeScript + JSX) support #1663
Conversation
This uses the same rules as JavaScript's JSX support. Fixes highlightjs#1155
@SirCmpwn Could you please not put the return statement in the constructor, but instead create a separate function? |
Does it matter? This is just for testing the highlighitng kicks in right. |
@SirCmpwn I think the same examples are also used on https://highlightjs.org/static/demo/ |
Anything I can do to help move this one along? Testing, changes? |
Hi, this needs rebasing. |
@ddevault would you be able to rebase please? |
#1967 |
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.
Hi,
it look to me that xml elements like <something />
(space before slash) are handled incorrectly:
return <div />;
// this is not xml
highlighted as
<span class="hljs-keyword">return</span> <span class="xml"><span class="hljs-tag"><<span class="hljs-name">div</span> /></span>;
// this is not xml
</span>
Missing \s*
somewhere?
Also please update docs/css-classes-referense.rst
to include the new alias.
any news on this? |
} | ||
<span class="hljs-keyword">else</span> { |
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.
Why is the syntax highlighting on else and return breaking here?
@@ -2,6 +2,7 @@ class MyClass { | |||
public static myValue: string; | |||
constructor(init: string) { | |||
this.myValue = init; | |||
return <div className="test">jsx syntax</div>; |
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.
Please also add a test with a self-closing tag as that seems to be a big issue with our React/JSX matching feature for this...
Closing this as it's out of date now (and I'm cleaning old issues for the new year). I think we're open to this, but it should be re-reviewed after 10.0 (or simply after more of the 10.0 stuff is in place) when we can make a single tiny JSX module and then import that exact module into both JS and TS, otherwise this is going to diverge and get very messy over time (as copy and paste tends to do) - as JSX seems to have a lot of activity lately. |
This uses the same rules as JavaScript's JSX support.
Fixes #1155