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

fix: Support tsx with prism syntax highlighter #1391

Merged
merged 2 commits into from
Apr 25, 2019
Merged

fix: Support tsx with prism syntax highlighter #1391

merged 2 commits into from
Apr 25, 2019

Conversation

ntucker
Copy link
Contributor

@ntucker ntucker commented Apr 25, 2019

Motivation

TSX and any other compositionally defined language (Prism.languages.extend) in prism will not work with the current system because of how language loading works.

Basically the other languages tsx is composed from (jsx and typescript) won't always be loaded first (I don't even have JSX examples so it can never get to that point). If that's the case it won't be able to create the composition properly.

Have you read the Contributing Guidelines on pull requests?

yes

Test Plan

I simply did this modification in my usage where I have lots of tsx (https://resthooks.io). Before I was getting TypeError: Cannot read property 'rest' of undefined. and it would fallback to highlight.js, which of course doesn't support tsx.

Here's it working:
tsx

Related PRs

Inspiration for this fix comes from workarounds in: PrismJS/prism#972

@ntucker ntucker requested a review from endiliey as a code owner April 25, 2019 07:05
@ntucker ntucker changed the title [fix] Make tsx load properly fix: Make tsx load properly Apr 25, 2019
@ntucker ntucker changed the title fix: Make tsx load properly fix: Support tsx with prism syntax highlighter Apr 25, 2019
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Apr 25, 2019
@docusaurus-bot
Copy link
Contributor

Deploy preview for docusaurus-preview ready!

Built with commit cb33742

https://deploy-preview-1391--docusaurus-preview.netlify.com

@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Apr 25, 2019

Deploy preview for docusaurus-preview ready!

Built with commit 9d3d812

https://deploy-preview-1391--docusaurus-preview.netlify.com

Copy link
Contributor

@endiliey endiliey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 🎉

Wow this is amazing work!!! Thank you so much @ntucker !

image

@endiliey endiliey merged commit c102651 into facebook:master Apr 25, 2019
@ntucker
Copy link
Contributor Author

ntucker commented Apr 25, 2019

Can you release a version with this fix?

@endiliey
Copy link
Contributor

endiliey commented Apr 25, 2019

I'll release next v1 version along with #1369

For now, you can use master version with @next tag

https://www.npmjs.com/package/docusaurus
image

Don't worry, there are no breaking changes for that, Docusaurus 2 itself is renamed to '@docusaurus/core'

@ntucker ntucker deleted the fix-tsx branch April 25, 2019 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants