diff --git a/extending.html b/extending.html index ed0d2f1c0b..de25798507 100644 --- a/extending.html +++ b/extending.html @@ -7,6 +7,7 @@
Note: You can declare a component as both require
and modify
We consider the dependencies of components an implementation detail, so they may change from release to release. Prism will usually resolve dependencies for you automatically. So you won't have to worry about dependency loading if you download a bundle or use the loadLanguages
function in NodeJS, the AutoLoader, or our Babel plugin.
If you have to resolve dependencies yourself, use the getLoader
function exported by dependencies.js
. Example:
const getLoader = require('prismjs/dependencies');
+const components = require('prismjs/components');
+
+const componentsToLoad = ['markup', 'css', 'php'];
+const loadedComponents = ['clike', 'javascript'];
+
+const loader = getLoader(components, componentsToLoad, loadedComponents);
+loader.load(id => {
+ require(`prismjs/components/prism-${id}.min.js`);
+});
+
+ For more details on the getLoader
API, check out the inline documentation.