summaryrefslogtreecommitdiffstats
path: root/web_src/js/features/highlight.worker.js
blob: 4a0f55f4411bfb58336935d64ec9302712d81ccb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
import {highlightBlock} from 'highlight.js';
import {createWindow} from 'domino';

self.addEventListener('message', ({data}) => {
  const window = createWindow();
  self.document = window.document;

  const {index, html} = data;
  document.body.innerHTML = html;
  highlightBlock(document.body.firstChild);
  self.postMessage({index, html: document.body.innerHTML});
});