Skip to content

Commit 6e942a4

Browse files
committed
change lib/highlight to lib/core for requiring the lib
1 parent a8c8450 commit 6e942a4

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ onmessage = (event) => {
301301

302302
## Node.js
303303

304-
You can use highlight.js with node to highlight content before sending it to the browser.
305-
Make sure to use the `.value` property to get the formatted html.
304+
You can use highlight.js with node to highlight content before sending it to the browser.
305+
Make sure to use the `.value` property to get the formatted html.
306306
For more info about the returned object refer to the api docs https://highlightjs.readthedocs.io/en/latest/api.html
307307

308308

@@ -314,7 +314,7 @@ const highlightedCode = hljs.highlightAuto('<span>Hello World!</span>').value
314314

315315
```js
316316
// require the highlight.js library without languages
317-
const hljs = require("highlight.js/lib/highlight.js");
317+
const hljs = require("highlight.js/lib/core.js");
318318
// separately require languages
319319
hljs.registerLanguage('html', require('highlight.js/lib/languages/html'));
320320
hljs.registerLanguage('sql', require('highlight.js/lib/languages/sql'));
@@ -371,15 +371,15 @@ import hljs from 'highlight.js';
371371
The default import imports all languages! Therefore it is likely to be more efficient to import only the library and the languages you need:
372372

373373
```js
374-
import hljs from 'highlight.js/lib/highlight';
374+
import hljs from 'highlight.js/lib/core';
375375
import javascript from 'highlight.js/lib/languages/javascript';
376376
hljs.registerLanguage('javascript', javascript);
377377
```
378378

379379
To set the syntax highlighting style, if your build tool processes CSS from your JavaScript entry point, you can import the stylesheet directly into your CommonJS-module:
380380

381381
```js
382-
import hljs from 'highlight.js/lib/highlight';
382+
import hljs from 'highlight.js/lib/core';
383383
import 'highlight.js/styles/github.css';
384384
```
385385

tools/build_node.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { rollupWrite } = require("./lib/bundling.js");
77
const log = (...args) => console.log(...args);
88

99
async function buildNodeIndex(languages) {
10-
const header = "var hljs = require('./highlight');";
10+
const header = "var hljs = require('./core');";
1111
const footer = "module.exports = hljs;";
1212

1313
const registration = languages.map((lang) => {
@@ -18,6 +18,12 @@ async function buildNodeIndex(languages) {
1818
return `hljs.registerLanguage('${lang.name}', ${require});`;
1919
})
2020

21+
// legacy
22+
await fs.writeFile(`${process.env.BUILD_DIR}/lib/highlight.js`,
23+
"// This file has been deprecated in favor of core.js\n" +
24+
"var hljs = require('./core');\n"
25+
)
26+
2127
const index = `${header}\n\n${registration.join("\n")}\n\n${footer}`;
2228
await fs.writeFile(`${process.env.BUILD_DIR}/lib/index.js`, index);
2329
}
@@ -30,7 +36,7 @@ async function buildNodeIndex(languages) {
3036

3137
async function buildNodeHighlightJS() {
3238
const input = { input: `src/highlight.js` }
33-
const output = { ...config.rollup.node.output, file: `${process.env.BUILD_DIR}/lib/highlight.js` }
39+
const output = { ...config.rollup.node.output, file: `${process.env.BUILD_DIR}/lib/core.js` }
3440
await rollupWrite(input, output)
3541
}
3642

0 commit comments

Comments
 (0)