File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 1
1
( function ( w ) {
2
2
'use strict' ;
3
3
4
- if ( typeof w . hljs == undefined ) {
4
+ if ( typeof w . hljs === ' undefined' ) {
5
5
console . error ( 'highlight.js not detected!' ) ;
6
6
} else {
7
7
w . hljs . initLineNumbersOnLoad = initLineNumbersOnLoad ;
8
8
w . hljs . lineNumbersBlock = lineNumbersBlock ;
9
9
}
10
10
11
-
12
11
function initLineNumbersOnLoad ( ) {
13
12
w . addEventListener ( 'load' , function ( ) {
14
13
try {
15
- var blocks = document . getElementsByClassName ( ' hljs') ;
14
+ var blocks = document . querySelectorAll ( 'code. hljs') ;
16
15
17
16
for ( var i in blocks ) {
18
17
if ( blocks . hasOwnProperty ( i ) ) {
31
30
var parent = element . parentNode ;
32
31
var lines = parent . outerText . match ( / \n / g) ;
33
32
34
- lines = lines ? lines . length : 0 ;
33
+ lines = ( lines ? lines . length : 0 ) ; // TODO: for IE + 1 ;
35
34
if ( lines > 1 ) {
36
35
var l = '' ;
37
36
for ( var i = 0 ; i < lines ; i ++ ) {
38
- l += ( i + 1 ) + '\n' ;
37
+ l += ( i + 1 ) + '\n' ;
39
38
}
40
39
41
40
var linesPanel = document . createElement ( 'code' ) ;
42
- linesPanel . className = 'hljs-line-numbers' ;
41
+ linesPanel . className = 'hljs hljs-line-numbers' ;
42
+ linesPanel . style . float = 'left' ;
43
43
linesPanel . innerText = l ;
44
44
45
45
parent . insertBefore ( linesPanel , element ) ;
You can’t perform that action at this time.
0 commit comments