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

How to use only needed languages from npm #1257

Open
vladshcherbin opened this Issue Jul 24, 2016 · 4 comments

Comments

Projects
None yet
4 participants
@vladshcherbin
Copy link

vladshcherbin commented Jul 24, 2016

If you install the package from npm, the built file has all languages.

How is it possible to use only some languages?

@isagalaev

This comment has been minimized.

Copy link
Member

isagalaev commented Aug 10, 2016

Sure. You can pass languageSubset as a parameter for highlightAuto(): http://highlightjs.readthedocs.io/en/latest/api.html#highlightauto-value-languagesubset

@Remo

This comment has been minimized.

Copy link

Remo commented Oct 18, 2016

@isagalaev but that will not exclude the files from the packed JavaScript file or am I missing something?

in index.js we have a ton of calls to require:

var hljs = require('./highlight');

hljs.registerLanguage('1c', require('./languages/1c'));
hljs.registerLanguage('abnf', require('./languages/abnf'));
...

As far as I understand we can just avoid index.js and include highlight.js directly and then call registerLanguage for the languages we actually need?

@Remo

This comment has been minimized.

Copy link

Remo commented Oct 18, 2016

Here's my complete example which is working for me

var hljs = require("highlight.js/lib/highlight.js");
hljs.registerLanguage('xml', require('highlight.js/lib/languages/xml'));
hljs.registerLanguage('sql', require('highlight.js/lib/languages/sql'));
@danoc

This comment has been minimized.

Copy link

danoc commented Dec 7, 2016

Thanks, @Remo. This was incredibly helpful. Would love to see it documented on the website or README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment