Prism Highlighter
is a Grav plugin that adds simple and powerful code highlighting functionality utilizing the Prism.js syntax highlighter.
At this time, this version of plugin is not avaiable via Grav Package Manager (GPM). To install you can clone the project. In the Grav root folder, execute:
cd /user/plugins/
git clone https://github.com/clemdesign/grav-prism-highlight.git grav-prism-highlight
Or download the latest release and unzip content in /user/plugins/prism-highlight
Prism.js supports currently 122 languages, at the time of this edit.
In your markdown, you can create a block of code, and assign the language to it. You can choose between the list above. Example:
```java
import java.util.HashSet;
public class Program {
public static void main(String[] args) {
// Create HashSet.
HashSet<String> hash = new HashSet<>();
hash.add("castle");
hash.add("bridge");
hash.add("castle"); // Duplicate element.
hash.add("moat");
// Display size.
System.out.println(hash.size());
// See if these three elements exist.
System.out.println(hash.contains("castle"));
System.out.println(hash.contains("bridge"));
System.out.println(hash.contains("moat"));
}
}```
Configuration shall be set in config/plugins/prism-highlight.yaml
.
Plugin shall be enabled through the option enabled
.
You can also override the default theme for a page with the option theme
.
You can choose between:
default
coy
dark
funky
okaidia
solarized-light
twilight
Check out a live test or a live demo. You can enbale the following plugins:
- Line Numbers => Set option
linenumbers
totrue
If you have the following error in console, disable the option "Javascript Minify" in Grav System Configuration.
Uncaught SyntaxError: Invalid regular expression: missing /