heynote/public/langdetect-worker.js

20 lines
600 B
JavaScript
Raw Normal View History

importScripts("highlight.min.js")
2023-01-12 18:55:55 +01:00
2023-01-03 16:56:07 +01:00
const HIGHLIGHTJS_LANGUAGES = ["json", "python", "javascript", "html", "sql", "java", "plaintext"]
onmessage = (event) => {
//console.log("worker received message:", event.data)
2023-01-12 18:55:55 +01:00
//importScripts("../../lib/highlight.min.js")
2023-01-03 16:56:07 +01:00
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,
})
}