Skip to content
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

Add docs: Using only a subset of languages with Node/npm #1257

Closed
vladshcherbin opened this issue Jul 24, 2016 · 5 comments
Closed

Add docs: Using only a subset of languages with Node/npm #1257

vladshcherbin opened this issue Jul 24, 2016 · 5 comments

Comments

@vladshcherbin
Copy link

@vladshcherbin 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
Copy link
Member

@isagalaev 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

Loading

@Remo
Copy link

@Remo 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?

Loading

@Remo
Copy link

@Remo 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'));

Loading

@danoc
Copy link

@danoc danoc commented Dec 7, 2016

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

Loading

@joshgoebel joshgoebel changed the title How to use only needed languages from npm Using only a subset of languages with Node/npm Oct 7, 2019
@joshgoebel joshgoebel changed the title Using only a subset of languages with Node/npm Add docs: Using only a subset of languages with Node/npm Oct 7, 2019
@joshgoebel
Copy link
Member

@joshgoebel joshgoebel commented Dec 26, 2019

This is in the README now.

Loading

@joshgoebel joshgoebel closed this Dec 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants