WordPress syntax highlighting


I recently switched my blog from joomla to wordpress and i’m having problems when posting code snippets.

The editor seems to remove some of the characters when i save my posts.

I am using a plugin that i got from this link: http://alexgorbatchev.com/SyntaxHighlighter/


<pre class="brush: javascript">;
var window.onload = function() {
    alert("Loading is complete");

Is formatted to:

var window.onload = function() {
    alert("Loading is complete");

How can i solve this problem?


If you’re on WordPress.com, I believe you should be using a shortcode like so: http://en.support.wordpress.com/code/posting-source-code/

If you’re on self-hosted WordPress and using the WordPress plugin Syntax Highlighter (http://wordpress.org/extend/plugins/syntax-highlighter/), again I think the correct way to insert code is by wrapping it in a shortcode. So instead of < pre > you would use:

// your code here

If neither of these sounds like an ideal solution (or works) there are a bunch of other syntax highlighter plugins for self-hosted WordPress that might be better: http://wordpress.org/extend/plugins/search.php?q=syntax+highlighter

Hope this helps – best of luck!

Answered By – Michelle

Answer Checked By – Jay B. (AngularFixing Admin)

Leave a Reply

Your email address will not be published.