-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load only languages needed support #13
Comments
That's a great idea! I think that would solve #12 as well. To keep the API minimal, I was thinking about just letting the user pass an instance of highlight.js in the options object, which we'd default to That way you could do something like this: const hljs = require('highlight.js/lib/core')
hljs.registerLanguage('javascript', require('highlight.js/lib/languages/javascript'))
const md = require('markdown-it')()
.use(require('markdown-it-highlightjs'), { hljs }) That said I'm not sure what's your exact use case to load just parts of highlight.js, while the above would work as far as RAM is concerned I would assume that this is more about bundling for browser usage? Then depending on the bundler, the above solution might not work, as it could still package the whole But again that could be mitigated with having something like If that makes sense and you feel comfortable writing a PR for that, that'd be awesome! Otherwise I can take a look at implementing it if you confirm that would solve your use case, the changes seem pretty straightforward. :) |
Sounds great!! I will take a look then, but maybe I will need your help to test it properly, let's see what can I do and I will come to you with something hahahaha :) Merciii!! 🥰 |
Niice, thanks a lot! Feel free to reach out to me if you have questions or need a hand =) |
👋🏽 Hi! This is a feature I'd like to use. The VS Code Markdown language extension uses Highlight.js to highlight fenced code blocks, but does not expose the I've started to work on this, but @Dawntraoz if you've already made progress I would prefer to collaborate. |
@igetgames feel free to start I had a lot of work and different projects, so It was quite a difficult time for me 💜 |
Fixed with #15 and 3.4.0, cheers! 🎉 |
Here's an example of the feature for the use case I described above. |
At the moment, highlightjs is loading every language included.
As you can see in this section: https://github.com/highlightjs/highlight.js#es6-modules, there is a possibility to only load the languages you need in your project.
What we have now (The default import imports all languages.)
import hljs from 'highlight.js'; // require('highlight.js')
Import only the library and the languages you need:
It will be nice to have an option call languages, by default could be all and just leave require('highlight.js') as it's now, and if it is filled just make as you're doing for register new languages:
What do you think? If you think is a good improvement I'm open to do it, I'm using this module in my personal projects 💜 Thanks a lot for your work!
The text was updated successfully, but these errors were encountered: