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

Does not highlight "json", "jsx", ... #1

Closed
karland opened this issue Sep 12, 2017 · 2 comments
Closed

Does not highlight "json", "jsx", ... #1

karland opened this issue Sep 12, 2017 · 2 comments

Comments

@karland
Copy link

karland commented Sep 12, 2017

Thanks for the package. It highlights "javascript", but no "json" or "jsx" (and probably no other non-core languages, but I have not tested this).

The reason is that the

import prism from 'prismjs'

only imports the standard prism.js file. However this is generated primarilly for the website, as described in the README and does not contain all the languages.

If one wanted other non-core languages to be included, it seems one needs to generate his own prism.js from the download page, which is then not imported by your package.

Alternatively, there is a discussion that you can require language files, see here.

So to at least allow for "json" and "jsx" you would need to require.

import prism from 'prismjs'
require('prismjs/components/prism-jsx');
require('prismjs/components/prism-json');

There is probably a more general solution. What do you think?

@stephenmathieson
Copy link
Collaborator

Sorry, not sure why I wasn’t watching this repo!

You’re right, you’ll have to add language support on your own (just like CSS). For example:

import Prism from '@majisoftware/react-prism'
import 'prismjs/components/prism-XXX'

<Prism language="XXX">...</Prism>

If we were to include all languages here, this component would be unnecessary huge.

Would a note in the README suggesting this solve your problem?

@karland
Copy link
Author

karland commented Nov 29, 2017

Thanks for your reply. Well, I guess I opened this issue for clarification. A note in the README would have been helpful...

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

No branches or pull requests

2 participants