diff --git a/index.html b/index.html index ae717859ee..3b64840274 100644 --- a/index.html +++ b/index.html @@ -174,28 +174,28 @@

Usage with Node

This might be useful if you're trying to generate static HTML pages with highlighted code for environments that don't support browser-side JS, like AMP pages.

Example:

-
var Prism = require('prismjs');
+	
const Prism = require('prismjs');
 
 // The code snippet you want to highlight, as a string
-var code = "var data = 1;";
+const code = `var data = 1;`;
 
 // Returns a highlighted HTML string
-var html = Prism.highlight(code, Prism.languages.javascript, 'javascript');
+const html = Prism.highlight(code, Prism.languages.javascript, 'javascript');

Requiring prismjs will load the default languages: markup, css, clike and javascript. You can load more languages with the loadLanguages() utility, which will automatically handle any required dependencies.

Example:

-
var Prism = require('prismjs');
-var loadLanguages = require('prismjs/components/');
+	
const Prism = require('prismjs');
+const loadLanguages = require('prismjs/components/');
 loadLanguages(['haml']);
 
 // The code snippet you want to highlight, as a string
-var code = "= ['hi', 'there', 'reader!'].join \" \"";
+const code = `= ['hi', 'there', 'reader!'].join " "`;
 
 // Returns a highlighted HTML string
-var html = Prism.highlight(code, Prism.languages.haml, 'haml');
+const html = Prism.highlight(code, Prism.languages.haml, 'haml');

Note: Do not use loadLanguages() with Webpack or another bundler, as this will cause Webpack to include all languages and plugins. Use the babel plugin described above.