November 4, 2013

Code Highlighing in Blogger

I got a relatively easy way to highlight code snippet from http://www.craftyfella.com/2010/01/syntax-highlighting-with-blogger-engine.html.

Step-1:
Add the following code in the template just above the </head> tag.
// Comment
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 




Step-2:
Write code inside <pre> tag. For example,
// Comment
public class Testing {
public Testing() {
}
 
public void Method() {
/* Another Comment
on multiple lines */
int x = 9;
}
}

The above html code gives the output as below
// Comment
public class Testing {
public Testing() {
}
 
public void Method() {
/* Another Comment
on multiple lines */
int x = 9;
}
}

I tried to make it work for R highlighting, but unfortunately it is not working. So, I am using the brush for C inside the <pre> tag.
x <- c(1, 4, -4)
m <- max(x)
print(m)

No comments:

Post a Comment