heynote/public/langdetect-worker.js
Jonatan Heyman 8d8f6cdcb3 Add support for Rust, XML and C++
Remove Lezer support
2023-01-16 23:43:22 +01:00

34 lines
713 B
JavaScript

importScripts("highlight.min.js")
const HIGHLIGHTJS_LANGUAGES = [
"json",
"python",
"javascript",
"html",
"sql",
"java",
"plaintext",
"cpp",
"php",
"css",
"markdown",
"xml",
"rust",
]
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,
})
}