Skip to content

Conversation

taion
Copy link
Contributor

@taion taion commented Jul 27, 2016

No description provided.

@taion
Copy link
Contributor Author

taion commented Jul 27, 2016

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

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 :)

Copy link
Contributor Author

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.

Copy link
Member

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 :trollface: to my comment :) You're good :D

Copy link
Contributor Author

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.

@taion
Copy link
Contributor Author

taion commented Jul 27, 2016

Going to merge this for trivial-ness.

@taion taion merged commit 0625e76 into master Jul 27, 2016
@taion taion deleted the syntax-jsx branch July 27, 2016 18:49
@taion
Copy link
Contributor Author

taion commented Aug 6, 2016

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

@taion
Copy link
Contributor Author

taion commented Aug 6, 2016

This doesn't look ideal:

image

@timdorr
Copy link
Member

timdorr commented Aug 6, 2016

npm uses highlights, which uses language-javascript and doesn't support JSX. highlights doesn't use language-babel by default, which does have a JSX grammer, which npm would need to install and configure to get this supported.

Long story short, I would just switch back to js highlighting.

@kentcdodds
Copy link
Member

Awe dang. Sad story :-( I guess the moral of the story is: use jsx for everywhere you expect github to be the only renderer.

@taion
Copy link
Contributor Author

taion commented Aug 6, 2016

Yeah... I'll drop jsx in the README. It's still helpful for the docs proper... though maybe not if we ingest them into a GitBook or something.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants