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
Labels
docs/website good first issue Should be easier for first time contributors help welcome Could use help from community

Comments

@vladshcherbin
Copy link

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

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

@Remo
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
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
Copy link

danoc commented Dec 7, 2016

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

@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 joshgoebel added good first issue Should be easier for first time contributors help welcome Could use help from community labels Oct 7, 2019
@joshgoebel
Copy link
Member

This is in the README now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs/website good first issue Should be easier for first time contributors help welcome Could use help from community
Projects
None yet
Development

No branches or pull requests

5 participants