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

Check for language existence before trying to highlight #226

Merged
merged 2 commits into from
Oct 1, 2020

Conversation

smoores-dev
Copy link
Contributor

@smoores-dev smoores-dev commented Sep 30, 2020

Description of Change

hljs throws an error if you pass an unregistered language name to hljs.highlight(). We need to verify that the language has been registered (hljs.getLanguage() returns undefined for unregistered languages) before trying to use hljs.

Related Issue

#225

Motivation and Context

Checklist

  • Ran npm run lint and updated code style accordingly
  • npm run test passes
  • PR has a description and all contributors/stakeholder are noted/cc'ed
  • tests are updated and/or added to cover new code
  • relevant documentation is changed and/or added

hljs throws an error if you pass an unregistered language name to `hljs.highlight()`. We need to verify that the language has been registered (`hljs.getLanguage()` returns `undefined` for unregistered languages) before trying to use hljs.
@afischer afischer linked an issue Oct 1, 2020 that may be closed by this pull request
Copy link
Member

@afischer afischer left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix! 👍

@afischer afischer merged commit 910c2e8 into nytimes:master Oct 1, 2020
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

Successfully merging this pull request may close these issues.

Unknown languages crash render
2 participants