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: warn unsupported languages by prismjs #1107

Merged
merged 2 commits into from
Nov 12, 2018
Merged

fix: warn unsupported languages by prismjs #1107

merged 2 commits into from
Nov 12, 2018

Conversation

shrirambalaji
Copy link
Contributor

@shrirambalaji shrirambalaji commented Nov 12, 2018

Motivation

Fixes #1076

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

The stacktrace errors thrown by prismjs for unsupported languages (eg: toml) are now logged only as a warning message instead of logging the entire stack trace. This can be tested by doing the following changes:

  1. Set usePrism:true in siteConfig.js.

  2. Modify docs/api-doc-markdown.md to render a language not supported by prismjs.
    Eg: (toml)

    	# This is a TOML document. Boom.
    	title = "TOML Example"
    	
    	[dog]
    	name = "Lucky"
    	breed = "Labrador"
    	
    	[cat]
    	name = "Fluffy"
    	breed = "Siamese"
	cd website
	yarn start

A warning message similar to the screenshot below would be logged in the console.

prism-errors

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Nov 12, 2018

Deploy preview for docusaurus-preview ready!

Built with commit 538b8ee

https://deploy-preview-1107--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. Small nits

console.error(err);
if (err.code === 'MODULE_NOT_FOUND') {
const unsupportedLanguageError = chalk.yellow(
`Warning: language-${language} is not supported by prismjs.` +
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's omit the language- so that it will be something like

`Warning: ${language} is not supported by prismjs.`

Even better if we put different color for the language itself

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@endiliey Okay, Ive made that change.

@endiliey endiliey changed the title Logged unsupported languages by prismjs instead of stacktrace error. fix: better warning for unsupported languages by prismjs Nov 12, 2018
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Nov 12, 2018
@endiliey endiliey changed the title fix: better warning for unsupported languages by prismjs fix: warn unsupported languages by prismjs Nov 12, 2018
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@endiliey endiliey merged commit 91c5e5e into facebook:master Nov 12, 2018
@endiliey
Copy link
Contributor

Thanks ! @Shriram-Balaji

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