Skip to content

Commit

Permalink
Avoid infinite loop when highlighting an empty input (#14165)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicol貌 Ribaudo <nicolo.ribaudo@gmail.com>
  • Loading branch information
blankPen and nicolo-ribaudo committed Jan 18, 2022
1 parent e1708ff commit e6cc107
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/babel-highlight/src/index.ts
Expand Up @@ -262,7 +262,7 @@ export function getChalk(options: Options) {
* Highlight `code`.
*/
export default function highlight(code: string, options: Options = {}): string {
if (shouldHighlight(options)) {
if (code !== "" && shouldHighlight(options)) {
const chalk = getChalk(options);
const defs = getDefs(chalk);
return highlightTokens(defs, code);
Expand Down

0 comments on commit e6cc107

Please sign in to comment.