Prism WP

Beautify the source codes displayed on your site using the Prism syntax highlighter.

Download

How To Use

Preparing the Markup

The following markup is used:

<pre><code class="language-xxx">
    //Insert your code here
</code></pre>

Notice the class language-xxx. You need to change language-xxx to the language you want to use. Below is the list of supported languages and their corresponding CSS class:

Bash class="language-bash"
C class="language-c"
CoffeeScript class="language-coffeescript"
C++ class="language-cpp"
C# class="language-csharp"
CSS class="language-css"
Gherkin class="language-gherkin"
Groovy class="language-groovy"
HTTP class="language-http"
Java class="language-java"
JavaScript class="language-javascript"
Markup class="language-markup"
PHP class="language-php"
Python class="language-python"
Ruby class="language-bass"
SCSS class="language-scss"
SQL class="language-sql"

Line Numbers

To use line numbers, check the Line Numbers option in Settings > Prism WP. Then add the class line-numbers to the pre tag:

<pre class="line-numbers" ><code class="language-xxx">
    //Insert your code here
</code></pre>

Examples

Bash

#!/bin/bash          
echo Hello World

C

#include <stdio.h>
 
int main(void)
{
    printf("Hello World\n");
    return 0;
}

CoffeeScript

# Existence:
alert "Hello World!" if elvis?

C++

#include <iostream>
using namespace std;

int main ()
{
    cout << "Hello World!";
    return 0;
}

C#

public class Hello1
{
    public static void Main()
    {
        System.Console.WriteLine("Hello, World!");
    }
}

CSS

body {
    color: #141412;
    line-height: 1.5;
    margin: 0;
}
a {
    color: #ca3c08;
    text-decoration: none;
}
a:visited {
    color: #ac0404;
}

Gherkin

Feature: Some terse yet descriptive text of what is desired
    In order to realize a named business value
    As an explicit system actor
    I want to gain some beneficial outcome which furthers the goal

Groovy

//hello.groovy
println "hello, world"
for (arg in this.args ) {
    println "Argument:" + arg;
}

HTTP

HTTP/1.1 200 OK
Date: Mon, 23 May 2005 22:38:34 GMT
Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux)
Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT
ETag: "3f80f-1b6-3e1cb03b"
Content-Type: text/html; charset=UTF-8
Content-Length: 131
Connection: close

<html>
<head>
    <title>An Example Page</title>
</head>
<body>
    Hello World, this is a very simple HTML document.
</body>
</html>

PHP

<?php
    echo "Hello world";
?>