@@ -56,13 +56,12 @@ const HLJS = function(hljs) {
56
56
}
57
57
58
58
function blockLanguage ( block ) {
59
- var match ;
60
59
var classes = block . className + ' ' ;
61
60
62
61
classes += block . parentNode ? block . parentNode . className : '' ;
63
62
64
63
// language-* takes precedence over non-prefixed class names.
65
- match = options . languageDetectRe . exec ( classes ) ;
64
+ const match = options . languageDetectRe . exec ( classes ) ;
66
65
if ( match ) {
67
66
var language = getLanguage ( match [ 1 ] ) ;
68
67
if ( ! language ) {
@@ -137,22 +136,20 @@ const HLJS = function(hljs) {
137
136
}
138
137
139
138
function processKeywords ( ) {
140
- var keyword_match , last_index , match , buf ;
141
-
142
139
if ( ! top . keywords ) {
143
140
emitter . addText ( mode_buffer ) ;
144
141
return ;
145
142
}
146
143
147
- last_index = 0 ;
144
+ let last_index = 0 ;
148
145
top . lexemesRe . lastIndex = 0 ;
149
- match = top . lexemesRe . exec ( mode_buffer ) ;
150
- buf = "" ;
146
+ let match = top . lexemesRe . exec ( mode_buffer ) ;
147
+ let buf = "" ;
151
148
152
149
while ( match ) {
153
150
buf += mode_buffer . substring ( last_index , match . index ) ;
154
- keyword_match = keywordMatch ( top , match ) ;
155
- var kind = null ;
151
+ const keyword_match = keywordMatch ( top , match ) ;
152
+ let kind = null ;
156
153
if ( keyword_match ) {
157
154
emitter . addText ( buf ) ;
158
155
buf = "" ;
@@ -305,7 +302,6 @@ const HLJS = function(hljs) {
305
302
306
303
var lastMatch = { } ;
307
304
function processLexeme ( text_before_match , match ) {
308
- var err ;
309
305
var lexeme = match && match [ 0 ] ;
310
306
311
307
// add non-matched text to the current mode buffer
@@ -324,7 +320,7 @@ const HLJS = function(hljs) {
324
320
// spit the "skipped" character that our regex choked on back into the output sequence
325
321
mode_buffer += codeToHighlight . slice ( match . index , match . index + 1 ) ;
326
322
if ( ! SAFE_MODE ) {
327
- err = new Error ( '0 width match regex' ) ;
323
+ const err = new Error ( '0 width match regex' ) ;
328
324
err . languageName = languageName ;
329
325
err . badRule = lastMatch . rule ;
330
326
throw err ;
@@ -337,7 +333,7 @@ const HLJS = function(hljs) {
337
333
return doBeginMatch ( match ) ;
338
334
} else if ( match . type === "illegal" && ! ignore_illegals ) {
339
335
// illegal match, we do not continue processing
340
- err = new Error ( 'Illegal lexeme "' + lexeme + '" for mode "' + ( top . className || '<unnamed>' ) + '"' ) ;
336
+ const err = new Error ( 'Illegal lexeme "' + lexeme + '" for mode "' + ( top . className || '<unnamed>' ) + '"' ) ;
341
337
err . mode = top ;
342
338
throw err ;
343
339
} else if ( match . type === "end" ) {
@@ -370,9 +366,9 @@ const HLJS = function(hljs) {
370
366
}
371
367
372
368
compileLanguage ( language ) ;
369
+ var result = '' ;
373
370
var top = continuation || language ;
374
371
var continuations = { } ; // keep continuations for sub-languages
375
- var result ;
376
372
var emitter = new options . __emitter ( options ) ;
377
373
processContinuations ( ) ;
378
374
var mode_buffer = '' ;
@@ -520,8 +516,8 @@ const HLJS = function(hljs) {
520
516
two optional parameters for fixMarkup.
521
517
*/
522
518
function highlightBlock ( block ) {
523
- var node , originalStream , result , resultNode , text ;
524
- var language = blockLanguage ( block ) ;
519
+ let node = null ;
520
+ const language = blockLanguage ( block ) ;
525
521
526
522
if ( shouldNotHighlight ( language ) ) return ;
527
523
@@ -534,12 +530,12 @@ const HLJS = function(hljs) {
534
530
} else {
535
531
node = block ;
536
532
}
537
- text = node . textContent ;
538
- result = language ? highlight ( language , text , true ) : highlightAuto ( text ) ;
533
+ const text = node . textContent ;
534
+ const result = language ? highlight ( language , text , true ) : highlightAuto ( text ) ;
539
535
540
- originalStream = nodeStream ( node ) ;
536
+ const originalStream = nodeStream ( node ) ;
541
537
if ( originalStream . length ) {
542
- resultNode = document . createElement ( 'div' ) ;
538
+ const resultNode = document . createElement ( 'div' ) ;
543
539
resultNode . innerHTML = result . value ;
544
540
result . value = mergeStreams ( originalStream , nodeStream ( resultNode ) , text ) ;
545
541
}
@@ -589,7 +585,7 @@ const HLJS = function(hljs) {
589
585
var PLAINTEXT_LANGUAGE = { disableAutodetect : true } ;
590
586
591
587
function registerLanguage ( name , language ) {
592
- var lang ;
588
+ var lang = null ;
593
589
try {
594
590
lang = language ( hljs ) ;
595
591
} catch ( error ) {
0 commit comments