aboutsummaryrefslogtreecommitdiffstats
path: root/spring-front/src/highlight_worker.js
blob: 1458026f80ea0b0892f605007364f82265846ff7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import hljs from "highlight.js/lib/core";
import markdown from "highlight.js/lib/languages/markdown.js";
import javascript from "highlight.js/lib/languages/javascript.js";
import python from "highlight.js/lib/languages/python.js";
import C from "highlight.js/lib/languages/c.js";
import bash from "highlight.js/lib/languages/bash.js";

hljs.registerLanguage("markdown", markdown);
hljs.registerLanguage("javascript", javascript);
hljs.registerLanguage("python", python);
hljs.registerLanguage("c", C);
hljs.registerLanguage("bash", bash);

self.onmessage(
  "message",
  (e) => {
    document.querySelectorAll("pre code").forEach((block) => {
      hljs.highlightElement(block);
      postMessage("highlight done");
    });
  },
  false
);