Skip to content

highlightjs/highlightjs-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Highlight.js Lang

This repository contains a language grammar for Minecraft's .lang files for highlight.js.

Basic Usage

Web Browser

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>

Node.js on the Server

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.').value

To highlight code with a specific language, use highlight:

html = hljs.highlight('gameTip.findTree=Punch a tree to gather wood.\n...', {language: 'lang'}).value

Note: Because lang can be so generic at times, it is recommended to not rely on autodetection and instead use highlight and 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.

Releases

No releases published