File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change 2
2
// See: https://highlightjs.org/usage/
3
3
onmessage = function ( event ) {
4
4
importScripts ( '/vendor/plugins/highlight/highlight.pack.js' ) ;
5
- var result = self . hljs . highlightAuto ( event . data ) ;
6
- postMessage ( result . value ) ;
5
+ var result = self . hljs . highlightAuto ( event . data . text ) ;
6
+ postMessage ( { index : event . data . index , html : result . value } ) ;
7
7
} ;
Original file line number Diff line number Diff line change @@ -1430,12 +1430,13 @@ $(document).ready(function () {
1430
1430
1431
1431
// Highlight JS
1432
1432
if ( typeof hljs != 'undefined' ) {
1433
- $ ( 'pre code' ) . each ( function ( index , element ) {
1434
- var worker = new Worker ( '/js/highlight-worker.js' ) ;
1435
- worker . onmessage = function ( event ) {
1436
- $ ( element ) . html ( event . data ) ;
1437
- }
1438
- worker . postMessage ( $ ( element ) . text ( ) ) ;
1433
+ var codeElements = $ ( 'pre code' ) ;
1434
+ var worker = new Worker ( '/js/highlight-worker.js' ) ;
1435
+ worker . onmessage = function ( event ) {
1436
+ $ ( codeElements [ event . data . index ] ) . html ( event . data . html ) ;
1437
+ }
1438
+ $ ( codeElements ) . each ( function ( index , element ) {
1439
+ worker . postMessage ( { index : index , text : $ ( element ) . text ( ) } ) ;
1439
1440
} ) ;
1440
1441
}
1441
1442
You can’t perform that action at this time.
0 commit comments