This repository contains a language grammar for Minecraft's .lang files for highlight.js.
First, include the main library as a script. Then, link this grammar. Be sure to also include a theme.
<link rel="stylesheet" href="/path/to/styles/default.min.css">
<script src="/path/to/highlight.min.js"></script>
<script src="/path/to/lang.min.js">
<script>hljs.highlightAll();</script>This will find and highlight code inside of <pre><code> tags; it tries
to detect the language automatically. If automatic detection doesn’t
work for you, or you simply prefer to be explicit, you can specify the language manually in the using the class attribute:
<pre><code class="language-lang">...</code></pre>The bare minimum to auto-detect the language and highlight some code.
// load the library and ALL languages
hljs = require('highlight.js');
html = hljs.highlightAuto('gameTip.findTree=Punch a tree to gather wood.').valueTo highlight code with a specific language, use highlight:
html = hljs.highlight('gameTip.findTree=Punch a tree to gather wood.\n...', {language: 'lang'}).valueNote: Because lang can be so generic at times, it is recommended to not rely on autodetection and instead use
highlightand specify the language.
See Importing the Library for more examples of require vs import usage, etc. For more information about the result object returned by highlight or highlightAuto refer to the api docs.