Autoloader

Automatically loads the needed languages to highlight the code blocks.

How to use

The default usage does not require anything to be done. The plugin will automatically handle missing grammars and load them for you. However, a couple of options are available through the configuration object Prism.plugins.autoloader.

Specifying the grammars path

By default, the plugin will look for the missing grammars in the components folder. If your files are in a different location, you can specify it using the languages_path option:

Prism.plugins.autoloader.languages_path = 'path/to/grammars/';

Using development versions

By default, the plugin uses the minified versions of the grammars. If you wish to use the development versions instead, you can set the use_minified option to false:

Prism.plugins.autoloader.use_minified = false;

Specifying additional dependencies

All default dependencies are already included in the plugin. However, there are some cases where you might want to load an additional dependency for a specific code block. To do so, just add a data-dependencies attribute on you <code> or <pre> tags, containing a list of comma-separated language aliases.

<pre><code class="language-jade" data-dependencies="less">
:less
	foo {
		color: @red;
	}
</code><pre>

Force to reload a grammar

The plugin usually don't reload a grammar if it already exists. In some very specific cases, you might however want to do so. If you add an exclamation mark after an alias in the data-dependencies attribute, this language will be reloaded.

<pre class="language-markup" data-dependencies="markup,css!"><code>

Examples

Note that no languages are loaded on this page by default.

Basic usage with some Perl code:

my ($class, $filename) = @_;

The Less filter used in Jade:

:less
	foo {
		color: @red;
	}