pngwn / MDsveX

A markdown preprocessor for Svelte.
https://mdsvex.pngwn.io
MIT License
2.36k stars 102 forks source link

Enable code highlighting in the REPL #70

Closed pngwn closed 4 years ago

pngwn commented 4 years ago

I think i should be able to build all 5 million language definitions to JSON modules and pop them somewhere accessible relatively easily. Since the preprocessor runs in a worker, loading modules on demand is a little more complicated than it might be. Bundling them and loading them up-front is not an option.

Currently, the browser build completely removes any highlighting because highlighting depends on node require calls. If I wrap those require calls in a function to decouple the loading from any particular mechanism, I could use require in node builds and something else in the browser. I don't think dynamic imports inside workers are well supported but I could use importScript() calls for this in the worker (which is also how mdsvex itself is loaded).

This might work. I think this would fix #65 as well.

pngwn commented 4 years ago

Done.