Skip to content

Commit

Permalink
Docs: Mention loadLanguages() function on homepage in the nodeJS se…
Browse files Browse the repository at this point in the history
…ction. Close #972, close #593
  • Loading branch information
Golmote committed Mar 23, 2018
1 parent b26bbb8 commit 4a14d20
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,24 @@ <h1>Basic usage</h1>
var code = "var data = 1;";

// Returns a highlighted HTML string
var html = Prism.highlight(code, Prism.languages.javascript);</code></pre>
var html = Prism.highlight(code, Prism.languages.javascript, 'javascript');</code></pre>

<p>Requiring <code>prismjs</code> will load the default languages: <code>markup</code>, <code>css</code>,
<code>clike</code> and <code>javascript</code>. You can load more languages separately by requiring them
directly from the <code>components</code> folder. Or you can use the <code class="language-javascript">loadLanguages()</code> utility, that
will automatically handle any required dependencies.</p>
<p>Example:</p>

<pre><code class="language-js">var Prism = require('prismjs');
var loadLanguages = require('prismjs/components/index.js');
loadLanguages(['haml']);

// The code snippet you want to highlight, as a string
var code = "= ['hi', 'there', 'reader!'].join \" \"";

// Returns a highlighted HTML string
var html = Prism.highlight(code, Prism.languages.haml, 'haml');</code></pre>

</section>

<section id="languages-list" class="language-markup">
Expand Down

0 comments on commit 4a14d20

Please sign in to comment.