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

Don't show error messages for prismjs missing languages #1076

Closed
iRoachie opened this issue Oct 29, 2018 · 2 comments
Closed

Don't show error messages for prismjs missing languages #1076

iRoachie opened this issue Oct 29, 2018 · 2 comments
Labels
difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. help wanted Asking for outside help and/or contributions to this particular issue or PR.

Comments

@iRoachie
Copy link
Contributor

💥 Proposal

Currently, it's possible to use usePrism: true to set prismjs as the syntax highlighter for all languages. However when a language that prismjs doesn't support is used, the errors are logged to console. Personally think this could be done much better.

 Error: Cannot find module 'prismjs/components/prism-html.min'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Function.require (/Users/kyleroach/Developer/react-native-elements/website/node_modules/docusaurus/lib/core/renderMarkdown.js:52:17)
    at Object.rules.fence (/Users/kyleroach/Developer/react-native-elements/website/node_modules/remarkable/lib/rules.js:73:37)
    at Renderer.render (/Users/kyleroach/Developer/react-native-elements/website/node_modules/remarkable/lib/renderer.js:71:39)
    at Remarkable.render (/Users/kyleroach/Developer/react-native-elements/website/node_modules/remarkable/lib/index.js:152:24)
    at MarkdownRenderer.render (/Users/kyleroach/Developer/react-native-elements/website/node_modules/docusaurus/lib/core/renderMarkdown.js:103:26)
    at toHtml (/Users/kyleroach/Developer/react-native-elements/website/node_modules/docusaurus/lib/core/renderMarkdown.js:113:43) code: 'MODULE_NOT_FOUND' }

References #735 (comment)

Have you read the Contributing Guidelines on issues?

Yes

@endiliey endiliey added help wanted Asking for outside help and/or contributions to this particular issue or PR. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. labels Oct 30, 2018
@endiliey endiliey added the difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. label Nov 11, 2018
@shrirambalaji
Copy link
Contributor

shrirambalaji commented Nov 12, 2018

@endiliey I'd like to take this up. Do you have something in mind, of how we can do better here? It looks like the error is thrown from here

require(`prismjs/components/prism-${language}.min`);

inside renderMarkdown.js if I'm not wrong. Also, based on the exact error mentioned in this issue, it looks like the term language-html is unsupported by prismjs. Would it be useful to add an exception for that, because to me it seems like a reasonable expectation to fallback to language-markup when the user specifies language-html instead.

@endiliey
Copy link
Contributor

Instead of throwing the error stack. Lets log that the language is not supported.

Any other idea is welcomed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. good first issue If you are just getting started with Docusaurus, this issue should be a good place to begin. help wanted Asking for outside help and/or contributions to this particular issue or PR.
Projects
None yet
Development

No branches or pull requests

3 participants