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

enh: add Safe Mode. Better error handling for crashes. #2286

Merged
merged 7 commits into from
Nov 20, 2019
Merged

Conversation

joshgoebel
Copy link
Member

@joshgoebel joshgoebel commented Nov 14, 2019

Closes #2276.

Makes Highlight.js more resilient in the face of serious errors:

  • When registering languages a serious error will result in a "plaintext" equivalent being registered, rather than crashing completely. Related: fix: freeze built-in modes to prevent grammars altering them #2271
  • When parsing a serious error will result in the raw code (HTML encoded) being returned in the result object along with an errorRaised key, rather than crashing completely
  • The old (more crash prone) behavior can be requested with hljs.debugMode()
  • Both Demo & Developer Tool run in Debug Mode by default

These changes are intended to make Highlight.js more resilient when running in production: That an error only affecting one code block or one language definition wouldn't prevent ALL code blocks from being highlighted.

@joshgoebel joshgoebel added enhancement An enhancement or new feature parser labels Nov 14, 2019
@joshgoebel joshgoebel added this to In Progress in Highlight.js via automation Nov 14, 2019
@joshgoebel joshgoebel added this to the 9.17 milestone Nov 14, 2019
Copy link
Collaborator

@egor-rogov egor-rogov left a comment

Choose a reason for hiding this comment

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

Looks good.

@joshgoebel joshgoebel merged commit 47b61ae into master Nov 20, 2019
Highlight.js automation moved this from In Progress to Done Nov 20, 2019
@joshgoebel joshgoebel deleted the safe_mode branch December 6, 2019 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature parser
Projects
No open projects
Highlight.js
  
Done
Development

Successfully merging this pull request may close these issues.

Suggest: remove default throw behavior
2 participants