From a2e9e525d5d1f02f8b712be379f8cc4bc1dacb25 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Mon, 27 May 2019 07:30:08 +0200 Subject: [PATCH] avoid exception when highlighting empty code blocks --- plugin/highlight/highlight.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin/highlight/highlight.js b/plugin/highlight/highlight.js index e50676f6..776f09ca 100644 --- a/plugin/highlight/highlight.js +++ b/plugin/highlight/highlight.js @@ -117,6 +117,9 @@ c:[{cN:"comment",b:/\(\*/,e:/\*\)/},e.ASM,e.QSM,e.CNM,{b:/\{/,e:/\}/,i:/:/}]}}); hljs.highlightBlock( block ); + // Don't generate line numbers for empty code blocks + if( block.innerHTML.trim().length === 0 ) return; + if( block.hasAttribute( 'data-line-numbers' ) ) { hljs.lineNumbersBlock( block, { singleLine: true } );