You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using (or about to use) prismjs on https://jakearchibald.github.io/svgomg/. I want it to live in a worker because I'm (potentially) dealing with large bits of markup, but also the worker is a convenient script loader.
Hi, sorry for the delay.
I just added a parameter in the worker message that forces it to close after highlighting. So when you use it directly from the outside, it should not close itself unless you pass the parameter.
varworker=newWorker('prism.js');worker.onmessage=function(evt){console.log(JSON.parse(evt.data));};worker.postMessage(JSON.stringify({language: 'markup',code: '<span>'}));// Here, the worker is still open!worker.postMessage(JSON.stringify({language: 'markup',code: '<div>',immediateClose: true}));// Now the worker is closed.
I'm using (or about to use) prismjs on https://jakearchibald.github.io/svgomg/. I want it to live in a worker because I'm (potentially) dealing with large bits of markup, but also the worker is a convenient script loader.
Anyway, I didn't want to spin up a new worker for each usage, but prism wants to terminate after handling a message event. I hacked around it by removing
addEventListener
while it initialises, making it think it's in a node environment https://github.com/jakearchibald/svgomg/blob/feature/code-view/src/js/prism-worker/index.jsDunno if this is something you're interested in making less hacky, but thought I'd bring it up anyway.
The text was updated successfully, but these errors were encountered: