mirror of
https://github.com/heyman/heynote.git
synced 2024-12-23 23:28:58 +01:00
20 lines
600 B
JavaScript
20 lines
600 B
JavaScript
importScripts("highlight.min.js")
|
|
|
|
const HIGHLIGHTJS_LANGUAGES = ["json", "python", "javascript", "html", "sql", "java", "plaintext"]
|
|
|
|
onmessage = (event) => {
|
|
//console.log("worker received message:", event.data)
|
|
//importScripts("../../lib/highlight.min.js")
|
|
|
|
const result = self.hljs.highlightAuto(event.data.content, HIGHLIGHTJS_LANGUAGES);
|
|
postMessage({
|
|
highlightjs: {
|
|
language: result.language,
|
|
relevance: result.relevance,
|
|
illegal: result.illegal,
|
|
},
|
|
content: event.data.content,
|
|
idx: event.data.idx,
|
|
})
|
|
}
|