-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Improve syntax highlighting in docs #3673
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
Conversation
@kentcdodds mentioned this trick on Twitter. I was going to write some docs for #3669 but realized I wanted to do this first. (this is how I procrastinate from doing actual work 😑) |
Then with a module bundler like [webpack](https://webpack.github.io/) that supports either CommonJS or ES2015 modules, use as you would anything else: | ||
|
||
```js | ||
```jsx |
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.
This example isn't using jsx at all. Not sure you're getting much value out of putting jsx
here :)
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.
I thought about that a little. The JSX syntax highlighting is slightly different for vanilla JavaScript, though:
// js
const foo = { bar: 'baz' };
// jsx
const foo = { bar: 'baz' };
Given that, it seemed like consistency in syntax highlighting was preferable to strict correctness.
And it let me do everything with a regex.
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.
Sorry, I should have added to my comment :) You're good :D
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.
I'm kidding too :p
I actually started doing separately using js
for the non-JSX snippets in a bout of idiocy before I realized how awful that would have been.
Going to merge this for trivial-ness. |
@kentcdodds Do you know if anybody has an issue open with npm to fix the rendering of "jsx" syntax on the npm website? It's actually not working there. I might have to change the README back to using "js". |
npm uses Long story short, I would just switch back to js highlighting. |
Awe dang. Sad story :-( I guess the moral of the story is: use |
Yeah... I'll drop |
No description provided.