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

Add tsx (TypeScript + JSX) support #1663

Closed
wants to merge 3 commits into from
Closed

Conversation

ddevault
Copy link
Contributor

This uses the same rules as JavaScript's JSX support.

Fixes #1155

This uses the same rules as JavaScript's JSX support.

Fixes highlightjs#1155
@ZoranRavic
Copy link

@SirCmpwn Could you please not put the return statement in the constructor, but instead create a separate function?

@ddevault
Copy link
Contributor Author

Does it matter? This is just for testing the highlighitng kicks in right.

@ZoranRavic
Copy link

@SirCmpwn I think the same examples are also used on https://highlightjs.org/static/demo/
And I'm pretty sure the users who would see that typescript code there would get annoyed.

@mmartinson
Copy link

Anything I can do to help move this one along? Testing, changes?

@ddevault
Copy link
Contributor Author

#1678

@paladox
Copy link
Member

paladox commented Jan 11, 2019

Hi, this needs rebasing.

@paladox
Copy link
Member

paladox commented Jan 31, 2019

@ddevault would you be able to rebase please?

@rhigdon
Copy link

rhigdon commented Jan 31, 2019

#1967
I rebased Drew's patch and updated the CHANGES.md and AUTHORS.en.txt

Copy link
Collaborator

@egor-rogov egor-rogov left a 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">&lt;<span class="hljs-name">div</span> /&gt;</span>;
// this is not xml
</span>

Missing \s* somewhere?

Also please update docs/css-classes-referense.rst to include the new alias.

@PabloSzx
Copy link

any news on this?

}
<span class="hljs-keyword">else</span> {
Copy link
Member

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>;
Copy link
Member

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

@joshgoebel
Copy link
Member

joshgoebel commented Dec 24, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(typescript) Add JSX support to Typescript