PrismJS Code Highlighter
Hepek has support for PrismJS code highlighter.
You need to add the dependencies by extending PrismDependencies
(or manually).
You can use it via PrismCodeHighlightComponents
object:
object Imports:
...
val chl = PrismCodeHighlightComponents.default
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 HTML
Note that withPrompt
, withUser
and withOutputLines
are available only on console languages like bash
and batch
. Nifty! :)
Examples are available here.