Explorar o código

avoid exception when highlighting empty code blocks

Hakim El Hattab %!s(int64=5) %!d(string=hai) anos
pai
achega
a2e9e525d5
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      plugin/highlight/highlight.js

+ 3 - 0
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 } );