Code Embedding

by Golan Levin @ 4:24 pm 10 January 2011

We will use the WP-Syntax WordPress plugin to embed code using attractive formatting and syntax colorization. Information about WP-Syntax is here; additional usage examples are here.

For a quick example, suppose your code is the following:

void setup() {
size(200, 200);
}
void draw() {
smooth();
background(#ffffff);
rect(0,0, width-1,height-1);
ellipse (100, 100, random(80), random(80));
line (0,0, mouseX, mouseY);
}

To see this formatted properly, put the fragment <pre lang=”java”> before your code, and </pre> afterwards. The result will look like the following:

void setup() {
	size(200, 200);
}
void draw() {
        smooth();
	background(#ffffff);
        rect(0,0, width-1,height-1);
	ellipse (100, 100, random(80), random(80));
	line (0,0, mouseX, mouseY);
}

WP-Syntax supports all GeSHI languages, listed here.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2023 Interactive Art & Computational Design / Spring 2011 | powered by WordPress with Barecity