Hepek has support for the awesome PrismJS code highlighter.
Add its dependencies by extending PrismDependencies
.
You can use its goodies by importing the PrismCodeHighlightComponents
trait.
Pro tip: Extend this trait as
object chl extends PrismCodeHighlightComponents
and importchl
in your page, so later you can tweak settings inchl
.
Example:
chl.java("""
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, Java!"); // a comment
}
}
""")
gets rendered as:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, Java!"); // a comment
}
}
There is support for all PrismJS languages.
Also, most of PrismJS features are expressed as methods:
chl.<language>.ajax("some.url")
fetches file via AJAXchl.<language>.github("TheAdnan", "focustube", "index.js")
fetches file from Githubchl.<language>.gist("65a82e76597f2fb6c2af", Option("Brick.ts")
fetches from Gistchl.<language>.withLineNumsStart(-2)
sets line numbers start position (see configuration below also)chl.<language>.withLineHighlight("1,5-6")
highlights lines 1, 5 and 6chl.<console-language>.withPrompt("my~awsome~prompt>")
sets promptchl.<console-language>.withUser("superadmin", "10.0.0.7")
sets user and host (to be used as prompt)chl.<console-language>.withOutputLines("2-5")
sets console output lineschl.markup
highlights HTMLNote that withPrompt
, withUser
and withOutputLines
are available only on console languages like bash
and batch
. Nifty! :)
Examples are available here.