mirror of
https://github.com/heyman/heynote.git
synced 2025-02-16 18:21:02 +01:00
17 lines
562 B
JavaScript
17 lines
562 B
JavaScript
|
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,
|
||
|
})
|
||
|
}
|