Skip to content

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

Merged
joshgoebel merged 7 commits intomasterfrom
safe_mode
Nov 20, 2019
Merged

enh: add Safe Mode. Better error handling for crashes.#2286
joshgoebel merged 7 commits intomasterfrom
safe_mode

Conversation

@joshgoebel
Copy link
Copy Markdown
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 the 9.17 milestone Nov 14, 2019
Copy link
Copy Markdown
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.

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

None yet

Development

Successfully merging this pull request may close these issues.

Suggest: remove default throw behavior

2 participants