diff options
author | terminaldweller <thabogre@gmail.com> | 2022-04-14 18:02:41 +0000 |
---|---|---|
committer | terminaldweller <thabogre@gmail.com> | 2022-04-14 18:02:41 +0000 |
commit | 4f8b298a691e98a6470e8b3bdf61c5d7b8b55001 (patch) | |
tree | c7af55acccb6049b28af478f7b4eb6c1cf468bbe /spring-front/src/highlight_worker.js | |
parent | wip (diff) | |
download | mdrtl-4f8b298a691e98a6470e8b3bdf61c5d7b8b55001.tar.gz mdrtl-4f8b298a691e98a6470e8b3bdf61c5d7b8b55001.zip |
update
Diffstat (limited to 'spring-front/src/highlight_worker.js')
-rw-r--r-- | spring-front/src/highlight_worker.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spring-front/src/highlight_worker.js b/spring-front/src/highlight_worker.js new file mode 100644 index 0000000..1458026 --- /dev/null +++ b/spring-front/src/highlight_worker.js @@ -0,0 +1,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 +); |