@@ -452,9 +452,8 @@ const HLJS = function(hljs) {
452452 list . unshift ( current . className )
453453 }
454454 }
455- list . forEach ( ( item ) => { emitter . openNode ( item ) }
456- )
457- }
455+ list . forEach ( item => emitter . openNode ( item ) )
456+ }
458457
459458 var lastMatch = { } ;
460459 function processLexeme ( text_before_match , match ) {
@@ -522,28 +521,30 @@ const HLJS = function(hljs) {
522521 }
523522
524523 compileLanguage ( language ) ;
525- var current ;
526524 var top = continuation || language ;
527525 var continuations = { } ; // keep continuations for sub-languages
528- var result = '' ;
526+ var result ;
529527 var emitter = new TokenTree ( ) ;
530528 processContinuations ( ) ;
531529 var mode_buffer = '' ;
532530 var relevance = 0 ;
531+ var match , processedCount , index = 0 ;
532+
533533 try {
534- var match , count , index = 0 ;
535534 while ( true ) {
536535 top . terminators . lastIndex = index ;
537536 match = top . terminators . exec ( codeToHighlight ) ;
538537 if ( ! match )
539538 break ;
540- count = processLexeme ( codeToHighlight . substring ( index , match . index ) , match ) ;
541- index = match . index + count ;
539+ let beforeMatch = codeToHighlight . substring ( index , match . index ) ;
540+ processedCount = processLexeme ( beforeMatch , match ) ;
541+ index = match . index + processedCount ;
542542 }
543543 processLexeme ( codeToHighlight . substr ( index ) ) ;
544544 emitter . closeAllNodes ( ) ;
545- emitter . collapse ( ) ;
545+ emitter . finalize ( ) ;
546546 result = new HTMLRenderer ( emitter , options ) . value ( ) ;
547+
547548 return {
548549 relevance : relevance ,
549550 value : result ,
0 commit comments