Code Embedding

by admin @ 1:05 am 17 January 2012

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) 2024 Interactive Art and Computational Design, Spring 2012 | powered by WordPress with Barecity