Add syntax highlighting with Pygments or PrismJS.


Add syntax highlighting to code snippets in your Orchid site. Supports pre-rendered highlighting with Pygments, browser-based highlighting with PrismJS, and runnable Kotlin code snippets with Kotlin Playground.


dependencies {
libraryDependencies += "io.github.javaeden.orchid" % "OrchidSyntaxHighlighter" % "0.21.2"


Prism.js Demo
public class HelloWorld {
    public static void main(String[] args) {
        // Prints "Hello, World" to the terminal window.
        System.out.println("Hello, World");
Pygments Demo
public class HelloWorld {
    public static void main(String[] args) {
        // Prints "Hello, World" to the terminal window.
        System.out.println("Hello, World");


Pre-rendered Highlighting

The highlight Template Tag, which will highlight your code using Pygments. Pygments supports many languages out of the box for you with no additional configuration. Pre-rendered highlighting has the advantage of still working in an environment with JS disabled, such as the PDFs generated by the Wiki plugin.

{% highlight 'yaml' %}
title: 'Page Title'
  - type: pageContent
{% endhighlight %}

This plugin includes a default stylesheet for Pygments, which must included in your theme for highlighting to work properly. Simply adding assets/css/pygments.scss in your extraCss is all that's needed, to use the default styling.

    - 'assets/css/pygments.scss' # this file is already available in the plugin's resources

Alternatively, you are free to use your own Pygments theme by creating and adding the necessary stylesheet.

    - 'assets/css/custom-pygments-theme.scss' # you'll need to create this file yourself

In-Browser Highlighting

Alternatively, you may opt for a browser-based solution using PrismJS. This may offer greater flexibility and works with the normal Markdown syntax, but requires Javascript to function. You will also need to manually add language definitions for each language you intend to highlight, which may not be feasible for sites which need many languages highlighted. This component is best added in an Archetype, such as allPages.

    - type: 'prism'
        - 'java'
        - 'kotlin'
        - 'yaml'

Kotlin Playground

The Kotlin Playground allows you to convert Kotlin code snippets into playgrounds that are runnable right in your browser. The kotlinPlayground component adds the script from their CDN, which will select all elements on the page with your runnable Kotlin code and convert them into embedded runnable playgrounds. By default, all Markdown code snippets with a language of run-kotlin are converted.

    - type: 'kotlinPlayground'
      selector: "pre code[class='language-run-kotlin']"

You can configure each individual playground using the attributes described in the Kotlin playground docs. These can be added from Markdown snippets with the following syntax:

fun main() {
   println("Running from Kotlin Playground!")
{theme='darcula' lines='true'}